Running Ubuntu in VirtualBox on OS X 10.5/Leopard

I am now consulting for myself and one of the things that I need to have is a test Linux box to play with. I am also lazy and do not want to maintain yet another computer (with it's associated costs) so I immediately turned to my good friend, virtualization. This also came around because my Leopard MySQL, PHP and Apache configuration is not working very well these days.

I had heard VirtualBox (1.6.2) had recently acquired Mac OS X support so I decided to give the platform a spin on my Intel-based iMac and report the results.

Installation

Easy as download, mount the disk image and run the installer.

Configuration

I wanted to create a new Ubuntu installation so I grabbed the latest Ubuntu server ISO. While that was downloading I started to configure the new VM image. The wizard walked me through the steps fairly painlessly but I do have to admit to being a bit confused by some of the defaults selected. I had to boost the amount of RAM allocated to the image to 512MB. I had to ensure I enabled PAE/NX (for Ubuntu to even start) and I also had to use NAT (Network Address Translation) to for network connectivity as the other options do not work with OS X yet, or at least that is what the documentation says. Once I had my image configured I set the guest VM's CD/DVD drive to point to the ISO image I downloaded, set the drive boot order to CD/DVD first and Blamo! I was installing Ubuntu.

Quick Caveats

The use of NAT for the networking makes for some headaches if you want to actually talk to the Guest VM from the host VM, as I wanted to do - this is my LAMP test box after all, and it requires the use of port forwarding on the Guest VM.
The documentation is a little light on how this is done on OS X so for my future referral the commands I ran are as follows:

  1. Shut down the guest VM
  2. Open the Terminal application and change directory to /Applications/VirtualBox.app/Contents/MacOS
  3. At the command line run the following commands to enable port forwarding, using the VBoxManage command. I am forwarding SSH, MySQL's ports and Apache. In essence you setup a port on the Host that will forward into the guest VM. The name guesthttp that I am using is meaningless; I used guesthttp for HTTP (Guest port 80 to Host port 8080), guestssh for SSH (Guest port 22 to Host port 2222) and guestsql for MySQL's port (Guest port 3306 to Host 3306). It is not advisable to forward to ports below 1024 if you are not running as root. My Guest VM's name is "Linux Test Box" - original, I know. Repeat for each protocol you wish to access on the Guest VM.

    evan@foo /Applications/VirtualBox.app/Contents/MacOS
    $VBoxManage setextradata "Linux Test Box" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
    VirtualBox Command Line Management Interface Version 1.6.2
    (C) 2005-2008 Sun Microsystems, Inc.
    All rights reserved.

    evan@foo /Applications/VirtualBox.app/Contents/MacOS
    $VBoxManage setextradata "Linux Test Box" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
    VirtualBox Command Line Management Interface Version 1.6.2
    (C) 2005-2008 Sun Microsystems, Inc.
    All rights reserved.

    evan@foo /Applications/VirtualBox.app/Contents/MacOS
    $VBoxManage setextradata "Linux Test Box" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8080
    VirtualBox Command Line Management Interface Version 1.6.2
    (C) 2005-2008 Sun Microsystems, Inc.
    All rights reserved.

After I made these changes and restarted the guest VM I was able to setup a Drupal 6 install with no problems. It is visible at http://localhost:8080 and is running entirely on an Ubuntu server install. I get the bonus of running a true LAMP install that can be instantly restored to a previous running state as well as the great features of Ubuntu! All for free.

Comments

I'm encourage to see that you could get VB running on the Mac. I suppose you could always try running Ubuntu in a VirtualBox VM that's running in a Windows VM provided by Fusion on top of OSX. Now if only there were a way to run OSX on top of Ubuntu. But even attempting that sort of thing could case a fracture in time-space.

I've found VB pretty stable. I mainly use it when I have to run IE from my Ubuntu laptop, and have also used it in the other direction to run Debian on Windows. Being able to save the complete OS state is great for testing.

Agreed, either space-time would collapse or the harddrive would implode from too many hypervisors wanting control!
VirutalBox is pretty good. The ease of use on OS X is a little lacking but it seems stable so far. It definitely does not have the integration or polish of a Parallels or Fusion product but then again I am getting what I paid for, it's good enough for testing but definitely not production worthy.

But after a quick reboot the VM is working perfectly ... Don't know what caused that one...

All content created and copyrighted by justwerks software 2001-2008 unless otherwise noted.