You are here

VirtualBox on DICE

DICE desktops can run virtual machines. This is done with VirtualBox. (See also virtualisation.)

When running a VM on your desktop, ask computing support to enable CPU Virtualisation Extensions (VT-X). Unfortunately our desktops ship with this BIOS setting turned off by default, but it's crucial for good performance of host and guest that they're turned on.

Teaching Staff

Before using VirtualBox (or similar) in teaching, please contact computing support — they need to know in advance so that they can accommodate large VM images, and they can often suggest an efficient way of distributing your course materials.

Make and install a VM

Login to your DICE machine as normal, start up a terminal and run the VirtualBox command. Using the GUI wizard, create a new virtual host and virtual disk image. (The disk image should be in your computer's /disk/scratch rather than your home directory for performance reasons.) You can then install any Guest OS from an ISO image or physical CD (e.g. 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 in VirtualBox to do this.

Get install images for some popular Linux distros from:

USB Devices

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

Network configuration

The virtual machines use NAT networking by default. This should be fine for most purposes. The exception is if you want to run services on the Guest OS which are accessible from machines other than your desktop. In this case you can configure Port Forwarding on the guest. Bridge-mode is not normally supported on DICE machines; see below.

Port forwarding

After setting up a service on the Guest OS, you can 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:

$ 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; this 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. First, completely shut down the Guest OS and quit VirtualBox.

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 don't recommend 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, 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

If you've set up a remote console, you should be able to reach this via RDP, if you know the port:

 rdesktop localhost:

You can safely shut down the VM (equivalent to touching the soft power button on the PC) with:

 VBoxManage controlvm machinename acpipowerbutton
Last reviewed: 
08/09/2021

System Status

Home dirs (AFS)
Network
Mail
Other services
University services
Scheduled downtime

Choose a topic