Converting .vmdk to a .vdi image.

Recently I came across a situation where I needed to convert a .vmdk (VMware 6) disk image to a .vdi (VirtualBox) image.

I tried the method in http://thedarkmaster.wordpress.com/2007/03/12/vmware-virtual-machine-to-virtual-box-conversion-how-to/ but it didn’t seem to work for me. The vdi image was not bootable. The VirtualBox VM gave a fatal error saying that no bootable media were found.

The following is another workaround which needs only a linux installation / live cd and VirtualBox.

  1. Create a new VirtualMachine in VirtualBox, and use an existing linux vdi image or put in a live linux cd in to your physical cdrom drive and set the VM to use the physical cdrom drive.
  2. Create a “New” dynamically expanding vdi image (Use the File->Virtual Disk Manager in Virual Box to do this).
  3. In your virtual machine add this newly created image as a hard disk drive. (primary slave)
  4. Go back to the Virtual Disk Manager and “Add” a new disk image, select your vmdk image as the image file.
  5. Add this image to your VM as a hard disk drive (secondary slave).
  6. Boot the VM
  7. Open a terminal and try to mount the secondary slave. In my case it was /dev/sdc2. If it mounts without any errors you are good to proceed.
  8. #mkdir /mnt/disk
    
    #mount -t ntfs /dev/sdc2 /mnt/disk
  9. Dump the secondary slave to the primary slave using dd
  10. # dd if=/dev/sdc of=/dev/sdb

    This would take some time (for me it took around an hour to dump a 9GB image)

  11. Turn off the VM.
  12. Remove all the hard disk drives from the VM leaving only the newly created vdi (mounted as primary slave)
  13. Make it the primary master
  14. Boot the VM
  15. If every thing went ok then the vm should boot fine with the new vdi image, and would be identical to the vmware virtual machine using the vmdk image.

Note

If your vdi image has a Windows OS then you would need to take a look at http://www.virtualbox.org/wiki/Migrate_Windows.

Further you may need to enable IO-APIC in the virtual image.

About these ads

One Comment to “Converting .vmdk to a .vdi image.”

  1. Excellent, thanks a lot for this! That’s excatly what I was looking for.

    PS: I believe, in 1. you meant ‘VirtualBox’ instead of ‘VMware’.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: