You are here

VirtualBox on DICE

Printer-friendly versionPrinter-friendly version

General notes

DICE desktops can run virtual machines using VirtualBox (though see our virtualisation page for more general information on what's available within Informatics

For performance reasons, if you are going to make heavy use of a virtual machine on your desktop you should ask computing support to make sure that CPU Virtualisation Extensions (VT-X) are enabled in your machine's BIOS. Unfortunately our desktops ship with this turned off by default, but it's crucial for good performance of host and guest that they're turned on.

Teaching Staff

If you are considering the use of VirtualBox or other any similar virtualisation technology in teaching, you must contact us — computing support need to know in advance if we have to accommodate large VM images, and can often find a significantly more efficient way of distributing your course materials.

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. Fedora or Windows). 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 comments, below.

USB Devices

DICE machines are not typically configured to permit virtual guests to access locally-connected USB devices. However, this can be arranged on request.

Network configuration

The default virtual machine configuration uses NAT which should be fine for most purposes, except if you want to run services on the Guest OS accessible from machines other than your desktop. In this case you may configure Port Forwarding on the guest. Bridge-mode is not normally supported on DICE machines; see 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 "myFedorahost" --natpf1 "guesthttp,tcp,,8080,,80"

Here "myFedorahost" 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 "myFedorahost" --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 theVirtualBox Manual page on the topic.

If you need the service to be visible outside of inf.ed.ac.uk then the Informatics firewall will need to allow traffic to the host port (8080 in the example above) on the physical host. Using the network from outwith the School describes how to ask for the firewall to be configured for your needs.

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". Bridging will not normally be permitted on DICE hosts, and won't work without the involvement of computing support; we'd recommend avoiding it.

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

  • Right-click on the guest you wish to configure and choose "settings"
  • In the "general" section click on the "advanced" tab.
  • Snapshot location can be changed to =/disk/scratch/= (for example).

Useful commands

Start a 'headless' VM:

 VBoxHeadless -s machinename -p port

(note that until VirtualBox 5.0 you cannot use the GUI to manage this guest until it's shut down again, but you may still connect to the VM console using RDP:

 rdesktop localhost:port

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

 VBoxManage controlvm machinename acpipowerbutton

Disk Images

There are some pre-built (and outdated, but possibly of use) disk images that can be used as a starting point for a Guest rather than installing from scratch. Currently the following pre-built disk images are available:

  • Fedora12 (username = f12user, password = f12userpw, root password = f12rootpw), filename = Fedora12Base.vdi
  • Fedora10 (username = f10user, password = f10userpw, root password = f10rootpw), filename = Fedora10Base.vdi
  • Ubuntu 9.04 (username = vboxuser, password = TestUser, root password = n/a), filename = UbuntuJaunty.vdi
  • Debian 5.0.1 (username = vboxguest, password = vboxLenny, root password = vboxLennyRoot), filename = DebianLenny.vdi

In order to use one of the images 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).

Using Differencing Images

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).

Before using one of the images above, you can set it to be immutable for your configuration of VirtualBox with:

  VBoxManage modifyhd /afs/inf.ed.ac.uk/group/rat-unit/images/image.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.

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.

Using VBoxManage you can configure that image to preserve changes with:

  VBoxManage '~/.VirtualBox/Machines/*GuestName*/Snapshots/{*ID*}.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.

Last reviewed: 
24/03/2016

System Status

Home dirs (AFS)
Network
Mail
Other services
Scheduled downtime

Choose a topic