Qemu images can’t be growed. In this example I will show you a little hack to grow a 6GiB
qcow image to a 10GiB image. Beware: these operations can take a lot of time to perform and require lots of free space.
First, convert your
qcow image to a plain raw file:
$ qemu-img convert system.qcow -O raw system.raw
Then, create a dummy file (filled with zeros) of the size of extra space you want to add to your image. In this case, 4GiB (=10GiB - 6GiB):
$ dd if=/dev/zero of=zeros.raw bs=1024k count=4096
Fearlessly, add your extra space to your raw system image:
$ cat system.raw zeros.raw > big10G.raw
After that you can boot qemu to verify that added free space is available:
$ qemu -hda big10G.raw
Here is an real case example of what you can see in a qemu image on which Windows XP was installed:
$ qemu -hda big10G.raw -cdrom gparted-livecd-0.3.4-5.iso -boot d
This will allow you to grow and manipulate all your partitions safely thanks to parted and other open source system tools.
Finally you can convert back your
raw image to a
qcow one to not waste space:
$ qemu-img convert big10G.raw -O qcow growed-system.qcow
That’s all !
By the way, I think it’s possible to perform the second and third step of this how-to in a single operation using