Import esxi 5 vmdk into KVM qcow2

One of my co-workers had the following error while trying to import a VMWare ESXi 5 VMDK file into KVM qcow2 format.

# qemu-img convert -O qcow2 vmtest-disk1.vmdk vmtest.qcow2
qemu-img: error while reading sector 131072: Invalid argument

This error seems to have been generated because the way ESXi 5 virtual machine disk files handle Thin Provisioning. KVM chokes on the any hardware version 8 thin provisioned vmdk disk file.

So one obvious fix is to pick “Thick Provision” for any virtual disk you know will be sent to a KVM host OS. If you need to transfer disk images between hosts, a thick provisioned disk could be a nightmare especially when the image is > 100Gig. However for those times when the machine is already created, or where a Thin Provisioned disk is a must VMware provides a disk utility to convert the disk image.

Here’s how we did it:

From a windows 7 PC, we grabbed a copy of VMware’s vSphere 5.0 Virtual Disk Development Kit from

Run and install the file. This expands several tools into “c:Program Files (x86)VMwareVMware Virtual Disk Development Kit”

Use the following command to convert the vmdk into a format qcow2 can use for imports:

c:Program Files (x86)VMwareVMware Virtual Disk Development Kitbin>vmware-vdiskmanager.exe -r original.vmdk -t 0 newdisk.vmdk

The options “-t 0” specifies the disk type to be “single growable virtual disk”.

Now just wait because this can take a really long time. Once completed, rerun the qemu-img convert command.

Further tinkering found that ESXi 5 Think provisioned disk we were testing was 430Mb in size. If we converted the disks to type 2 (thick provisioned) yielding a 20 gig vmdk and then imported into qcow2 format, the new disk was 1.3 gig, not 20 gig. The qcow2 import took the thick provisioned vmdk and converted it back to a thin provisioned format. This means you *could* also use “-t 2” on the disk conversion command and get a vmdk that was preallocated to full size. However, there seems to be no need for this since the type 0 disk works and keeps the total size down to a manageable level.

In addition, KVM can use native VMDK disk files as well. The type 0 disk worked when used in KVM as a VMDK with no conversion.

Bookmark the permalink.

One Response to Import esxi 5 vmdk into KVM qcow2

  1. mike says:

    hell ye!

    This should be posted on other sites.

Leave a Reply

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

Solve : *
23 − 4 =