Ubuntu Server 10.04 on VirtualBox OSE

Published: 29 March 2011

This gives a quick, no-frills overview of how to install Ubuntu Server Edition 10.04 LTS 32-bit as a guest operating system on VirtualBox 3.1.10_OSE. The installation was tested on Ubuntu Desktop Edition 10.04 LTS 32-bit, but should be similar on other versions of Ubuntu. It assumes that you have rudimentary knowledge of Linux - ideally Ubuntu.

If you want more information, Ubuntu’s VirtualBox Community Documentation is a good place to start.

There are already many guides on the web about installing VirtualBox OSE with Ubuntu, so this guide is going to be brief. The configuration outlined here will form a base on which I intend to build further articles in the near future.

Once you’ve downloaded the guest operating system, installation should only take a few minutes. You will then have a self-contained server environment in which you can experiment, without fear of damaging a live server, and without requiring additional hardware.

Install VirtualBox OSE

From the command line:

sudo apt-get install virtualbox-ose

Alternatively, install virtualbox-ose and its dependencies via Synaptic Package Manager.

Open VirtualBox OSE (either Applications > System Tools or Applications > Accessories).

Download Ubuntu Server Edition 10.04

Download the Ubuntu Server Edition 10.04 ISO image, and save it somewhere handy.

Alternatively, from the command line:

wget http://releases.ubuntu.com/lucid/ubuntu-10.04.2-server-i386.iso

Add Virtual Media

Before Ubuntu Server can be installed onto a new VirtualBox guest, the Ubuntu Server ISO image must be added to the virtual media list in VirtualBox:

  1. From the File menu, select Virtual Media Manager... (Ctrl+D)
  2. Select the CD/DVD Images tab
  3. Select Add (Ins)
  4. Browse for and select your recently downloaded Ubuntu Server ISO image.

Create a new machine

VirtualBox is now ready to go. Creating a basic Virtual Machine is easy, and for the purposes of this example, most of the options can remain at their default values:

  1. Click the New icon, or from the Machine menu, select New (Ctrl+N)
  2. Follow the wizard. Give your VM a name, and be sure to set the Operating System to Linux and the Version to Ubuntu.

Change the memory and disk size if you wish, but the default values will probably be okay for simple experimentation purposes.

Attach the CD/DVD drive to the ISO image

At this stage, the VM has a blank disk. The Ubuntu Server ISO image must be attached to its CD/DVD drive so that the VM can boot from it:

  1. Select the new VM from the left-hand panel.
  2. Click the Settings icon, or from the Machine menu, select Settings... (Ctrl+S)
  3. Select Storage from the left-hand panel.
  4. Select the empty CD/DVD drive from the Storage Tree.
  5. Select the Ubuntu Server ISO image from the CD/DVD list to the right.

Configure the Network Adaptor

For a good explanation of bridged and NAT virtual network configurations, see VMware Server Virtual Network Configurations

The default virtual network setting for new VMs in VirtualBox is to use network address translation (NAT). In this configuration, the network adaptor shares the IP address and MAC address of the host system. This works for simple networking tasks, but can limit connectivity. I prefer to set the network adaptor to bridged mode, where each VM communicates directly with the network interface card (NIC) on the host system, but appears as a separate client on the network.

If you have a DHCP server available, you can use the MAC address in the `Advanced` section of the network settings to assign a fixed address to the VM network adapter.

  1. Select the new VM from the left-hand panel.
  2. Click the Settings icon, or from the Machine menu, select Settings... (Ctrl+S)
  3. Select Network from the left-hand panel.
  4. In the tab for Adapter 1, set Attached to to Bridged Adapter.
  5. If you have multiple NICs in your host computer, select an appropriate adapter from the Name dropdown list.

Install Ubuntu Server

Everything should now be in place to install Ubuntu Server.

  1. Ensure that your new VM is selected, then click Start, or from the Machine menu, select Start.
  2. If you’ve not used VirtualBox before, be sure to read any information dialogues that appear — they might save you some frustration later.
  3. The Ubuntu Server installation should now begin.
  4. Select the desired language from the list.
  5. Select Install Ubuntu Server.
  6. Follow the wizard.

Here are screen shots showing the settings that I change from the default. Note that I don’t install any software from the Software selection page.

At the end of the installation, the ISO image should be detached from the CD/DVD drive prior to rebooting. See the next section for details.

Detach the ISO image from the CD/DVD drive

When this point is reached, it’s time to detatch the ISO image. See the next steps for details.

  1. From the Devices menu on your current VM window, select CD/DVD Devices, and un-check the Ubuntu Server ISO image.
  2. Select Continue on the Ubuntu Server installation screen.

The VM will reboot, and if all has gone well, after a few seconds, the login prompt will appear. Login using the authentication details created during the setup process.

Networking

If the VirtualBox guest OS has access to DHCP, then networking should already be configured. If not, a static IP address will have to be assigned. For a good explanation of Ubuntu Server network configuration, see the Static IP Address Assignment section of the Ubuntu Server Guide Network Configuration document.

Update Ubuntu

Unless you have good reason not to, always install the latest patches and security updates:

sudo apt-get update
sudo apt-get upgrade

Install SSH

If you want to access your server from a terminal, or copy files to or from the server using scp or rsync, then installing SSH will make this simpler. Accessing the server from a terminal also makes it easier to copy and paste text to or from your server.

sudo apt-get install shh

The following steps are to be carried out on the computer from which you would like to have remote access to the VM — probably the same computer that is running VirtualBox OSE:

Open a terminal. If you have not already generated a public/private key-pair:

ssh-keygen -t rsa -b 4096

Accept the default location and filename for the key. Entering a passphrase is optional. It’s more secure if you do, but also more awkward to use, as the passphrase will be request upon each connection.

The choice depends on your situation, and there’s plenty of information available elsewhere to help you decide. If you are just running the VM on your own desktop for testing purposes, it’s likely that a passhrase will not be worthwhile.

Copy the public key the to VM (replace username and IP address as appropriate):

ssh-copy-id mike@192.168.1.10

Check that you can log in to the VM via SSH (replace username and IP address as appropriate):

ssh mike@192.168.1.10

And that’s it for now.