Skip to main content

Converting Virtual Box VM to Hyper-V VM (VDI to VHD)



Introduction

There are times when you use Virtualbox and for some reason need to convert over to VMWare or Hyper-V (or other).
Finding this process on the Internet is tedious, and usually involves using QEMU, an open-source Virtualization product to perform the .raw --> .vmdk step. However, if you are running on Windows, the QEMU Windows port will not perform the conversion without failure (at least on Windows 7!). So with that, I decided to go another route with a handy tool that I've used for years in some variation or another, WinImage. It is a worthwhile app to add to your IT toolbox, and I highly suggest supporting the author.
Tools you'll need:
. Sun VirtualBox - http://www.virtualbox.org
. WinImage (Shareware) - http://www.winimage.com
Requirements:
Free disk space should be around 2 times the size of the .vdi disk image file size.
For the sake of this document, we will use .vmdk as our output file, but the conversion steps are the same when it comes to .vhd.

Steps (3 total)

1

Convert the .vdi file to a raw disk image (.raw)

Perform a search on your system for existing .vdi files that you are going to convert.
a. Go to a cmd prompt and navigate to the VirtualBox folder (typically c:\program files\sun\VirtualBox).
b. Execute the following command against the .vdi file in question:
vboxmanage.exe internalcommands converttoraw "x\path-to-vdi\diskimage.vdi" "x:\path-to-output-folder\diskimage.raw"
Depending on the size of your .vdi file, the time for conversion may greatly vary. Also, be sure you have around 2 times the available drive space that your existing .vdi currently consumes on your logical volume.
i.e. if you have a 16gb .vdi file, just to be safe, I would make sure you have 32Gb free on your physical disk to ensure the conversion process can complete without errors. Usually you won't need this much, but it is good to be safe.
2

Convert .raw disk image to .vmdk format using WinImage

a. Open WinImage, click on 'Disk'> 'Convert Virtual Hard Disk image...'
b. Next to the 'File name:' field, click on the file type drop-down and select 'All files (*.*)'.
c. Navigate to the location where you stored your outputted .raw disk file and double-click it.
d. Choose whether you wish to 'Create Fixed Size Virtual Hard Disk' or 'Create Dynamically Expanding Virtual Hard Disk' (I typically pick the latter) and click 'OK'.
e. Navigate to a folder where you wish to store the newly converted image to. Next to 'Save as type:' (for the sake of this How-to) choose 'VMWare VMDK (*.vmdk). and click 'Save'.
You should see a 'Reading disk' progress indicator giving you the status of the conversion process. I've converted 30Gb images in about 10 minutes or less...but I have no firm numbers.
f: Once the conversion is complete, you'll see a dialog box that will ask you if you wish to connect to the partition. Click 'OK' if you wish to view the contents.
3

Import your disk images into your existing Virtual Infrastructure

Now that the files are converted, copy or move your converted disk image files to your virtualization software's datastore/disk storage folder.
Once moved/copied, you should now be able to create a new Virtual Machine and utilize the disks you just converted.
Note that you will need to install the proper guest additions/tools to the virtual machine when you get it booted, so you will likely not have network access right off the bat.

Conclusion

Indeed, that was a quick How-to, but it's an important process that gets easily overlooked. The WinImage step makes quick work of converting the .raw image...and it is easy!

References


**********************************************************************************************************************************

If you are using Oracle Virtual Box with .vdi format for the disk image and want to move your virtual machine to Microsoft Hyper -V there is a small migration required as currently Hyper-V doesn’t read the .vdi file.
The good part is that its extremely easy as well as Virtual Box also comes with a GUI to convert .vdi files to .vhd files.

  1. Open Virtual Box and go to Files > Virtual Media ManagerVirtual Box vdi vhd
  2. Select the disk file you want to migrate and click copy.Virtual Box vdi vhd-1
  3. Select the output format of the disk file (Hyper-V and VMWare support .VHD file) and click copy.Virtual Box vdi vhd-4
  4. Wait for the the copy to complete and then it can be plugged into Hyper-V
    Virtual Box vdi vhd-5
Oh yes ! there is a nerdier way of converting the file too, just locate the VirtualBox binaries and fire the following command ðŸ˜‰
If you have any questions please feel free to PM me or leave a comment.



Comments