Using virtualbox

General Notes

For performance reasons if you are going to make heavy use of a virtual machine on your desktop you should ask support to make sure that CPU Virtualisation Extensions (VT-X) are enabled in your machine's BIOS, if available (all 745s and newer). These are crucial for best performance of host and guest; their absence is implicated in some problems experienced on 745s. What's worse, they're off by default on all our standard desktop machines.

Guest OS Configuration

Login to your DICE machine as normal and start up a terminal and run the VirtualBox command. Follow the GUI Wizard to create a new virtual host and virtual disk image on the physical disk (ideally in /disk/scratch rather than your home directory for obvious performance reasons). You can then install any Guest OS from an ISO image or physical CD (eg. Fedora10 or !WindowsXP). Note that you have to first mount the image file or CD to make it available to your virtual machine - use the CD menu within the !VirtualBox GUI to do this.

Alternatively you can use one of the pre-built base images (such as Fedora10) and a local differencing disk, see [[#Disk_Images][disk images]] comments, below.

Network Configuration

The default virtual machine configuration uses NAT which should be fine for almost anything except if you want to run services on the Guest OS and have them accessable from other machines on the Informatics or University networks or from the internet in general. In this case we recommend that you use Port Forwarding. Bridged Adapter is also a possibility but you should try port forwarding first. Both are described below.

For DICE guests see Bridged_Adapter comments, below.

Port Forwarding

You can set up a service on the Guest OS and then set up the host to proxy incoming connections to that service using the command line tool VBoxManage. You will need to know which ports on the Guest OS the service uses and decide which ports to use on the physical host (often but not always you will want to use the same ports on the Guest OS and on the host). You can use any ports on the host greater than 1024 which are not already in use by a service. For example, to set up an incoming NAT connection to an http server on the Guest OS would require the following:
$ VBoxManage modifyvm "myfc10host" --natpf1 "guesthttp,tcp,,8080,,80"
Here "myfc10host" is the name of the virtual machine as displayed in the VirtualBox interface. The number one in the argument --natfp1 refers to the first (and default) network card. The name guesthttp is an arbitrary tag chosen to identify this particular port forwarding configuration and can be anything you like. The Protocol can be either tcp or udp (these are case insensitive). With the configuration in place, all TCP connections to port 8080 on the physical host will now be forwarded to port 80 on the Guest OS. You might also have to check that your Guest OS does not apply any network filtering by default that would prevent services being run in this way. To remove a port forwarding configuration, use the following:
$ VBoxManage modifyvm "myfc10host" --natpf1 delete "guesthttp"
and to check the current configuration use the VBoxManage showvminfo command.

Note that it is not possible to configure port forwarding while the Guest OS is running, completely shut down the Guest OS and exit the =VirtualBox= application first.

For more information on port forwarding please see the VirtualBox Manual page on the topic. If you require the service to be visible outside of inf.ed.ac.uk then the physical host will need filter rules added exactly as if the service was running natively on that host but based on the host port not the guest port (so =8080= for the example above). For the example above this would mean adding the following lines to the physical host machines LCFG profile (you will need to contact support to do this).

    #include <dice/options/ipfilter.h>
    !ipfilter.export mADD(8080)
For complex port-forwarding arrangements you may be better asking support to create a self-managed profile: see below.

Bridged Adapter

Port forwarding should work in most cases, however to install a DICE Guest OS with PXE/DHCP and to use ports below 1024 you need to enable the Bridged networking option. This can be done in the !VirtualBox GUI by selecting the "Network" configuration option for the virtual machine and choosing "Bridged Adapter" in place of "NAT".

It appears that for !VirtualBox 4.0 the Intel emulated network cards do not support PXE (without the PUEL-licensed "Oracle Extension Pack"), so to PXE boot you'll need to pick a non-Intel card - the =AMD PCnet-PCI II and =III= both seem to work. Presumably you could switch back to an Intel once installed, if desired for performance reasons.

Snapshots

Snapshots are unlikely to work (or give desirable performance or reliability) if stored in your home directory. To make sure they are created on local disk only, you can alter their default location: In each Virtual Machine's "settings" dialog, you are offered a choice of location

Useful Commands

Start a 'headless' VM:
 VBoxHeadless -s machinename -p port
(you may then connect to the VM console using RDP:
 rdesktop localhost:port
Though note that as of !VirtualBox 4.0 the VRDP server only appears to work where the PUEL-Licensed Oracle Extension Pack has been installed.

Safely shut down a VM (equivalent to touching the soft power button on the PC):

 VBoxManage controlvm machinename acpipowerbutton

Installation Notes

This resembles a normal "PIE" installation, and can be performed using PXE. Only a few snags:

Disk Images

There are some pre-built disk images that can be used as a starting point for a Guest rather than installing from scratch. Using a pre-built disk image is also useful if you don't have sufficient space to store the entire base image which can be many gigabytes in size. Although the pre-built disk images are immutable, the local differencing disk image can be made writeable (changes are written to a local differencing disk file which is a fraction the size in general of the base disk image). Currently the following pre-built disk images are available: In order to use one of the images above in a virtual machine first update your local configuration to set the base disk as immutable (it won't be writeable anyway but !VirtualBox needs to be told this explicitly). Do this using

  VBoxManage modifyhd /afs/inf.ed.ac.uk/group/rat-unit/images/Fedora10Base.vdi --type immutable

where the =.vdi= file is the one corresponding to the base disk image you want to use. Then start !VirtualBox and create a new machine following the Wizard as normal but don't create a new virtual disk, instead browse to select the base image file (name as above) from the directory =/afs/inf.ed.ac.uk/group/rat-unit/images=. Then configure and start up your virtual machine as normal. Once the Guest has booted up, choose the =Machine= menu option on the Guest window and then choose =ACPI Shutdown= to cleanly shutdown the Guest. A new differencing disk image should have been created in =~/.Virtualbox/Machines/*GUESTNAME*/Snapshots/{*ID*}.vdi=. Now using VBoxManage configure that image to preserve changes by doing

  VBoxManage ~/.VirtualBox/Machines/Fedora10/Snapshots/\{c1fba93f-f2c4-4176-a096-e8169d16207f\}.vdi --autoreset off.

Now you should be able to use your virtual machine as normal, any changes to the disk image will be preserved in this local file.

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh