Resizing kvm qcow2 disk
I followed this steps in order to add some space to a virtual disk in kvm environment
convert qcow2 disk to be expandend in raw format:
1 |
qemu-img convert -f qcow2 to-be-expandend.img -O raw to-be-expandend.raw |
create extra space, 30G in this case:
1 |
sudo qemu-img create -f raw addon.raw 30G |
merge the two files:
1 |
cat to-be-expandend.raw addon.raw >expanded.raw |
re-convert in qcow2 format:
1 |
qemu-img convert -f raw expanded.raw -O qcow2 expanded.img |
To be used, the extra space needs to be re-partitioned in the guest OS.
To do that, download the Gparted live cd
Then add the cdrom to the guest OS pointing to the downloaded iso. You can do that via the virt-manager or adding an xml like the following in the VM configuration file:
1 2 3 4 5 |
<disk type='file' device='cdrom'> <source file='[DOWNLOAD_PATH]/gparted-live-cd.iso' /> <target dev='hdc' bus='ide'/> <readonly/> </disk> |
Add also the cd boot option:
1 2 3 4 |
<os> <type arch='i686' machine='pc-0.12'>hvm</type> <boot dev='cdrom'/> </os> |
Resize the partition, disable the cdrom boot and restart the VM
Extra space available!
Una risposta.
[…] post about qemu image resize: https://synaptica.info/2012/02/20/resizing-kvm-qcow2-disk/ where you can find some info about image format conversion […]