Using VirtualBox 2.0 to host Xubuntu 8.04 on Windows XP

Change history
2009-02-11: Updated Network configuration notes
2008-11-14: Ubuntu network configuration notes
2008-11-01: Xubuntu 8.10, VirtualBox 2.0.4 related updates.
2008-09-17: First published.

How to install an Xubuntu 8.04 Desktop VM on Windows XP SP2 using the VirtualBox 2.02 virtualization program. I’ve also included some evaluation notes, things I learnt along the way and a (fairly subjective) comparison with VMware Workstation. The focus is on interactive workstation usability not server deployment or graphics performance. My hardware requirements are equally focused: just CD/DVD-ROM, video, audio and networking.

As a software developer requiring all sorts of ad hoc test platforms I’m absolutely sold on virtualization and machine snapshots, I don’t know why it took me so long to start using it. No more unnecessary PCs crowding my office, no multi-boot PCs, KVMs and the interminable partition+format+install cycles.


Environment

Here’s my environment, your mileage may differ in other OS and hardware environments:

VirtualBox
Version 2.0.2 x86
Host OS
Windows XP SP2
Guest OS
Xubuntu 8.0.4 Desktop i386.
Host PC
Compaq Evo D510 Desktop, 2.8GHz P4, 1GB RAM.

The hardware is marginal (the RAM especially so), but it was quite usable (I’m writing this document on it now).


Resources


Installing on Windows

Easy, just download the Windows MSI installer and run it.


Usage

The only VM keyboard shortcuts I use are:

  • Host+F to toggle to and from full-screen mode (default Host key is the right Ctrl key).
  • Host+L to toggle the seamless windows mode. Because I use the Ctrl key a lot with my editor I changed the VirtualBox Host key from Right Ctrl to Right Alt.
  • Ctrl+C and Ctrl+V to cut and paste text between different OS’s.

One thing that is a bit confusing (as of version 2.0.2): you can’t switch directly between full-screen to seamless-windows modes, you need to first toggle back to normal single-window mode first.


Creating Xubuntu Guest VM

This procedure is generic and can be used to install any guest operating system.

  • Create new VM with the New Virtual Machine Wizard (Machine→New menu command).
  • Mount the PCs CDROM drive on the VM:
    • Run VirtualBox Manager Machine→Settings menu command.
    • Select CD/DVD-ROM
    • Tick the Mount CD/DVD Drive checkbox.
    • Tick the Enable passthrough checkbox (if you don’t check this box you won’t be able to write to the drive).
  • Insert Xubuntu install CD-ROM.
  • Click Start button on the VirtualBox main window.
  • Install Xubuntu exactly as you would on a normal PC.

Once this is complete you will be able to restart Xubuntu in the VM.


Installing Guest Additions

The Guest Additions are important, they include:

  • An X display driver that allows you to change the display resolution and can resize the size of the VM window (without it I was stuck with a generic 800×600 screen resolution).
  • Support for seamless windows.
  • Bidirectional cut and paste between host and guest clipboards.
  • A mouse driver that seamlessly integrates the host and guest mouse cursors.

To install (this covered in much greater detail in the User Manual):

  1. Start the Xubuntu VM.
  2. Run the VM windows Devices→Install→Install Guest Additions menu command (toggle from full-screen mode so you can see the VM menu bar). This mounts the Additions ISO file (in the host C:\Program Files\Sun\xVM VirtualBox directory) to /media/cdrom.

    Note

    If the ISO does not mount automatically on your system mount it manually:

    sudo mount -o ro /dev/cdrom /media/cdrom.

  3. Compile and install the additions:
    $ cd /media/cdrom0
    $ sudo sh ./VBoxLinuxAdditions-x86.run

    All the required build tools and headers are present in the default Xubuntu 8.04 install.

  4. Restart Xubuntu.

If you upgrade your Linux kernel you will probably need to reinstall the Guest Additions. To reinstall or update the Guest Additions repeat the above procedure with then updated ISO image (this is also covered in the manual).

Xubuntu 8.10 with VirtualBox 2.0.4

Had mouse movement problems, see: http://forums.virtualbox.org/viewtopic.php?t=10309&view=next&sid=fc6da7d3655a7ab39863b778db0e9b43

Following the suggestion I added the Ubuntu 8.04 /etc/X11/xorg.conf mouse section to /etc/X11/xorg.conf in 8.10 and the problem went away:

Section "InputDevice"
    Identifier  "Configured Mouse"
    Driver      "vboxmouse"
    Option      "CorePointer"
EndSection

Display Settings

Once the Guest Additions were installed the video resolution can be changed using the Xubuntu Applications→Settings→Display applet.


Networking

