Saturday, July 2, 2011

VDI to VMDK


vdi-to-vmdkThis post explains how to convert vdi to vmdk and open Sun VirtualBoxvirtual machinein to VMware workstation or VMplayer 3. As you are aware, Virtual Box uses VDI as hard disk file and VMware uses VMDK.  Opening VMDK in VirtualBox is very straight forward since VirtualBox supports VMDK. But opening VDI files in VMware workstation or VMware player is not possible, because VMware doesn’t support VDI files.
After I wrote steps to convert VMDK to VDI and How to open VMDK files in Sun VirtualBox, I wanted to try converting VDI to VMDK. When I googled , found only few steps   work with Linux or Mac environment and didn’t work for me in Windows.
Found the two following posts in google first page, but both did not work for me. I’m sure it wouldn’t have worked for others too.
How to convert VDI to VMDK; Converting a VirtualBox image to a VMware disk image and vice versa
how to convert vdi to vmdk in Sun VirtualBox Vbox
So, after several attempts, here are the steps worked for me in converting VDI to VMDK in Windows environment and allowed to open VirtualBox virtual machine in VMware Workstation and player.
Before convert VDI to VMDK, make sure to delete snapshots in VirtualBox. Because each snapshot keeps different hard disk files separately from major disk file. So if you convert the major VDI file to VMDK then you will get the first version of virtual machine before any snapshots. There for we have to merge all snapshots to major disk file to get the latest virtual machine in VMware. By deleting snapshots you can merge all snapshot hard disks to main hard disk file.
Read more about deleting snapshots in VirtualBox 3.1 under branched snapshots.

Steps to Convert VDI to VMDK

1) Convert VDI file to RAW format by Vboxmanage command.
Vboxmanage internalcommands converttoraw >
VDI to VMDK
In this example I have WinXP.vdi at G:\VirtualBox location. You must add path to Windows OS to work this vboxmanage and qemu-img commands.  Read more about setting up these commands paths in Windows which is explained in VMDK to VDI.
2) Once RAW disk is created, now we can convert RAW to VMDK. For this conversion you need third party software QEMU Manager for Windows which can be download here.
VDI to VMDK
3) After installed QEMU Manager for Windows, start the conversion of RAW to VMDK by following command.
Qemu-img convert -O vmdk
VDI to VMDK
4) VMDK file will be stored at the location you specified in command. This VMDK file is containing the same data which VirtualBox VDI file had.
VDI to VMDK
5) Now we will import this VMDK file in to VMware Player 3 and run the same virtual machine which was running in Sun VirtualBox.
When people wanted to change virtual machines between VirtualBox and VMware, they try to convert VMX to XML or XML to VMX. It’s wrong.  You cannot convert virtual machines by converting these files. VMX is a virtual machine configuration file on VMware and XML is for Sun VirtualBox. We must convert the hard disk files (VMDK or VDI) to be able to swap virtual machines.
Then how about VMX and XML? We have to create them. When you create virtual machines in VMware or VirtualBox it creates theses configuration files automatically. So do not waste your time to convert VMX to XML or XML to VMX.
6) To import converted VMDK files to VMware player, just create a new Windows XP virtual machine. You have to create same OS of VDI file. In this example I converted Windows XP VirtualBox virtual machine.  I’m assuming that you know the steps to create Windows XP virtual machine in VMware Player 3, so I’m not going to explain it.
Before start the virtual machine, remove the newly added hard disk during the creation and add the converted VMDK ( VMXP.vmdk) as a hard disk.
7) That’s it. Play the virtual machine. Now, you must be able to see the same Sun VirtualBox virtual machine in VMware Player. You may have to allow drivers installation, because VMware and Sun VirtualBox desktop virtualization software are totally different.

This method not only to transfer virtual machines to VMware from VirtualBox, but also to access VirtualBox VDI files in VMware products.
The similar method can be used to convert VDI to VMDK and open in VMware Workstation.
I hope this post will be useful to convert VirtualBox VDI files to VMware VMDK files in Windows environment and transfer virtual machines between top desktop virtualization software.
Let me know if you face any problem on this VDI to VMDK conversion.