Converting Virtual Machine Images

By | 24/09/2018

Converting from QCOW2 to RAW

qemu-img convert -p windows7.qcow2 -O raw windows7.raw

qemu-img convert -p windows7.qcow2 -O raw /dev/mapper/3600144f00000000000005367385c0004

Converting from RAW to iSCSI device

ddrescue -v -d -f windows7.raw /dev/mapper/3600144f00000000000005367385c0004 windows7.log

Converting from VMware

Running kvm with vmdk disks

Apparently it is possible to run vmdk disk images directly in KVM. So far I have not had such success. To try this method read the notes on the kvm website

Starting at v0.12, qemu-kvm has native support to VMware’s disk images v6 (seems to be compatible with v7, used by VMware Server). VMware images can be run with qemu-kvm without any modification.

Look at your VMX configuration file:

# grep -e ethernet0.generatedAddress -e vmdk -e uuid.bios XP.vmx
uuid.bios = "56 4d a1 29 00 eb d8 da-df 7a 97 b8 ee 85 99 84"
ide0:0.fileName = "CDrive.vmdk"
ethernet0.generatedAddress = "00:0c:29:85:99:84"

And then build the command-line:

# /usr/libexec/qemu-kvm \
  -vga std \
  -m 1024 \
  -hda /var/lib/kvm/XP/cdrive.qcow2 \
  -net nic,macaddr=00:0c:29:2b:ce:d5 \
  -net tap,ifname=tap0,script=no \
  -localtime \
  -uuid 564d0014-1fba-13e5-31fe-539d082bced5 &

The UUID is optional, but might be useful for applications using it for validation (i.e. Windows), and the MAC address as well.

Converting the VMware disk to kvm native format

NB: If you want to remove VMware Tools you must do this while running under VMware as it checks the host system to verify uninstalltion (go figure!) The qemu-img command is capable of converting disk images to KVM native format:

qemu-img convert -O qcow2 CDrive.vmdk cdrive.qcow2


Leave a Reply