The two common guest networking configurations are NAT and Host Interface. I use the Host Interface configuration on all guests because of NAT performance problems (see following sidebar).

NAT Performance issue

Running VirtualBox 2.0.4, 2.1.0, 2.1.2 I had the following performance issue in WinXP SP3 guests: network upload performance from VirtualBox Windows guest to a Windows network share was very slow, the download speed (network share to guest local disk) was fine. The problem went away when I switched the VM networking from NAT to Host Interface. As of Virtual box 2.1.0 Host Interface configuration is as easy as NAT so this is a minor inconvenience.

Host Interface

All you need to do (as of VirtualBox 2.1.0) is select Attach to: Host Interface in the guest Network configuration dialog. Your DHCP server should be configured to assign an IP address to the guest, on my Linux server addresses are dynmically assigned, for example, my /etc/dhcp3/dhcpd.conf contains the following entry:

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.149;
}

NAT

The default NAT networking mode communicates with the external physical network via a built-in NAT router that also includes a DHCP server and a forwarding DNS server. You don’t need to set up DHCP or DNS entries for the VM on your external network. All this is covered in detail in the User Manual, but it fooled me to start with: I couldn’t figure out why the VM had not picked up and address from my DHCP server (dhclient reported the built-in DHCP server at 10.0.2.2 and nslookup reported the DNS server at 10.0.2.3).

Because the VM is sitting behind it’s NAT router on it’s private network it communicate with, but is effectively hidden from the external physical network. If you want to make networking services on your guest VM visible to the host or other machines on your network you’ll need to setup port forwarding using the VBoxManage command-line tool (this is explained in the User Manual), this is not an issue if you use Host Interface networking. Limitations of NAT are also covered in the User Manual.

NAT networking has some nice properties:

  • You don’t need to worry about assigning Intranet compatible IP addresses to your VMs because all external networking is via the host IP address.
  • If you copy your VM environment to another PC you don’t need to worry that the VM MACs are the same because they are behind the NAT router on their own private subnet.

NFS Client

Because networking uses NAT port forwarding addresses greater than 1024 you’ll need to specify the insecure option in your server’s /etc/exports entries (see the exports(5) man page). If you don’t do this you will get access denied when trying to mount NFS shares from and you’ll find illegal port messages in the servers syslog.


Audio

To enable audio:

  • Run VirtualBox Manager Machine→Settings menu command.
  • Select Audio.
  • Change the Host Audio Driver from Null Audio Driver to Windows DirectSound.

Miscellaneous Stuff

  • Because I use the seamless windows mode a lot I have a single auto-hiding panel at the top of the screen (so it doesn’t get in the way and is not confused with the Windows host Taskbar at the bottom of the screen). Right-click on the Xubuntu panel, select Customize Panel and then tick the Autohide checkbox.
  • I only have one Xubuntu workspace to avoid any confusion with the host workspace.
  • The AVG Antivirus (version 8) on the Windows host scans incoming mail to the Thunderbird mail client running on the Linux guest VMs, this was slow so I disabled incoming mail scanning in AVG. As a precaution I also excluded the .VirtualBox folder from AVG Resident Shield scanning which examines files as they are opened and may affect performance. I also disabled the scheduled file scan after experiencing a drop in performance when the host and guest scans were running.

Compatibility

I’ve used the following applications without any problems:

Mail
Thunderbird mail client using POP3.
Audio
Audacity, Rhythmbox, Transcribe.
CD/DVD-ROM
Brasero (burner).
Printing
CUPS remote printing over IPP.

Copying VMs

By default all VM machine and disk data is stored in the .VirtualBox directory located in your home directory (C:\Documents and Settings\<username>\ on Windows XP, C:\Users\<username>\ on Windows Vista). If .VirtualBox is not there check your HOME environment variable — if HOME has been set you’ll find there.

What I wanted to do was copy my entire VirtualBox VM environment from one PC to another. The technique is simple but it took me a while to figure out:

All I had to do was copy the .VirtualBox directory and all it’s contents from the source PC to the home directory on target PC. Be sure to close VirtualBox on both source and target PCs before copying.

I carried out this procedure twice, the first was from a Windows XP host to a Windows XP host, and a second time to Windows Vista host. I only had one minor glitch: the second target PC’s DVD drive was mapped to E:, the source’s was mapped to D:, this resulted in a PIIX3 cannot attach drive to the Secondary Master error when starting the VM. To fix this I dismounted the CD/DVD drive in the VM settings and it started fine, I then stopped the VM and mounted the correct E: drive.

Warning

This worked for me, but there are undoubtedly some gotchas lurking out there.

NTFS Permissions

