Safe Shrinking of ext3 LVM volumes

When shrinking your LVM volumes, it is important to do it safely. I will show you how I like to do that here.

Shrinking

Shrinking an ext3 volume is fairly straight forward, but it’s important you don’t mount your drive and start doing stuff, before you verify everything worked correctly.

e2fsck -f /dev/vg/lv1

resize2fs -p /dev/vg/lv1 ###G

e2fsck /dev/vg/lv1

lvresize -L ###G /dev/vg/lv1

e2fsck /dev/vg/lv1

Step #5 is the most important step; as steps 1-3 will not have any problems unless you have a system failure, a corrupted file system to start with, disk failure, or hardware failure. Step 5 however, could be due to sys-admin error, from shrinking the LVM volume too much. If you receive an error similar to the following, then you probably shrunk the volume too much, and your file system is not completely accessible.

e2fsck 1.41.9 (22-Aug-2009)
The filesystem size (according to the superblock) is 113634135 blocks
The physical size of the device is 112197632 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? cancelled!

If the error is due to shrinking too far, then this is easy to recover from; simply do another lvresize, with a large size specified, and do another e2fsck afterward.

Generally speaking, you should make the LVM maybe 2% or so larger than the file system was reduced to, so that there’s room for file system overhead.