====== Converting your existing .vmdk Virtual Disc Image To a .vdi File ======
Now we need to convert your existing VMWare disc image into a format readable by VirtualBox.
Don't worry, you won't lose any data but, just in case, you can always create a backup copy of your VirtualDisk before we start!
First of all, download qemu, you can do it using Synaptic or simply opening a Console and executing:
sudo apt-get install qemu
Now open a terminal and go into the folder where you’ve got your .vmdk virtual disc image and type this:
qemu-img convert harddrive-name.vmdk raw-file.bin
Naturally, you’ll have to change harddrive-name with the name of your .vmdk file and raw-file with the name of the new converted file you want to create. After a few minutes, the conversion will be completed. Now we’ve got a raw hard disk image and we want to transform it into a .vdi file!
We need a new application called "vditool". You’ll find it here:
[[http://www.virtualbox.org/download/testcase/vditool]]
Download it into the same dir where you’ve got your new raw .bin disc image file. A simple way to download this app is from the command line, like so:
wget http://www.virtualbox.org/download/testcase/vditool
* NOTE: The commands under "Notes for AMD64 users" below work for Ubuntu 8.04 Hardy 32 bit and are much easier than downloading the same file again. Please try that first.
* NOTE: To download vditool using a web browser, right click on the link and choose to save the file. You can also tell a download manager to download this file for you. I suggest using the download manager "Aria", which is in the Ubuntu repositories.
Now that we’ve got vditool, we need to make it executable. Right click on the file, open its properties and set the “Executable” permission option. In Gnome, go into the Permission tag and activate the “Let this program be executed” or something like that option (Remember, my Ubuntu is Italian, dunno what’s your exact translation).
At that point, we’ll need the terminal again, from the same dir where you’ve stored vditool and the .bin raw file. Run this from console into the interested dir:
LD_LIBRARY_PATH=/opt/VirtualBox* ./vditool DD new-file.vdi old-file.bin
Where new-file.vdi is the file that will be outputted by vditool and must be the first to appear in the command. The second filename, old-file.bin, is the name of the raw disc image we converted the .vmdk image to. Naturally, change these invented names for real ones.
* NOTE: If you wish, remember that you can run vditool for other tasks too. Now we’ll run it to optimize the filesize of the .vdi image file, for example. For a list of all commands, you’ve just got to execute vditool without any other option.
Let's optimize the file size of the newly converted .vdi file, let’s call it new-file.vdi and from the terminal in the dir where you’ve got this file, run:
LD_LIBRARY_PATH=/opt/VirtualBox* ./vditool SHRINK new-file.vdi
Now we’re all set up.
* Notes for AMD64 users. The vditool executable above only works on 32 bit systems. If you have a 64bit system then use the "vditool" image and library path from your existing VirtualBox installation. The following commands suit an AMD64 system running Ubuntu 7.10:
LD_LIBRARY_PATH=/usr/lib/virtualbox /usr/lib/virtualbox/vditool DD new-file.vdi old-file.bin
LD_LIBRARY_PATH=/usr/lib/virtualbox /usr/lib/virtualbox/vditool SHRINK new-file.vdi
(These commands should actually work on both 32bit and 64bit systems).