Migrating from VirtualBox to VMware
Friday, May 23rd, 2008As part of the Gnash buildbot farm, I run several virtual machines as build slaves. I started with VirtualBox because it is free software and I prefer to support free software, but it’s still a bit too fragile and it still lacks x86_64 guest support.
When I discovered that VMware Server is now available for free–well, free as in beer, anyway–I happily installed it and set up some new VMs on it. Best of all, it supports x86_64 guests! Of course, now I have the problem of migrating those VirtualBox guest VMs over to VMware.
VMware uses its own VMDK format for storing virtual disk images, while VirtualBox uses its own VDI format. The first step is getting a copy of vditool, VirtualBox’s command line program for manipulating VDI files.
The host OS I used to run VirtualBox is Ubuntu’s 8.04 Hardy Heron on AMD64. The VirtualBox 1.6.0 .deb package didn’t include vditool, for some reason. Fortunately, the VirtualBox package in Debian’s “lenny” release includes it, so lets just grab it from there.
$ wget http://http.us.debian.org/debian/pool/main/v/virtualbox-ose/virtualbox-ose_1.5.6-dfsg-6_amd64.deb $ dpkg -x virtualbox-ose_1.5.6-dfsg-6_amd64.deb vbox-1.5.6 $ sudo cp vbox-1.5.6/usr/lib/virtualbox/vditool /usr/lib/virtualbox/vditool $ sudo ln -sf /usr/lib/virtualbox/vditool /usr/bin/vditool
There, now we have vditool installed. Next, we use it to export our old VirtualBox VDI back to raw disk data. However, if you used VirtualBox’s “Snapshots” with differencing VDI’s, you need to discard all snapshots before the one you want to write out as the raw disk: only the “base” data gets written out, not the “Current State”.
$ cd ~/.VirtualBox/VDI $ vditool copydd win2000-i386-32gb.vdi win2000-i386-32gb.dd vditool Copyright (c) 2004-2008 innotek GmbH. Copying VDI image file="win2000-i386-32gb.vdi" to DD file="win2000-i386-32gb.dd"... The operation completed successfully!
Be careful, this could consume a lot of disk space, if you were using compacted VDI’s instead of fixed size as the raw image will be the full size of the disk image, which in my case was 32 GB even though the VDI only took ~6.5 GB on disk.
Once we have the raw data, we can create the VMDK metadata for our DD image. We compute the size of the raw data in sectors by dividing its size in bytes by 512:
$ stat --printf="%s 512/p" win2000-i386-32gb.dd | dc 67108864
We also need to compute the CHS geometry of the virtual disk. I used the assumption of 255 heads and 63 sectors:
$ stat --printf="%s 512/255/63/p" win2000-i386-32gb.dd | dc 4177
Once we have that information, we go ahead and create the VMDK metadata. Change the elements highlighted in blue as appropriate for your system:
$ cat >win2000-i386-32gb-flat.vmdk <<-__EOF__ # Disk DescriptorFile version=1 CID=4dd210c6 parentCID=ffffffff createType="monolithicFlat" # Extent description RW 67108864 FLAT "win2000-i386-32gb.dd" 0 # The Disk Data Base #DDB ddb.virtualHWVersion = "4" ddb.geometry.cylinders = "4177" ddb.geometry.heads = "255" ddb.geometry.sectors = "63" ddb.adapterType = "buslogic" __EOF__
There, we now have a VMDK suitable for use in VMware! But, it takes up all 32 GB of space on the disk while only ~6.5 GB is actually in use. Lets use vmware-vdiskmanager to create another VMDK that is growable, instead:
$ vmware-vdiskmanager -r win2000-i386-32gb-flat.vmdk -t 0 win2000-i386-32gb.vmdk Using log file /tmp/vmware-dossy/vdiskmanager.log Creating a monolithic growable disk 'win2000-i386-32gb.vmdk' Convert: 100% done. Virtual disk conversion successful.
And there you have it: a growable converted VMDK from VDI:
$ ls -lh win2000-i386-32gb* -rw------- 1 dossy dossy 32G 2008-05-23 11:26 win2000-i386-32gb.dd -rw------- 1 dossy dossy 327 2008-05-23 13:40 win2000-i386-32gb-flat.vmdk -rw------- 1 dossy dossy 6.5G 2008-05-23 14:25 win2000-i386-32gb.vdi -rw------- 1 dossy dossy 6.3G 2008-05-23 14:20 win2000-i386-32gb.vmdk
From here, I created a new virtual machine under VMware Server, specifying “Custom” and using an existing virtual disk–the one I just created.
Of course, I couldn’t just boot this VM up because the virtualized hardware from VirtualBox differs from the virtualized hardware in VMware, and the particular VM in question is a Microsoft Windows 2000 guest. To fix the Windows install, I performed a “repair installation” of Windows 2000. I guess this is necessary when you change all the hardware out from underneath a Windows machine. After completing the repair installation, the VM booted up! I went ahead and installed VMware Tools, rebooted, and now everything works as expected.
I don’t know how many folks out there want to migrate away from VirtualBox to VMware, but I couldn’t find very much useful information on doing it so hopefully this will help people out who want to do it.
Tags: HOWTO, VirtualBox, VMware









May 20th, 2009 at 7:47 pm
Hello Dossy, I'm coming back after some time still surprised with good news. Native Broadcom support in kernel (b43 driver) has ...
May 19th, 2009 at 10:16 pm
God conceived of–not literally “created”–everything at once but that some would only come to manifest at a certain point in ...
May 19th, 2009 at 7:53 pm
Hey Dossy your Twitter Karma tool is very nice, thank you for creating it. "Similarly, the pro-evolution arguers insisting that such ...
May 18th, 2009 at 10:49 am
Hello, The Electronic cigarette do not quit smoking, nothing replaces the will. However, it can replace some cigarettes daily and allows ...
May 17th, 2009 at 1:25 am
1 Corinthians 10:13 (New International Version) 13 No temptation has seized you except what is common to man. And God is ...