After resizing VG,LV,PV, how do you reduce the Partition?

gcmartin

Member
Sep 14, 2010
58
0
6
What tool should be used to resize the physical partition?
If "fdisk" what steps in fdisk should be used? Will fdisk do it without upsetting the LVM?

Here's the Proxmox system's LVM and disk's layout
Code:
# vgscan
  VG   #PV #LV #SN Attr   VSize   VFree
  pve    1   3   0 wz--n- 310.00G 8.52G

# pvscan
  PV         VG   Fmt  Attr PSize   PFree
  /dev/sda2  pve  lvm2 a-   310.00G 8.52G

# lvscan
  LV   VG   Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  data pve  -wi-ao 201.48G                                      
  root pve  -wi-ao  96.00G                                      
  swap pve  -wi-ao   4.00G                                      

# vgdisplay
  --- Volume group ---
  VG Name               pve
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               310.00 GB
  PE Size               4.00 MB
  Total PE              79359
  Alloc PE / Size       77178 / 301.48 GB
  Free  PE / Size       2181 / 8.52 GB
  VG UUID               aJntXw-B3L6-B0kk-BzKU-vi9a-mZ3x-KVn5Fc
   
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               pve
  PV Size               310.00 GB / not usable 3.81 MB
  Allocatable           yes 
  PE Size (KByte)       4096
  Total PE              79359
  Free PE               2181
  Allocated PE          77178
  PV UUID               nIfVEy-nnzR-2PsQ-BS0y-cZmy-Cdor-sNlMds
   
# lvdisplay
  --- Logical volume ---
  LV Name                /dev/pve/swap
  VG Name                pve
  LV UUID                6CYwNT-aiUV-tmVU-0MWl-eDHM-w3TR-VoT6pG
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                4.00 GB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0
 



  --- Logical volume ---
  LV Name                /dev/pve/root
  VG Name                pve
  LV UUID                M9KPLD-EbFP-OyWN-p62N-kp1f-HF3c-NfGeAX
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                96.00 GB
  Current LE             24576
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1
   
  --- Logical volume ---
  LV Name                /dev/pve/data
  VG Name                pve
  LV UUID                rkNVX5-ss9U-gZTS-DAwA-H8I0-DTg7-eVZ2Q8
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                201.48 GB
  Current LE             51578
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:2
   
# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00057353

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          65      522080+  83  Linux
/dev/sda2              66       60801   487859712   8e  Linux LVM

Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-1 doesn't contain a valid partition table
Disk /dev/dm-1: 103.0 GB, 103079215104 bytes
255 heads, 63 sectors/track, 12532 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-2 doesn't contain a valid partition table
Disk /dev/dm-2: 216.3 GB, 216333811712 bytes
255 heads, 63 sectors/track, 26301 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

# df -H
Filesystem                 Size   Used  Avail Use% Mounted on
/dev/mapper/pve-root       102G   746M    96G   1% /
tmpfs                      2.1G      0   2.1G   0% /lib/init/rw
udev                        11M   668k   9.9M   7% /dev
tmpfs                      2.1G      0   2.1G   0% /dev/shm
/dev/mapper/pve-data       212G   197M   212G   1% /var/lib/vz
/dev/sda1                  527M    33M   468M   7% /boot

# mount
/dev/mapper/pve-root on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/mapper/pve-data on /var/lib/vz type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)
 
Hi,
if you have reduce the LVs, the VG and the PV (pvresize --setphysicalvolumesize) you can boot a live cd (like grml) and change the partition-layout (smaller sda2, new sda3).
But be sure, to have a valid backup and you use a little bit bigger partition like the PV.

Perhaps it's easier to connect a second disk; boot grml, expand pve with the second disk, pvmove (from sda1 to second disk), pvremove sda2; new partition layout on sda; pvcreate sda2; vgextend; pvmove back and removing of the second disk...

Udo
 
Thanks Udo
Hi,
if you have reduce the LVs, the VG and the PV (pvresize --setphysicalvolumesize) you can boot a live cd (like grml) and change the partition-layout (smaller sda2, new sda3).
But be sure, to have a valid backup and you use a little bit bigger partition like the PV. ...
Udo
I assume that you mean to use a tool like "fdisk". OR, Did you mean some other disk partitioning tool that only changes the parttion table without touching the partition data? (If I remember, some tools will affect the data.) What are your experiences.
 
Hi,
yes i mean fdisk - but the new partion-layout will only activatet if there are no open PVs on the disk. So if you resize sda2 and create sda3, i would first do an reboot before use (mkfs) sda3.

gparted can reduce partitions, but don't support lvm...

Udo
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!