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!
- Resize your virtual disk (this depends on your hypervisor, I use VMware so YMMV)
- Shut down the VM, find an ISO that has GParted. I use PartedMagic but the GParted Live ISO works too.
- Boot from the ISO, start GParted.
- Select the LVM physical volume, right click on it then click on deactivate.
- Then right click on Resize/Move
- Resize the partition (here, sda2, yours might be different)
- Apply the changes by clicking the green checkmark in the toolbar at the top. Click Apply in the popup.
- Don’t forget to reactivate the LVM physical volume.
- 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
- Shut down the VM, unmount the iso.
- You’re done.