If you get Access is denied errors when copying files from one PC to another (for example transferring VMs using an NTFS formatted USB drive) the problem is most likely due to a folder copied from a user’s home directory not having permissions on the target machine. This article explains how to take ownership of a folder.

If you can’t see the Security tab first need to untick the Use simple file sharing checkbox (Windows XP Home users will need to reboot into Windows Safe Mode):

  • Open Windows Explorer.
  • Tools→Folder Options→View then scroll to the bottom of the Advanced settings list and untick the Use simple file sharing checkbox.

Next change the owner of the folder to Administrators:

  1. Right-click the file or folder that you want to take ownership of, and then click Properties.
  2. Click the Security tab.
  3. Click Advanced, and then click the Owner tab.
  4. If you’re changing a folder tick the Replace owner on subcontainers and objects box.
  5. In the Name list, click Administrator, or click the Administrators group, and then click OK.

See also http://support.microsoft.com/kb/307874/.

Why such a simple thing like giving permissions has to be so complicated is beyond me.

What didn’t work

I had first tried copying the virtual disk file from the VDI directory from my source PC; creating a new VM on the target PC; and attaching the copied disk. There where two problems with this approach:

  1. My snapshots where not copied so the VM state was the state preceding my first snapshot.
  2. I had to manually configure the new VM.

The VBoxManage clonevdi command does not handle snapshots either and I didn’t want to merge my snapshots.

I’d love to see portable snapshots containing the VM configuration meta-data along with optional attached VDIs and snapshot that could then be easily imported on another host.


Snapshots

Snapshots are machine state check-points, a mechanism to restore your machine to a prior state. This is really handy, especially for developers. For example suppose you want to carry out testing that involves software installation, registry and disk deletions/additions, but you want to put your machine back to exactly where it was before you started — just take a snapshot before you start and revert the snapshot once you’ve finished. To revert the current state to the latest snapshot:

  1. Select the Snapshots tab in the VirtualBox window.
  2. Right-click on the Current State icon.
  3. Select the Revert to Current Snapshot menu item.

You can also to this from the VM window’s Machine→Close menu command: click the Power off the machine option and tick the Revert to the current snapshot box before pressing OK.


Shared Folders

The Guest Additions installs the mount.vboxsf command which allows you to mount directories on the host’s file system inside the Xubuntu VM.

