VirtualBox Appliance Problem With Linux Guests
I have been struggling with the feature of export / import appliance in VirtualBox for a couple of days now and every time it failed and my frustration grew. The problem i had was that my guest system couldn’t find its partitions after import.
Finally i found the issue, it was due to that my guest OS(openSUSE) called the partition by name ID instead of with device name, the ID was unique to the machine being exported thus changed for the new imported machine.
This has been tested on VirtualBox 2.2.4 with openSUSE as guest configured for server usage.
To make this work you must change how the boot loader calls the partitions upon startup. It seems the common behavior these days is to call the partitions by ID and thus the problem with exporting/importing Linux appliances for now on VirtualBox.
What we are going to do is to change from using ID to Device in our Linux guest.
1. Start your system in init 3 mode, in openSUSE you already boot into init 3 when you have configured your system to act as a server during installation, on other systems i don’t know how to do this but it should be easy to find in your system documentation.
2. Login with an account with administrators privileges on your Linux guest.
3. Find out what device name your partitions have and write them down properly, any mistake and the machine might not boot again.
# fdisk -l
Disk /dev/sda: …
Device Boot Start End Blocks Id System
1 1 65 522081 82 Linux swap / Solaris
2 * 66 1566 12056782+ 83 Linux
As we can see my disk is called sda and i have 2 partitions, the needed partition numbers in my case are 1 & 2, you can directly translate the 1 & 2 to your device name under /dev/, i have sda1 & sda2 where sda1 is the swap(1) and sda2 is the boot(2) marked with a * as shown above.
4. Now we should edit the menu.lst under /boot/grub/ and change disk information. Look for root=… and resume=… on rows starting with kernel should be more than than one of each.
# nano /boot/grub/menu.lst
For safety edit just those for normal boot first and try if it works, if not you can go to safe mode(init 3) and continue editing the menu.lst file again.
This is what i found:
root=/dev/disk/by-id/ata-VBOX_HARDDISK_VB49c304d2-7e24e06f-part2
resume= /dev/disk/by-id/ata-VBOX_HARDDISK_VB49c304d2-7e24e06f-part1
The ‘root’ is the actual boot partition that is mounted as / and resume is the swap partition. This is what i changed them to, based on the output above:
root=/dev/sda2
resume=/dev/sda1
Save your file.
5. Edit /etc/fstab file, you will be able to boot without editing this but you get some errors at boot, so i recommend editing this file to and just replace following data same way as above.
From:
/dev/disk/by-id/ata-VBOX_HARDDISK_VB49c304d2-7e24e06f-part1 swap …
/dev/disk/by-id/ata-VBOX_HARDDISK_VB49c304d2-7e24e06f-part2 / …
To:
/dev/sda1 swap …
/dev/sda2 / …
6. Now to the final step, edit the /boot/grub/device.map change the (hd0) to same as above.*
7. Reboot your virtual machine and try to boot on the menu alternative you just edited, your system should boot as normal and you should be able to use the appliance feature of VirtualBox.
* This step was missed the first time and should be done to ensure system stability.


October 23rd, 2009 at 4:34 am
Good post! I plan to move into this stuff after I’m done with school, as most of it is time consuming. It’s a great post to reference back to. My blog needs more time to gain in popularity anyway.