document updated 13 years ago, on May 18, 2011
Resizing LVs (logical volumes — see this diagram)
resizing root partition
If you're resizing the root partition, 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
resizing non-root partition
Just unmount first.
shrinking
To shrink, you must first resize the internal filesystem, and then shrink the LVM.
- Shrink the filesystem. Depending on your filesystem type, use one of:
- Shrink the LVM.
- lvreduce
- see "calculating the size" below
expanding
To expand, you must first expand the LVM, and then resize the internal filesystem.
- Expand the LVM.
- Expand the filesystem.
- if it's ext2/3, you don't need to specify the size to resize2fs — if unspecified, it will automatically expand to fill all available space
calculating the size
This is where you can really shoot yourself in the foot. If you tell the filesystem it has more space than the LVM eventually has, then your filesystem will be corrupt.
- Method 1: Pad it out for safety.
If you err the other way (making the LVM bigger than the filesystem), you'll be fine. You'll have some wasted space, but you'll be safe.
- Method 2: (when shrinking an ext2/3FS) Pad it out for safety, reduce LVM, and then expand the ext2/3 to the full size.
Because resize2fs can figure out how much space to use when you're expanding, you can 1) shrink the filesystem too far, 2) shrink the LVM just right, 3) expand the filesystem to take up the entire space, letting resizefs figure out exactly how much space to use.
- Method 3: Calculate EXACTLY how much space to use
External links