How to convert an OVA virtual machine to VHD

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%.

Summary

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.

Leave a comment ?

19 Comments.

  1. Thank you, much! I was just Googling how I could take this OVA file that I have & bring it into Hyper-V.

  2. after convert to vhd file ,how to create .ova file?

    • If you have the VHD file essentially you would want to revert this whole process. After converting the VHD to something like VMDK then you can make an OVA in vSphere.

  3. Here is another way of converting VMDK files to VHD or VHDX.http://blogs.msdn.com/b/timomta/archive/2015/06/11/how-to-convert-a-vmware-vmdk-to-hyper-v-vhd.aspx

    Just a matter of which tool you want to use.

  4. How I convert a backup of hyper-v to virtualbox?

    • From my quick research you can usually not simply import a Hyper-V VHD file straight into VirtualBox as Hyper-V seems to add additional information to the file, it may be possible if you change the disk controller to IDE rather than SCSI first in Hyper-V and then try to import it into VirtualBox.

  5. Also if you’re using the files copied straight from an ESXi datastore, you should convert the smaller descriptor file, not the *-flat.vmdk file.

    Another option is microsoft virtual machine convertor which will connect directly to your ESXi system and it also comes with powershell cmdlets to use.

  6. Best way to convert VMDK to VHD

  7. This is the format I’ve had to use in VBOX 5.0.16

    C:\Oracle\VirtualBox>VBoxManage.exe convertfromraw C:\Blah.vmdk Blah.vhd –format vhd

  8. I was looking for days on how to make this work and you came with this. Very useful and strait to the point. Thank you!

  9. Virtual Box must be installed to use it.

    I tried Microsoft Virtual Machine Converter 3.0 but got error ConvertTo-MvmcVirtualHardDisk : The entry 59b560fa-32d3-443f-89fd-1c558e5b13f5 is not a supported disk database

    So I found another solution qemu-img https://cloudbase.it/qemu-img-windows/
    That’s works for me!

  10. That works great! Thanks man

  11. i tried with MVMC and it didn’t work…
    Great job, you saved my life, thanks

  12. When the OVA is large it will extract multiple VMDK files. I ultimately want to create an image in Azure. Do i need to convert all files to VHD or just the largest one?

    • Hmm not sure, try the biggest and see what happens I guess, the others may be other disks attached to the main VM or it may just be split up, don’t have to have single file I don’t think.

Leave a Comment

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