Howto Resize KVM lvm guest image
Here is how you add 5 GB of disk space to your guest:
1a. # qemu-img create -f raw temp.img 5G
2.a # cat oldimage.img temp.img > newdiskimage.img
Sometimes you don’t have enough space to create a complete new image. If thats the case you can use this
1.b #qemu-img create -f raw temp.raw 5G
2.b #cat temp.raw >> oldimage.img
3. After createing the new disk image you can start your VM and login
4. Delete the old lvm partition with fdisk (the one in the VM!).
# fdisk -l to see partition
# fdisk /dev/vda
# Delete lvm (this is the partition with the type 8e)
# Create new one which starts at the same cylinder as the one you deleted (type 8e)
5. reboot the guest
# init 6
6. Now after rebooting and logging in to the VM you can do a
# fdisk -l
and you’ll see the new space you’ve just added to the disk. So lets extend the physical volume, volume group and logical volume (named bla):
# pvresize /dev/vda2
#lvresize /dev/Volgroup/bla -L +5G
#resize2fs /dev/Volgroup/bla
7. If everything went well you should see the new diskspace with the command
# df -h