How to extend LVM on qcow2 images

Categories Virtualization

Preparing to add some more space for VM’s swap and /. Commands listed below [note: host = node, VM = virtual machine]

Make sure that the VM is stopped before trying this out.

Current VM space layout (compare with final):


* Extend image to required size

* Boot up the VM,  then log into it, delete and recreate LVM partition

* Reboot then VM, and login back to resize physical volume

* I have to extend swap as well, so better unmount swap which is on LVM before extending it

* Now extend swap LVM

* Make Swap and mount it back again

New Swap = 2GB [success!!]

* Now extend root LVM so that it has ~10GB+ space

* Online resize (WARNING: for ext4 only)


So, final VM layout is as follows:


  • Thank you, that was informative! I didn’t know before that you can resize the disk you are using (ok, it does it after reboot, but still…)! Kudos!