How to convert a VMWare vmdk appliance to VirtualBox vdi

March 22nd, 2009

There are loads of ready-built appliances for VMWare in .vmdk format but I use VirtualBox and there is never a release in .vdi form to be found. I’ve heard that virtualbox will run the vmware images… but is that true?

I’m a little partial to the aging appliances over at virtualappliances.net but they come in vmdk form and I’ve discovered they have some nasty quirks which might prevent your aspirations. To get their vmware appliances to work in virtual box I had to do this:

Clone the image to a VDI format

vboxmanage clonevdi sourcefile destfile -format vdi

You can actually mount the vmdk files directly into virtualbox but I found I was given two vmware files for each disk. Things weren’t working out. One file was zero kilobytes long, the other the size of the disk. “-flat-” was mentioned in the filename of one of them. I could mount the zero file, but not the flat (read error). It wouldn’t boot and after googling around I got the idea these two vmdk files had to be merged into one to work for virtualbox. VMware provide a tool to do it, but vmware was banished and I’m loathe to reinstall it just for the tool.

Fortunately VirtualBox can do it too via an little option on the new (v2.1.2+) “clonevdi” command: -format vdi

Whilst its nice to get the disks into the native form, I’m not convinced this step is entirely necessary as after some more fooling around I discovered something else significant…

To mount as IDE or SATA?

I’ve mounted the disks and started the new virtual machine. GRUB came up and things were looking good for a boot,

Starting up ...
Loading, please wait...

And wait I did. Wait for a while. Still waiting. Ok nothing’s happening here.

You don’t know whether the machine was created with virtual IDE hard disks, or vitual SATA hard disks. You’ve had to choose one of these two and its not working, so now try the other.

Go into the vbox manager and put the primary disk in “IDE Primary Master” or “Slot 0″ and the swap drive (if you have one) into the second spot.

Settings->Hard Disks->"Enable SATA controller"
->"Slots"

With a bit of luck one of these configurations will actually boot.

Change the network driver

I found my appliance couldn’t connect to the network. In fact it couldn’t even see a network device. Your new VirtualBox machine defaults to a network driver which VMWare does not have. My appliance had been stripped of anything superfluous, like unused network card drivers, so didn’t have the default virtualbox network device driver.

Switching to the Intel Network drivers solved this problem.

Settings->Network->Adapter Type->Intel Pro 1000/MT Desktop

I’ve had a curiousity with the MAC addresses: I created the virtual machine on my hard disk then cloned it over to my USB drive. When i ran up the cloned copy to see if it all worked the network device “failed”. But it turns out it wasn’t failing at all – my dhcp server (a home adsl modem/router) was refusing to assign it an ip address – it must think it’s being spoofed!? When I changed the MAC address of the clone to match MAC address of the original machine it works.

Remove VMWare tools

I was stoked. My appliance was up and running and doing all that was advertised. I started getting comfortable and did a couple of hours work on it. Then rebooted.

Bloody thing wouldn’t work. It would boot all right, but the root hard drive would always mount in readonly mode with a string of errors during the boot sequence complaining about the lack of an “/etc/fstab”. I couldn’t create an fstab because it was in readonly mode.

Well that was pretty bizarre because it was fine the first time, why not the second. How on earth did the fstab go missing?

Turns out vmwaretools had been installed. VMWaretools does something funky at every boot and shutdown like fiddle with your fstab. It’s not pretty and it will mess you up if you’re not using vmware.

So remove vmware tools altogether since we won’t be needing it and it buggers up your fstab. Then fix the fstab once and for all.

The vmware uninstall script assumes you have a “killall” command installed; which I found in the “psmisc” package, but I was behind a proxy so I had to tell apt-get about that too. Gotta love the way technical problems compound don’t you. You can skip the “export” if you’ve no proxy. Note that I copy the fstab elsewhere first because the uninstall will remove all the fstab files leaving you high and dry without any fstab template at all.

So as root


cp fstab.AfterVmwareToolsInstall fstab.bak
export http_proxy=http://username:password@proxy.whatever.com.au:8080/
apt-get install psmisc
/etc/vmware-tools/installer.sh uninstall
cp fstab.bak fstab

Fix your /etc/fstab

Now editing the fstab may be required. Google for the details if you need them, but basically I had to replace the UUID references in the first column back to the typical linux device files: “/dev/sda1″ and “/dev/sda2″ worked for me, but may vary according to whether you have set them to be IDE drives or SATA drives.


/dev/sda1      /       ext3  defaults  1 1
proc           /proc   proc defaults 0 0

Now you can get to work.

Change the hostname

On that particular virtual machine I had a bit of trouble getting the name I put into “/etc/hostname” to stick. Turns out they’ve told rc.local to run their own little configuration script dubbed “/etc/virtualappliances.conf”. There are a couple of other switches in there which might bore you.

  1. No comments yet.
  1. No trackbacks yet.