Convert VMware .vmdk to KVM .qcow2 or Virtualbox .vdi

I wrote this how to as I was having problems converting a VMware image to KVM. The existing tutorials all suggest using qemu-img to convert the .vmdk, however it was not working as qemu-img only supports VMware 3 and 4 compatible image formats.

At least that is what Google searching and reading the qemu man pages yielded after I got this error message :

qemu-img convert Ubuntu.vmdk -O qcow2 Ubuntu.qcow
qemu-img: Could not open ‘Ubuntu.qcow’

And to make matters worse, it was difficult to find any information on converting the .vmdk if it was split into multiple files.

This is how I ended up converting. You can convert from a .vdi or a “flat” .vmdk

First convert the .vmdk to a format compatible with qemu-img.

Turns out this can be done with vmware-vdiskmanager.

1. Converting from .vmdk

Use vmware-vdiskmanager to create a copy. This works with a single or multiple disks.

Ubuntu-f003.vmdk ...

vmware-vdiskmanager -r Ubuntu.vmdk -t 0 Ubuntu-copy.vmdk

Note: If you have multiple disks, use Ubuntu.vmdk as well (you do not need to convert each Ubuntu-f001.vmdk).

Note: That is a -t Zero not a capital O. see man vmware-vdiskmanager.

Note: vmware-vdiskmanager is part of vmware server (and workstation, not sure about player).

2. Alternate – Converting “flat files”.

Flat files are used by vmware if you create a virtual disk (vmdk) with the “Allocate all disk space now” option (you have this option when creating disks for use with vmware). Flat files contain all the data from your .vmdk and can (usually) be converted directly.

Notice, flat files can be directly converted to .qcow. If you wish to convert to .vdi (VirtualBox) convert flat to raw.


qemu-img convert Ubuntu-flat.vmdk -O qcow2 Ubuntu-copy.qemu

Note: That is a capital O qcow2

RAW (for VirtualBox)

qemu-img convert Ubuntu-flat.vmdk -O raw Ubuntu-copy.img

Note: That is a capital O qcow2

KVM – Convert to qcow2

Convert the new “copy” .vmdk with qemu-img

qemu-img convert Ubuntu-copy.vmdk -O qcow2 Ubuntu-copy.qemu

Note: That is a capital O qcow2

3. Boot the image with KVM

kvm -hda Ubuntu-copy.qcow -net nic -net user -m 512

Caveats :

  1. If you have vmware-tools installed, you will have mouse integration.
  2. If you have vmware-tools installed, the guest desktop may well be larger then the kvm window. You will need to resize the guest display to 800×600 .
  3. I could not convert a .vmdk which was using LVM (Fedora).

VirtualBox – Convert to .vdi

1. First use qemu-img to convert the copy .vmdk to raw.

qemu-img convert Ubuntu-copy.vmdk Ubuntu-copy.img

qemu-img with no options will make a raw image. If you prefer you can specify

qemu-img convert Ubuntu-flat.vmdk -O raw Ubuntu-copy.img

2. Then convert the raw image with VBoxManage

VBoxManage convertfromraw --format VDI Ubuntu-copy.img Ubuntu-copy.vdi

3. Start VirtualBox, make a new machine or add the Ubuntu.vdi to an existing machine.

Caveats :

  1. With VMWare-tools installed, Mouse integration did not work (as it did with KVM).
  2. The resolution of the guest is also larger then the Virtualbox window.
  3. I installed the VirtualBoxAdditions and guest resolution worked well, mouse integration, however, did not.

As always, I hope this helps. Converting usually went smoothly for me however there is the occasional .vmdk I could not convert.

This entry was posted in Linux. Bookmark the permalink.

