Creating a minimal Ubuntu 10.4 VirtualBox Virtual Machine
- Download the latest Ubuntu Minimal ISO.
- Start up VirtualBox and create a new Ubuntu Virtual Machine. Give it say 768MB RAM and create a new 8GM dynamically expanding disk space (you cannot increase this maximum disk size so make sure you pick something that will accommodate the largest possible size your VM will take).
- Go to the Settings dialog in VirtualBox and select to mount the the mini Ubuntu ISO you downloaded. Go through all the other settings as well and make sure sensible configurations are enabled (you can always change these later).
- Start the VM, it should boot from the ISO and take you to a 'boot:' prompt. Just hit enter without typing anything.
- Select Command-line install from the next menu and follow the prompts selecting language, keyboard, etc. All defaults work fine in most cases.
- Set a proxy when prompted if you're behind a proxy server. The installer will then do it's thing, connect to the internet, download packages and install the core of the OS.
- After the install, create a user and password when prompted, say ubuntu/ubuntu.
- Once all that is over, the VM will restart and you'll be taken to a login prompt.
- Login with the user you created, then install the following (first is a minimal gnome setup, second is needed for installing Guest Additions later):
- sudo apt-get install xorg gnome-core gdm gnome-applets gnome-system-tools gnome-utils ubuntu-artwork compiz-gnome file-roller
- sudo apt-get install build-essential linux-headers-generic
- Restart the VM and login via the new interface.
- Install the VirtualBox Guest Additions by clicking on Devices/Install Guest Additions in the VirtualBox menu bar at the top of the VM window. This will just mount a CD ISO under /media/VBOXADDITIONS_x_x_x. Navigate to that directory in a terminal and run 'sudo ./VBoxLinuxAdditions-x86.run'.
- This gives you a minimal install with not much besides the Gnome environment (you could use an alternative to Gnome such as xfce4 which is supposed to be lighter, but I find Gnome is just a lot more standard and will give you less headaches in the long term). Before installing anything else you may want to just shut down the VM and make a zip of the .vdi disk file to store in a safe place. You can use this as a base image that you can import into a new VM and configure differently. Whenever you do this though (create a new VirtualBox machine configuration and attach it to a copy of this .vdi), login to Ubuntu and delete the file /etc/udev/rules.d/70-persistent-net.rules (otherwise the virtual network card won't be detected, the new VM config creates a new random virtual MAC, Ubuntu caches the old MAC from the original VM you used and gets confused, deleting the file and restarting the VM forces Ubuntu to reconfigure the eth0 interface).
If you want to install PHP/Apache/Postgresql, do the following:
- sudo apt-get install postgresql postgresql-client postgresql-contrib
- sudo apt-get install php5 php5-gd php5-curl php5-pgsql
- sudo apt-get install apache2-mpm-prefork libapache2-mod-php5
To install a web-browser, just do:
- sudo apt-get install firefox
You may also want to create a shared folder between the host OS and the guest OS. In the VirtualBox application on the host OS, click settings and add a new shared folder giving it a name, say 'share'. Then, in the Ubuntu VM, type 'sudo vi /etc/rc.local' and add the line 'mount -t vboxsf share /tmp'. This will link the host folder named 'share' with the Ubuntu /tmp folder at startup. Note though that if you're thinking of creating a shared folder which is also a Dropbox folder, it won't work. The Ubuntu guest Dropbox client won't be able to properly detect and index the files that are being shared by the host.
Install whatever other tools you may need, and remember you can always shut-down and make a zip of the .vdi to take a backup copy that you can come back to later (you can also use the VirtualBox snapshot feature, but make sure you back these up to redundant storage).