Elegantly resizing a Linux LVM volume in a virtual machine…

I’ve seen many articles on how to resize a LVM volume after increasing a virtual disk capacity. Most write-ups call for adding partitions and simply adding them to the volume group. While it is simple, it’s not future proof since the number of partitions is limited.

Here’s the way I do it. I hope you enjoy!

  1. Resize your virtual disk (this depends on your hypervisor, I use VMware so YMMV)
  2. Shut down the VM, find an ISO that has GParted. I use PartedMagic but the GParted Live ISO works too.
  3. Boot from the ISO, start GParted.
    1 GParted
  4. Select the LVM physical volume, right click on it then click on deactivate.
    2 Deactivate
  5. Then right click on Resize/Move
    3 Resize
  6. Resize the partition (here, sda2, yours might be different)
    4 Resize
  7. Apply the changes by clicking the green checkmark in the toolbar at the top. Click Apply in the popup.
    5 Apply
  8. Don’t forget to reactivate the LVM physical volume.
    6 Activate
  9. In the terminal, enter the following commands (volume group names may vary) do an ls /dev/ if you’re not sure.
    #extend the volume
    lvm lvextend /dev/lv_hostname/lv_root /dev/sda2
    #check the filesystem for inconsistencies
    e2fsck -f /dev/lv_hostname/lv_root
    #resize the filesystem
    resize2fs /dev/lv_hostname/lv_root
  10. Shut down the VM, unmount the iso.
  11. You’re done.

Namaste.