In the Windows host

  1. Create a shared folder, say C:\shared.
  2. Share this folder (either using the VM window’s Devices→Shared Folders menu command or (if the VM is closed the Shared Folders link on the Details tab of the VirtualBox window).

In the Xubuntu guest
Apply the normal Linux mount procedures where the file system type is vboxsf and the device name is the shared folder name that you assigned (not the windows path). By default Windows files will be owned by root so you probably want to change the UID and/or GID’s so you can write to the share. This example creates a mount point in the user’s home directory and mounts a shared folder named host to the shared directory:

$ cd $HOME
$ mkdir shared
$ sudo mount -t vboxsf -o uid=srackham,gid=srackham host shared

The same mount can be performed automatically at startup by putting the following line in /etc/fstab:

host /home/srackham/shared vboxsf rw,uid=srackham,gid=srackham 0 0

Gotchas
A couple of things to be aware of (as of VirtualBox 2.02):

  • If you have a folder in the same directory as your mount folder and it has the same name as the VirtualBox shared folder name you will get a mounting failed with the error: Protocol error error (this has something to do with mount not VirtualBox, see http://www.virtualbox.org/ticket/2265).
  • Don’t use your Windows My Documents folder as a shared folder, this folder behaves differently to other folders and is not writable by non-root users — you will get permission denied errors when you try to write to it.
    • Setting the uid and gid mount options does not help.
    • Spaces in the folder name is not the problem.
    • You can write if you have root permissions.

      The problem seems to be related to the special properties imbued in the My Documents folder by Windows. Same applies to the Windows Shared Documents folder (C:\Documents and Settings\All Users\Documents). See also http://www.virtualbox.org/ticket/2264).

To get a list of the file system specific mount options run mount.vboxsf with no command-line arguments:

$ sudo mount.vboxsf

Usage: mount.vboxsf [OPTIONS] NAME MOUNTPOINT
Mount the VirtualBox shared folder NAME from the host system to MOUNTPOINT.

  -w                    mount the shared folder writably (the default)
  -r                    mount the shared folder read-only
  -n                    do not create an mtab entry
  -o OPTION[,OPTION...] use the mount options specified

Available mount options are:
     rw                 mount writably (the default)
     ro                 mount read only
     uid=UID            set the default file owner user id to UID
     gid=GID            set the default file owner group id to GID
     ttl=TTL            set the "time to live" to TID for the dentry
     dmode=MODE         override the mode of all directories to (octal) MODE
     fmode=MODE         override the mode of all regular files to (octal) MODE
     umask=UMASK        set the umask to (octal) UMASK
     dmask=UMASK        set the umask applied to directories only
     fmask=UMASK        set the umask applied to regular files only
     iocharset CHARSET  use the character set CHARSET for I/O operations
                        (default set is utf8)
     convertcp CHARSET  convert the folder name from CHARSET to utf8

Less common used options:
     noexec,exec,nodev,dev,nosuid,suid

VirtualBox XML configuration files

The VirtualBox.xml file (in the .VirtualBox directory) is the VirtualBox global configuration file and each VM has it’s own XML configuration file in the VM’s Machines directory. These files can be edited with a text editor — the entries are self explanatory.

The GUI Virtual Disk Manager can be used to add virtual disk files but not snapshot .vdi files, to register a snapshot manually edit the disk/snapshot registry in VirtualBox.xml configuration file (close VirtualBox first though).


VMware Workstation vs VirtualBox

This article is not a product comparison but as part of my evaluation I did the exactly the same installation of VMware 6.05 and used it in parallel with VirtualBox over a two day period. I ended up choosing VirtualBox, I just liked it better, it had that ineffable “Goldilocks” feel to it.

  • I liked VirtualBox’s separate windows for each VM compared to VMware’s MIDI approach. I found the VirtualBox (QT4 based) UI more pleasing than VMware’s.
  • The VirtualBox Guest Additions include a video driver that dynamically resizes the VM display resolution when you resize the guest.
  • I’m hooked on the seamless windows mode, it allows guest and host windows to co-exist side by side and nicely complements the bidirectional cut-and-paste functionality.
  • The dynamically expanding image disk image files are nice because you only use (and have to back up) the amount of disk space that has been consumed.

Not very scientific reasoning, but after you’ve been using and programming computers for decades you start to develop antennae for this sort of stuff. Admittedly I don’t create and tear down VMs on a daily basis so all of VMware’s bells and whistles didn’t count, plus I did have to jump through a few (in hindsight) minor hoops to get VirtualBox setup the way I wanted (in contrast to VMware which got everything configured out of the box). There’s an interesting PC World article by Randall Kennedy comparing the two products.


Conclusion

I’ve now been using VirtualBox for almost a week on a daily basis, the more I use the more I like it, it’s a beautifully crafted piece of software, has excellent documentation and a supportive community.

Advertisements

8 Responses to “Using VirtualBox 2.0 to host Xubuntu 8.04 on Windows XP”

  1. Ian Says:

    Good comments. FYI I just fixed a VBOX problem that might impact others. I got the “PIIX3 cannot attach drive to the Secondary Master” when trying to start a snapshot. I poked around in the config files and found that for some reason this section in the /home/user/.VirtualBox/machines/.xml file was wrong:

    It should have been:

    I poked the dev name and it came up just fine. I have no idea why the CDROM dev namegot hosed.

  2. James Sun Says:

    I was having problems installing a Shared Folder in my environment — Windows XP host running Ubuntu 8.10 guest OS. I found your blog and your instructions helped tremendously.

    I have one suggestion for your blog entry. In the section that deals with creating the shared folder using Devices -> Shared Folder, the Folder Name in your example needs to be “host” for the mount procedure you describe to work properly.

    Thanks!
    James

  3. Lock Says:

    Awesome article!

    Really fitted my needs, thanks so much!

  4. Lock Says:

    BTW, here’s a tip with a fix for a problem I found when changing screen resolution in a similar system setup:

    http://www.aviransplace.com/2008/07/01/change-screen-resolution-for-ubuntu-804-running-under-virtualbox/

  5. Robert Says:

    Hi Stuart…

    I have a question regarding VBox that has got me almost pulling out my hair.

    I would like to set up the VM’s so that limited users can access them. I have a Vista Ultimate x64 host and my thinking is that the VM’s need to be in the “C:\Users\Public\” folder since all users have access to that folder and its subfolders.

    So I created a test VM there and it appears in the Admin users list of VM’s when you start VBox but not in any other users list.

    I have created half a dozen VM’s so I know the process pretty well and have not even had problems with guest additions, but I cannot figure out how to set things up for all users.

    I really don’t like running as admin all the time, so that is why I would like to set up for access by limited users.

    Any ideas? I am at a loss here..

  6. Joris333 Says:

    Great post thanx a lot

    Greetz Joris

  7. sysadmin Says:

    that is what i am looking for

    thanks
    anuj

  8. totosugito Says:

    Very complete virtualbox tutorial. Thank for this sharing. good job

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: