Lvm – How to increase KVM guest disk size using LVM VG as storage pool

disk-space-utilizationkvm-virtualizationlvm

The KVM host server is running CentOS 6.5 and a LVM volume group "storage_pool" is used as the main storage pool for KVM.

An Ubuntu guest is installed using an ext4 filesystem and mounts the whole /dev/vda1 as /. This is the guest disk configuration:

<disk type='block' device='disk'>
  <driver name='qemu' type='raw' cache='none' io='native'/>
  <source dev='/dev/storage_pool/kvmguest.img'/>
  <target dev='vda' bus='virtio'/>
  <alias name='virtio-disk0'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>

What would be the best approach to increase the guest disk size? The VG has a lot of free space.

I have found some examples but most use LVM inside the guests as well, or weren't completely applicable. As far as I understand, the common method is to create a larger LV in the same VG, shutdown the guest, transfer the data, edit the configuration to use the new LV?

Thanks in advance for any suggestions or pointers

Best Answer

There is no need to shutdown the guest (at least no longer in 2019).

Simply

lvextend -L+<size>G /dev/<group>/<volume>

then

virsh blockresize <domain> /dev/<group>/<volume> --size <newsize>

and finally go into your guest and do whatever is necessary in your guest to make use of the extra space.

In a Windows guest you can do

diskpart

list volume

select volume <n>

extend

These are the exact steps I followed to expand the C: drive of a Windows 10 guest running as KVM domain under Ubuntu 19.04 with qemu 3.1.0