How do I shrink the root logical volume (LV) on LVM?

The root partition and LV resizing should be done on unmounted partitions, so you have to boot from a rescue CD or USB stick, run it as live CD. Then make sure, that your root LV is not installed, by

mount

and unmount it when necessary. The LVM command vgchange changes attributes of volume groups. What needs to be “changed” to access the volume is the “availability” — i.e. to make the kernel realize the LVM volumes are there. This can be done by the command:

lvm vgchange -a y

Note, in rescue mode the system command is lvm and the LVM command that is run is vgchange. The -a y argument sets the availability to “y” or yes. As there are no specified LVM volume groups, this command will make all LVM volumes found available to the rescue kernel.

Once the kernel is aware of all LVM volumes they will be automatically mapped as devices. These are usually located under /dev/VolGroup or /dev/mapper/VolGroup (where “VolGroup” is the name of the Volume Group). Then do filesystem check

e2fsck -f /dev/yourVG/yourLV

on this LV. Then shrink filesystem

resize2fs /dev/yourVG/yourLV 5G

and reduce LV

lvreduce -L 5G /dev/yourVG/yourLV

Reboot to your system, Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

*