Resizing a Windows qemu Image

This is for the crazy few who, like me, run Windows in
KVM on a
Linux host. If you ever need to resize one of your Windows disk images,
these are the steps necessary to accomplish this feat. (Please note the
steps for actually changing the size of the disk image were taken from
this linuxwave blog post) This works for Windows 2008 Server, and
most likely Windows 2008 Server R2. I do not know if it works with any
other versions of Windows.

  • Convert qemu image to raw
1
qemu-img convert -f qcow2 imagename -O raw imagename.raw
  • Extend the image size using dd (In this example, to the size of 10G)
1
dd bs=1 if=/dev/zero of=/path/to/imagename.raw seek=10G count=1 conv=notrunc
  • Convert back to qemu image
1
qemu-img convert -f raw imagename.raw -O qcow2 imagename
  • Boot into Windows and use Storage Manager to resize your partition