How to enlarge a kvm image
- Stop the kvm maschine.
Convert the kvm image to raw format if necessary.
qemu-img convert -O raw original.img raw.img
Make a backup copy of the image.
Enlarge the raw image.
dd if=/dev/zero of=raw.img bs=1 count=0 seek=[size in]GB
Attach the enlarged image to a loop device.
losetup /dev/loop0 raw.img
Use
fdisk /dev/loop0
to create a new partition or enlarge an existing one to accomodate the additional disk capacity.
Boot the machine using the new image.
Log in to the machine and start up lvm. Either add the new partition as a new physical volume (pvcreate) and add it to a volume group (vgextend) or in case an existing partition was enlarges use
lvm> pvresize /dev/vda2
and add the newly available space to logical volumes
lvm> lvresize -L +511.02G /dev/philipp/home
Enlarge the filesystem (ext2/3).
resize2fs /dev/philipp/home

Leave a comment