Qemu disk image conversion

I see that there is some confusion over how to convert disk images from various popular emulators, and I thought I’d try to clear some of this up. Without a doubt, the best free tool available for this is qemu-img. And it’s free! Currently as I write this, that makes Qemu 0.14.0 the current version. I’ll cover the common ones that I use.

For the most part for Qemu I used the qcow2 format. Naturally you can use any of these formats in Qemu… While others are limited.

Converting from..

Virtual PC source image..
To convert to a qcow2:

qemu-img convert source.vhd -O qcow2 destination.qcow2

To convert to VMDK for VMWare:

qemu-img convert source.vhd -O vmdk destination.vmdk

And to convert to a raw image, suitable for BOCHS.

qemu-img convert source.vhd -O raw destination.raw

And of couese you can mix and match from there… Say take your qcow2 and convert it for VPC like this:

qemu-img convert source.qcow2 -O vpc destination.vpc

Or convert a Virtual PC/Virtual Server/Hyper-V vhd (as long as the hyper-v image is consolodated) and convert it to VMWare like this:

qemu-img convert source.vhd -O vmdk destination.vmdk

Note that these VMWare VMDK’s are not for ESX/ESXi, they use more of a raw partition set… But of course you can always convert them to RAW then dd them into the target partition… But I’ll leave that exercise to you. Honestly that vmware converter thing is much easier as it’ll inject the needed drivers.

Speaking of which, this only converts image formats, don’t forget about pre-loading the needed drivers!

I hope this helps out anyone trying to move disk images around.

7 thoughts on “Qemu disk image conversion

  1. Yes, that’s the great thing about that utility! In that example I used the extension ‘.disk’ but the format was qcow2 …

  2. Well, at least conversion to vdi doesn’t workout too well: the current VirtualBox doesn’t pick up the image, complaining about unsupported version…
    Didn’t try vmdk, went with raw ahead, which worked out good but not with 0.15. (0.15 converted a smaller image fine, but kept telling “write error” on a larger image).

  3. I stick with raw, I worry that at some point I’ll run out of disk space, a write in qcow will try to extend the image, it can’t, and my file system will be garbage. Rather have the disk space committed up front. Anyway disk is dirt cheap these days, especially given the size of images of earlier machines.

    • I just filled a 4TB disk, and most of it went to giant disks for VMs that barely had anything on them… but in the scale of things it doesn’t matter I suppose.

      Any luck with a config like the one I mentioned? qcow or raw shouldn’t matter. I did use an actual SUN-5 ROM, although the OpenBIOS should be up to Solaris and maybe even SunOS by now.

Leave a Reply to Robert Dinse Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.