document updated 13 years ago, on May 18, 2011
Resizing LVM PVs (physical volumes — see this diagram)
resizing root partition
If you're resizing the root VG, you have to do some extra steps beforehand:
- Boot into a LiveCD that has LVM support built-in.
- Locate and activate the LVMs.
- vgscan --mknodes
- vgchange -ay
- lvscan
shrinking
- "Defragment" the PEs (physical extents)
- pvmove -v --alloc anywhere /dev/sda5
- The man page says "pvresize will refuse to shrink PhysicalVolume if it has allocated extents after where its new end would be. In the future, it should relocate these elsewhere in the volume group if there is sufficient free space, like pvmove does."
- Ignore this — the 'pvmove --alloc anywhere' thing does work
- Shrink the PV
- lvm pvresize --setphysicalvolumesize 40G /dev/sda1
- Shrink the physical partition.
expanding
- expand the physical partition (eg. in gparted)
- lvm pvresize /dev/sda1
- it will automatically take up the entire partition
calculating the correct partition size after shrinking
- lvm pvs --units s
- ... SEE HERE
External links