LVM Cheat Sheet

Expand a logical volume

Source

  • Make sure the host partition is big enough (using parted or gparted) (must be done offline if partition is mounted)

The following commands can be done online (even if the logical volume is in use)

  • Check disk usage (Allocated / Free)

sudo lvm vgdisplay

  • Check allocation of the lv

sudo lvs

  • Expand a a volume (for example extend to a 80 GB volume)

sudo lvextend -L80G /dev/mapper/VolGroup-lv_something

  • Resize the filesystem (not the dev mapper path)

sudo resize2fs /dev/mapper/VolGroup-lv_something

Shrink a logical volume

Source

This is essentially the same in reverse order, except that the volume must be offline.

sudo resize2fs /dev/mapper/VolGroup-lv_something 30G

sudo lvreduce -L 40G /dev/mapper/VolGroup-lv_something

The above value must be greater than the previous one. As a rule of thumb the file system can be shrink to 90% of what the final value should be.

sudo resize2fs /dev/mapper/VolGroup-lv_something

Page top