Install Ubuntu server in a virtual machine
These instructions use VirtualBox as an example. Instructions for other virtual machines are likely to be similar.
There is a version of the Ubuntu server that is optimized for usage within a virtual machine. It is provided on the Ubuntu Server edition LiveCD. The LiveCD image (.iso) found here can be downloaded onto your hard drive. It can then be installed directly into your virtual machine from the hard drive. Alternatively, you can also burn the .iso image onto a CD and install Ubuntu Server into the virtual machine from the CD. Both methods work identically during the Ubuntu Server installation process.
VirtualBox supports both 32 and 64-bit guest OSs. See this list for known supported operating systems. However, if your host OS is 32-bit you cannot run 64-bit guest OSs. Other virtual machines may have similar limitations, so in general a 32-bit Ubuntu OS is safest.
Note that the "minimal virtual machine" install of Ubuntu Server 10.04 doesn't recognize the SATA disk controller which VirtualBox 3.2.8 uses by default. If you find you can't boot your new installation and get dropped to an initramfs prompt on first boot, stop the VM and reconfigure it to use a SCSI disk controller instead as described here.
*Start the virtual machine you created in the previous step.
Virtualbox -> Ubuntu Virtual Server (highlighted) -> Start
The "First Run Wizard" will prompt for the location of the installation disk -> Next ->
CD/DVD-ROM device (ticked) ->
- select the CD-ROM drive (if you burned the LiveCD (.iso) image onto a physical CD), or
- browse for the folder where you stored the (.iso) image onto your hard drive, if you did not burn it to a physical CD
-> Next ->
* Install Ubuntu server virtual machine edition:
The First Run Wizard will automatically start the LiveCD from the location you indicated, and you will see the Ubuntu Server LiveCD screen.
Choose language: English ->
Important: note this step carefully! Select the minimal virtual machine installation mode:
Click the F4 (modes) key -> Install a minimal virtual machine ->
- Install Ubuntu Server
Select your installation options. When asked about partitioning, use the guided partitioning method and use the entire disk. This uses the entire virtual machine disk (which is 8 GB or whatever size you created when creating the virtual machine), not the entire physical hard drive disk.
Task selection. A menu will appear to select options for additional packages to be installed along with the server. Make sure these packages are starred use the space button to select them and the arrow keys to go up or down the list) before completing the installation.
(Optional) You will be prompted to enter an MySQL root user password during the LAMP server package installation. This password becomes important later on (in some instances). Record your chosen MySQL password in a safe location. Do not use your primary user password as the MySQL password; it ought to be unique.
* Finish the remainder of the Ubuntu server installation. At the conclusion the Ubuntu system will automatically reboot within the virtual machine. When it restarts, you will then have a fully function Ubuntu Server within the virtual machine. Immediately update the operating system:
sudo apt-get update sudo apt-get upgrade
Installing missing kernel modules
The kernel package installed by the "minimal virtual machine" option only contains a small number of modules. It's possible you may need one of the "missing" modules to get extra hardware supported. (In my case I wanted to access my MacBook Pro's internal USB Bluetooth device from Ubuntu.)
You *don't* have to build the modules yourself, you can simply install the associated "linux-image-extra-virtual" package and all the missing modules will be installed (at the cost of some extra disk space). (The description of the package currently implies a kernel image is also installed but that's not the case.)