Shell Person Help me keep the shell people alive.


Using a VirtualBox Machine in Both Linux and Windows


It isn't difficult to use a VirtualBox virtual machine in both Linux and Windows, but it wasn't immediately obvious to me, so perhaps it will be helpful.  The virtual machine consists of two primary parts; the virtual hard drive (named yourvirtualmachinename.vdi), and an XML file which contains the settings for the virtual machine (named yourvirtualmachinename.xml).  Both of these files are contained within the ".VirtualBox" folder in your home directory ("/home/username/.VirtualBox" in Linux, and probably "C:\Documents and Settings\username\.VirtualBox" in Windows XP).  The leading period "." in ".VirtualBox" indicates that it's a hidden folder in Linux.  The .vdi hard disk file will be in the "HardDisks" subdirectory, while the .xml config file will be in the "Machines" subdirectory, in another subdirectory with the name of your virtual machine.  Unfortunately, the .xml configuration file will not work in a new host with a different operating system, so you can't simply register the old file with the new host.

When migrating the virtual machine to another computer (or just another operating system), you will only need to copy the .vdi hard disk file.  Put it in the "HardDisk" subdirectory on the new host and select "New..." from the "Machine" menu.  Give the new virtual machine a name (it doesn't matter what), set the memory to the same level as you used on the old host (I doubt it matters if it's the same, but that's what I did - 512 MB), and choose "Existing" in the Virtual Hard Disk selection screen.  That will open the "Virtual Media Manager".  Select "Add" and then choose the .vdi virtual disk you copied from your other host system.

Once the 'new' machine has been created, adjust the settings to your liking.  I enable both sound and USB, and set up a shared folder.  In both Linux and Windows I use my Desktop as the shared folder (and name it, surprisingly, "Desktop").  Inside my Windows XP guest virtual machine, I've mapped the shared "Desktop" folder to drive letter X: with the command net use x: \\vboxsrv\Desktop (at the command prompt), and then set my Windows desktop to "X:\", so my virtual machine desktop is the same as the host machine's desktop.  This is done by changing the registry key named "Desktop" (found at "HKEY_CURRENT_USER > Software > Microsoft > Windows > CurrentVersion > Explorer > User Shell Folders") to the value "x:".  Once the net use command and the registry change have been done once, it will continue to work in both Linux and Windows (and presumably Mac?) as long as the shared folder is named "Desktop".

All this entire process is doing is creating a new "yourvirtualmachinename.xml" file for the new host, but using the same virtual hard disk.  I haven't tried it, but I imagine that you could use the same virtual hard disk file in both operating systems in a dual boot environment.  I'm assuming the best way of doing this would be to put the file on an NTFS partition, as most Linux distributions now have native NTFS read-write capabilities.

Here are the software versions I was working with:
Debian Sid (a.k.a. Unstable)
Windows XP Professional SP2
Sun xVM VirtualBox 2.1.4