Saturday, October 15, 2011

Virtualization with VirtualBox

VirtualBox is a free virtualization package available from Oracle. The makers of VirtualBox were originally a company purchased by Sun Microsystems. Some attractive features of this package include:
  • Open source
  • Runs on Macintosh, Linux and Windows
  • Supports OVF

Installation on Host Machine

Download the latest VirtualBox package for your host system (4.1.8 as of this post). Run the installer.
Note that when you're installing VirtualBox on your local machine, you can install it as yourself. However, if you're installing it on shared servers, be sure to use a machine account rather than a personal account.
Be sure to check the Default Machine Folder in Preferences to ensure you're using a path without spaces. On Unix systems, I use $HOME/vm for personal installations and /opt/vm for shared (server) installations.

Installation of Guest Operating System

Once VirtualBox is installed, it's time to create guest operating system. A guest is a virtual machine that runs as an application on your host. It effectively gives you a computer within a computer that you can run side-by-side with your host machine.

Ubuntu 64-bit LTS Desktop

To install Ubuntu, download 64-bit Desktop ISO. I like to create a guest that I call stemcell that I snapshot in well-known states so I can easily test things.
2048 MB RAM
500 GB dynamic hard drive (vdi)
128 MB video ram


It's a good idea to install Dropbox so you can easily copy sample configuration files.
$ sudo apt-get install nautilus-dropbox
$ dropbox start -i # enter your dropbox details
I keep common Ubuntu configuration files in Dropbox/config/ubuntu. For example


Update /etc/apt/sources.list to contain the following:

Next, update your packages and install VirtualBox guest additions.
sudo apt-get update
sudo apt-get upgrade
Now power off your virtual machine and take a snapshot.


Cloning is an extremely useful way to manage machine images that you use over and over. We manage our clones as follows:
  1. Create a base installation of our target OS
  2. Install a package or extension
  3. Take a snapshot
This process is repeated until a full stack machine is created (e.g. WKS server). The full heredity of the machine is now available for cloning.
There is a step that is not well-documented. The clone process does not remove the entries in /etc/udev/rules.d/70-persistent-net.rules. When you first launch your cloned guest, you will get an error with your eth0 interface. Remove all entries in this file and reboot and the interface will reactivate.

No comments: