I need to extend the root partition of a virtual machine (VM) using LVM (Logical Volume Manager). I can afford a few minutes of downtime so a VM shutdown/reboot is fine. The virtual hard disk is in qcow2 format but I can translate it to a raw format easily if it helps.Search engines did not help that much because answers usually refer to using a LVM partition to host the virtual hard disk, here the LVM partition is inside the virtual hard disk which is a simple file.The virtual machine is running with linux-kvm and must stay bootable after the operation.
How to extend an ext3 partition over LVM inside a file (virtual machine)?
partition;virtual machine;lvm;kvm
Your safest pick, without the need of making any changes to your current qcow disk, is adding another disk to the VM. Once you have rebooted, you can run these commands:pvcreate /dev/${newdisk}vgextend ${vgname} /dev/${newdisk}lvextend -L +${n}G /dev/${vgname}/${root_lv} (+ means add to LV ${n} GBs)resize2fs /dev/${vgname}/${root_lv}In the end you get extra room on / with just a reboot.