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.
ls
Ubuntu.vmdk
Ubuntu-f001.vmdk
Ubuntu-f002.vmdk
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.
KVM :
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 :
- If you have vmware-tools installed, you will have mouse integration.
- 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 .
- 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 :
- With VMWare-tools installed, Mouse integration did not work (as it did with KVM).
- The resolution of the guest is also larger then the Virtualbox window.
- 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.
Hey bodhi.
Good job with this one, I had no Idea that was even possible. Thanks!
Great tips, very useful, thanks.
Terrific — thanks!
We migrate from VMware to KVM. With this howto we can reuse our appliances. Great, Thank you very much
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.
Pingback: Augie’s Weblog » Blog Archive » Convert Vmware to virtual box
Pingback: Jonathan
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.
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).
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.
Carl
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.
Pingback: help-v » 将vmware的虚拟机迁移到kvm
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.
frank
Pingback: Convert VMware growable, splitted and snapshoted disks « falstaffs Reise durchs Internet
Pingback: Small is Beautiful » Blog Archive » RHEV - import vmware image into RHEV
Pingback: uberVU - social comments
Pingback: BrainBlog » VMware vApp (from vSphere) to KVM
Pingback: Lucid Lynx - em Schorsch sin Bastelbud
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?
Thanks!!
Kitos: I would assume you would use the same commands in reverse order.
Thanks a lot .. helped me a lot
Great,
But I can’t import, When I start the machine always gives me the same error:
No bootable device.
vmware-vdiskmanager seems to be part of the VDDK Development Kit
Pingback: HOWTO: Migration from VMWare to KVM (Linux) – I couldn’t get it to work!! | FBA Knowledgebase
Pingback: Migrating CentOS5 VMWare images to KVM | Screwtape's Blog
Migrating from VMware to KVM has been an easier experience than I thought it would be. qemu-image is quite useful.
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.
Aeh, I meant: “qemu-img convert /mnt/flat -O qcow2 yyy.vmdk
Pingback: Ubuntu 11.04にKVMを導入する | 記録用手帳
Dude, ur awesome!!! Thanks!!!!!!!!!!!!!
well,
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….
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 VMWARE SERVER
- 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 KVM SERVER
- 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!!!
Pingback: A valid boot sector was not found when tryin to start converted VMs
You can directly convert files to VDI now, just specify -O vdi.