03/08/2007 Updated! Now there are informations on how to convert multiple vmdk disc images into a single .vdi disc image!
So you like Virtual Box and want to switch to this wonderfull Open Source software but you allready have a Vmware Virtual Machine you often use? Don’t worry, it is tricky but you can convert a Vmware virtual machine into one that will work on Virtual Box. Why this conversion is absolutelly convenient for you? Read my next post about How to Install Virtual Box and why you should do it.
So, everything is about the virtual disc image. There’s no need to convert the Virtual Machine into one for Virtual Box, once we’ve converted a .vmdk hard disc image (For VMWare) into a .vdi disc image (For VBox) we can just run VBox and create a new Virtual Machine similar to the one we had on VMWare.
First of all, download qemu, you can do it using Synaptic or simply opening a Console and executing:
sudo apt-get install qemu
And that’s the first step. Now open a console and go into the folder where you’ve got your .vmdk virtual disc image and type this:
qemu-img convert harddrive-name.vmdk -O 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 whant to transform it into a .vdi file!
Now we need a new application. You’ll find it here. Download it into the same dir where you’ve got your new raw .bin disc image file. The name of this app is vditool.
Downloading that vditool file is not the simplest thing in the world. If you try and open it with Firefox, for example, a strange page with weird code in it will appear. To save this vditool file, 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 you the download manager: Aria. It is into Ubuntu repositoryes.
Now that we’ve got vditool, we need to make it executable. Right click on the file, open its propertyes 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 console again, from the same dir where you’ve stored dvitool 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 vdi tool 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 this invented names with real ones.
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.
Now we’re going to optimize the filesize of the newly converted .dvi file, let’s call it new-file.dvi and fromth console in the dir where you’ve got this file, run:
LD_LIBRARY_PATH=/opt/VirtualBox* ./vditool SHRINK new-file.vdi
Now we’re all setted up. Let’s run Virtual Box. At this point, you have to create a new Virtual Machine, set it up as you like and choose the new-file.dvi as disc image. If everything is okay, the machine will run, even if it will have to be settep up again a bit from inside the OS you’re using. For example, Windows has got a lot of problems in this part.
When I started my old disc image converte into a new compressed .vdi file inside a new Virtual Machine created with VBox, WinXP refused to start. I had to insert in the CD-Rom my original WinXP Cd to boot from cd and restore the windows installation! Windows, this way, reconfigured and installed each new virtual peripheral so that at reboot everything was okay and all my programs where left installed where they were.
Multiple vmdk files to vdi
A lot of people have been asking me about this. I sincerely didn’t have a clue on how to convert multiple vmdk vmware virtual disc images into a vdi VB virtual disc image. Luckily, Leonardo Cosmai just provided us with a solution in one of the comments on this post! You can see that post for yourself.
What you have to do is:
1) Downloading and installing VMWare Server for your platform, it is freeware but proprietay software, it is opensourced but you’ll need to subscribe for a license to use it. We’ll just use this to convert multiplevmdk images into a single one. You can find VMWare Server here.
2) Run a terminal, move in the dir where you store your multiple vmdk disc images and run:
vmware-vdiskmanager -r source_multiples.vmdk -t 2 single_file.vmdk
And that’s all! The multiple vmdk images will be converted into one single vmdk image file. At that point you’ll be able to normally use this guide to convert the newly obtained vmdk disc image into a single .vdi file!
I sincerely hope this helped a lot of people out there. It is almost impossible to find a way to use vditool in Google for now. No matter how much you google, I spent the all day trying to find something. Thanks to the guys from the VBox IRC Channel for helping me out, I wasn’t going to get out from this problem alone. And a lot of people in Ubuntu Forum where in my same conditions, so…. Enjoy your migration to Virtual Box!