Converting Virtual Box Images (VDI) to VHD and VHD to VDI

Update Nov 21 2011
Use this command to chagne UUID of a copied disk where you ran sysprep to get new machine name

C:\Program Files\Oracle\VirtualBox>vboxmanage.exe internalcommands sethduuid F:\
vDisks2\sp8.vhd

Result
UUID changed to: 84dccb27-6b22-4716-b64e-161c1a2620c5

 
Update Oct 2011, it seems you do not need to do this stuff below, it is much easier to run this command, it worked like a charm from my windows 7 machine with vBox installed on it.

C:\Program Files\Oracle\VirtualBox>VBoxManage  clonehd H:\MyDisk.vdi f:\NewDisk.vhd –format VHD

This is from Spiceworks,
Convert the .vdi file to a raw disk image (.raw)

No need to convert from VHD to VDI because Virtualbox supports VHD which is Microsoft VM format.

This is command I used

C:\Program Files\Oracle\VirtualBox
vboxmanage.exe internalcommands converttoraw "D:\Disks\NDAExchVM.vdi" "G:\diskimage.raw"

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.

Convert_to_raw_big

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.

Convert_to_vmdk_big

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.

Advertisements