Today I received a virtual machine OVA file exported from VMware, I needed to import this into Apache CloudStack where XenServer was the hypervisor.
To do this I first needed to convert the OVA/OVF to VHD, this post covers how it’s done.
Get the VMDK files from the OVA
An OVA file is simply a tar archive file containing the OVF directory. After renaming my .ova file to have a .tar extension, I was able to simply open it with WinRAR and extract the .vmdk files within to get the virtual machines disks. VMDK is an open format used by VMware and VirtualBox, as such we can make use of VirtualBox which is free to convert these files to VHD.
Converting the VMDK file to VHD
From my research I found that the VBoxManage.exe tool which comes with VirtualBox can be used with ‘clonehd’ to specify the new format of the disk. Basically you specify the original disk file, in this case the .vmdk, and then give a location and name to output the .vhd – for further information on this see the VirtualBox documentation here.
Now we run C:\Program Files\Oracle\VirtualBox\VBoxManage.exe as below, the location of which may vary depending on where you have VirtualBox installed.
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd --format vhd M:\disk1.vmdk M:\disk1.vhd 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone hard disk created in format 'vhd'. UUID: 4cfba843-ca57-73s6-8f79-c532e31f5008
In this example we want to convert disk1.vmdk, the format is specified as vhd as this is what the output should be. Other options include VDI and RAW. disk1 was a 25gb .vmdk file which took approximately 15 minutes to complete and when it was done I had a 60gb .vhd file. The progress should update every 10%.
That’s all there is too it, a simple command from VirtualBox can be used to convert a VMDK file to VHD, or in this case a OVA/OVF which contained VMDK files to VHD. This VHD was then successfully imported into Apache CloudStack, it could also be used with other hypervisors that support the VHD format such as Hyper-V.