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.
- 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.
- Create a “New” dynamically expanding vdi image (Use the File->Virtual Disk Manager in Virual Box to do this).
- In your virtual machine add this newly created image as a hard disk drive. (primary slave)
- Go back to the Virtual Disk Manager and “Add” a new disk image, select your vmdk image as the image file.
- Add this image to your VM as a hard disk drive (secondary slave).
- Boot the VM
- 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.
- Dump the secondary slave to the primary slave using dd
- Turn off the VM.
- Remove all the hard disk drives from the VM leaving only the newly created vdi (mounted as primary slave)
- Make it the primary master
- Boot the VM
- 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.
#mkdir /mnt/disk #mount -t ntfs /dev/sdc2 /mnt/disk
# dd if=/dev/sdc of=/dev/sdb
This would take some time (for me it took around an hour to dump a 9GB 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.
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’.
Kolik
September 18, 2008