39 Responses to Convert VMware .vmdk to KVM .qcow2 or Virtualbox .vdi

  1. Montel says:

    Hey bodhi.

    Good job with this one, I had no Idea that was even possible. Thanks!

  2. wiflye81 says:

    Great tips, very useful, thanks.

  3. HDave says:

    Terrific — thanks!

  4. maurizio says:

    We migrate from VMware to KVM. With this howto we can reuse our appliances. Great, Thank you very much

  5. WRF says:

    When I try to boot either the vmdk or qcow2 file from kvm, it displays an error message
    for a fraction of a second and then returns to the screen asking whether I want to boot
    safe mode. How to I freeze it on the error screen? Thanks.

  6. Pingback: Augie’s Weblog » Blog Archive » Convert Vmware to virtual box

  7. Pingback: Jonathan

  8. Juan says:

    I have a pile of flat vmware images that have been converted using the method described here (although with kvm-img). They appear to convert fine but so far 2 out of 4 fail. One is a Ubuntu feisty vm. The Xorg log file complains of no device found (it contains reference to vmware vga drivers although vmtools were never installed) and there is also no network card present. Another one is WinXP. It doesn’t even boot. I get a BSOD type result.

    There is a lack of online documentation on how to proceed once the images have been converted and how to tackle the kind of problems I have described.

  9. bodhi.zazen says:

    I agree, conversion does not always work. I also agree with the lack of documentation , many sites that use “KVM” in the title are using virsh or virt-manager as front ends, for example.

    I think the problems vary with the VM and for your graphics card try reconfiguring X (boot to recovery mode and try xfix).

  10. Carl Moser says:

    I tried to convert a VMware VM to run on Ubuntu Jaunty KVM but got the Blue Screen of Death.
    When I got it to boot from CDROM so I could do a repair install, it just rebooted.

    KVM is not quite there handling VMware VM’s.


  11. bodhi.zazen says:

    Converting Windows VM does not work so well due to the way Microsoft licenses it’s products.

    Windows is licensed per hardware and changing VM changes your hardware configuration and you are likely to have problems with needing to either re-authorize your installation or re-install drivers.

    IMO, with Windows, you are better off backing up your data and performing a fresh install.

    Converting Linux VM is easier, but still prone to errors.

    The good news is, this process does not change your original VM.

  12. Pingback: help-v » 将vmware的虚拟机迁移到kvm

  13. fjgaude says:

    Waiting for a fix to permit VMware with work with 9.10 Beta I decided to give KVM a try… thanks for your tireless efforts to keep us all on-track.


  14. Pingback: Convert VMware growable, splitted and snapshoted disks « falstaffs Reise durchs Internet

  15. Pingback: Small is Beautiful » Blog Archive » RHEV - import vmware image into RHEV

  16. Pingback: uberVU - social comments

  17. Pingback: BrainBlog » VMware vApp (from vSphere) to KVM

  18. Pingback: Lucid Lynx - em Schorsch sin Bastelbud

  19. Kitos says:

    I want to do the oposite: Convert KVM image in a MVWare image. It’s that possible? Someone knows how to open KVM images in Windows?


  20. bodhi.zazen says:

    Kitos: I would assume you would use the same commands in reverse order.

  21. Harish says:

    Thanks a lot .. helped me a lot

  22. juan says:

    But I can’t import, When I start the machine always gives me the same error:
    No bootable device.

  23. Lennie says:

    vmware-vdiskmanager seems to be part of the VDDK Development Kit

  24. Pingback: HOWTO: Migration from VMWare to KVM (Linux) – I couldn’t get it to work!! | FBA Knowledgebase

  25. Pingback: Migrating CentOS5 VMWare images to KVM | Screwtape's Blog

  26. Migrating from VMware to KVM has been an easier experience than I thought it would be. qemu-image is quite useful.

  27. A. Schuppisser says:

    You can also use the tool vmware-mount comming with the free VMWare-Player to convert any vmdk-File (even in the form of 2GB-splittet) directly to a qcow2 file:
    > vmware -f xxx.vmdk /mnt # Mount vmdk as a raw device-Image -> /mnt/flat
    > qemu-img convert /mnt/flat -O qcow2 /mnt/flat
    > vmware -d /mnt

    Don’t know, if this method is more efficent, but at least you don’t need to install vmware server or vmware converter to do the job.

  28. A. Schuppisser says:

    Aeh, I meant: “qemu-img convert /mnt/flat -O qcow2 yyy.vmdk

  29. Pingback: Ubuntu 11.04にKVMを導入する | 記録用手帳

  30. Connor says:

    Dude, ur awesome!!! Thanks!!!!!!!!!!!!!

  31. Antonio Cosenza says:

    i think one of the most secure method to import Linux guests from different virtualization platform is to use rsync! By the way, Rsync is not the perfect way to convert from phisical to virtual??!! ;-) I converted and imported lots of virtual machines this way!

    Windows? nothing to say….

  32. Vincent says:

    Tried but no luck! (this method may not work for those old vmware server image ) I am using quite a old school vmware server ( version 1.06). After many attempts, I finally worked out a solution, hope this might be useful for some people:
    What I’ve done:

    - On my Old Vmwre server, setup an linux guest machine ( the hard disk must be bigger than the vmare you’re trying to convert ), add the vmware hard disk to this quest machine as secondary hard dish ( /dev/sdb)
    - Boot up the machine, run fdisk -l, you should be able to see 2 hard disk /dev/sda and /dev/sdb
    - Run dd if=/dev/sdb of=sdb-image-dump.raw
    - Once finished, scp the image to your network share drive.

    - On the KVM-QEMU Host machine, setup a linux guest machine, also add a secondary hard disk ( make sure the disk size is identical to your VMware hard disk)
    - Boot up your guest machine on the KVM. (once booted, the server should have /dev/sda and /dev/sdb drive )
    - SCP the dumped image to KVM’s guest machine.
    - Run dd if=sdb-image-dump.raw of=/dev/sdb
    - Once is done, shutdown the KVM guest machine.
    - Now, you can go to the /var/lib/libvirt/image forlder to have your KVM image file.
    - Use the image file to import to your new KVM machine.

    - Bingo!!! it works!!!

  33. Pingback: A valid boot sector was not found when tryin to start converted VMs

  34. You can directly convert files to VDI now, just specify -O vdi.

  35. Pratt G says:

    I tried to convert .vmdk to .img using VBoxManage command but I am getting an error while booting it on KVM hypervisor
    Command :
    VBoxManage internalcommands converttoraw -format RAW source.vmdk target.img
    ERROR:No bootable device
    source.vmdk is Ubuntu 11.10
    VirtualBox 4.1.2

  36. bodhi.zazen says:

    @Pratt G

    I am sorry you are having a problem. I have not seen that error before. You might try the VBox forums or file a bug report.

  37. ferdienandp says:

    looks good but not promising. it didn’t worked for me.

  38. bodhi.zazen says:

    @ferdienandp – I have had mixed results as well. Sort of depends , most common problems come if you have vmware tools installed or a custom kernel.

  39. Oliver says:

    Hi there!

    even in 2014 this blog post was a very helpful resource for me.

    Thanks a lot, Oliver

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>