Thursday, July 1, 2010

Ubuntu JeOS Virtual Appliances in VirtualBox

I find myself creating more and more test environments in VirtualBox on Ubuntu JeOS for alot of the research projects I do. Some of these test environments span multiple machines. I starting thinking it would be nice to have a resuable template for these purposes. The other thing that I wanted to do was simulate a network where I could assign static IPs to the Virtual Machines because some of the software that I test gets really fussy if the IP keeps changing.

Oracle VM VirtualBox

VirtualBox can be installed on Ubuntu Desktop by doing the following:
  1. Modify /etc/apt/sources.list and add the following to the file:

    deb http://download.virtualbox.org/virtualbox/debian lucid non-free
  2. Download and register the Oracle public key by running the following:

    wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc \

    -O- | sudo apt-key add -

  3. Install VirtualBox 3.2 by running the following from a command prompt:

    sudo apt-get update

    sudo apt-get install virtualbox-3.2

For more information on installing VirtualBox on Ubuntu: http://www.virtualbox.org/wiki/Linux_Downloads

Ubuntu JeOS Virtual Machine

Ubuntu JeOS is a lightweight easy to configure environment that makes an excellent choice for research and testing.

To create an Ubuntu JeOS image download the 32-bit Ubuntu Server Edition CD from here: http://www.ubuntu.com/server

Create a new Ubuntu JeOS Virtual Machine by doing the following:

  1. Launch Oracle VM VirtualBox (Applications > System Tools > Oracle VM VirtualBox)
  2. Click New to create a new Virtual Machine
  3. Name the machine: Ubuntu JeOS 10.04. The Operating System and Version should change to Linux and Ubuntu.
  4. Leave the memory at the default of 512 MB
  5. Create a new virtual disk with the default settings
  6. Make sure the newly created Ubuntu JeOS 10.04 VM is highlighted and click Settings
  7. Go to System > Processor and check Enable PAE/NX.
  8. Go to Storage and highlight SATA Controller and click - to remove it. I had a problem with the SATA controller that prevented the VM from booting properly.
  9. Highlight the IDE Controller and then click the Add Hard Disk icon (looks like a + sign on hard disk platters).
  10. Highlight the newly added Hard Disk and choose Ubuntu JeOS 10.04.vdi from the Hard Disk drop down.
  11. Highlight the CD ROM and click the button to open the Virtual Media Manger (looks like a green arrow on a folder).
  12. Click the Add button and browse for the Ubuntu Server .ISO on the system.
  13. With the Ubuntu Server .ISO highlighted, click Select to choose the image for use with this Virtual Machine.
  14. Go to Network and change set ''Attached to:'' to NAT.
  15. While still in the Network settings, click Adapter 2 and Enable Network Adapter and set ''Attached to:'' to Host-only Adapter.
  16. Click OK to close the VM settings.

Installing Ubuntu JeOS

Follow these steps to install Ubuntu JeOS in Oracle VM VirtualBox:

  1. Power on the Virtual Machine by clicking Start
  2. Press Enter on the Language screen
  3. Press F4 to bring up the Modes Menu
  4. Choose Install a minimal virtual machine
  5. With Install Ubuntu Server highlighted, press Enter
  6. Press Enter twice for Language and Country
  7. Press Enter 3 times on the Keyboard detection screens
  8. Make sure eth0 is hightlighted as the Primary network interface
  9. Leave the default of ubuntu for the Host name
  10. Ensure that the installer selected the correct time zone and continue on.
  11. On the Partition Disks screen keep the default: Guided - use entire disk
  12. On the Write changes to disk screen Tab to Yes and press Enter
  13. On the Set up users and passwords screen, enter Test Admin as the Full name for the new user
  14. Keep the suggested user name: test
  15. Set the password to: test
  16. Select No for encrypting the home directory.
  17. When prompted for server selection choose Open SSH Server.
  18. Once installation is completed highlight the new Virtual Machine and click Start.
  19. If the Virtual Machine flashes a window and quits check the PAE/NX setting on the Virtual Machine. See Section enu:PAE/NX

Configuring Ubuntu JeOS

This section cover install the VirtualBox Guest Tools as well as Exporting the VM as a Virtual Appliance.

  1. Log into the new Virtual Machine as user name/password: test/test.
  2. Install Vi IMproved by running the following:

    sudo apt-get install vim
  3. Configure the first static IP address by modifying /etc/network/interfaces as follows:

    sudo vim /etc/network/interfaces

    # Testing network interface
    auto eth1
    iface eth1 inet static
            address 192.168.56.2
            netmask 255.255.255.0
            network 192.168.56.0
            broadcast 192.168.56.255
  4. Save the file by type :wq
  5. Restart networking by running the following

    sudo /etc/init.d/networking restart
  6. From the host machine SSH to the Guest machine by running: ssh test@192.168.56.2
  7. In order to install the VirtualBox Guest Tools the Linux build tools and kernel headers will have to be installed to support compiling the VirtualBox kernel modules. Install the build tools and kernel headers by running the following from the Virtual Machine:

    sudo apt-get update

    sudo apt-get install build-essential linux-headers-`uname -r`

  8. From the Virtual Machines window go to Devices > Install Guest Additions
  9. Back at the machines command prompt run the following to mount the CD ROM and install the Tools:

    sudo mkdir /media/cdrom

    sudo mount /dev/cdrom /media/cdrom/

    cd /media/cdrom

    sudo ./VBoxLinuxAdditions-x86.run

  10. Remove the network card settings so this machine can act as a template for creating other machines by running the following:

    sudo rm /etc/udev/rules.d/70-persistent-net.rules
  11. Shut the machine by running: sudo halt
  12. Back in Oracle VM VirtualBox choose File > Export Appliance and select Ubuntu JeOS 10.04 from the list.
  13. Browse to a location on the system to store the Appliance.
That's it! Now this VM template can serve as the base for all of the other machines to be used for testing.

Provisioning Virtual Machines

To Provision a new Virtual Machine for use with the various configurations do the following:

  1. From Oracle VM VirtualBox go to File > Import Appliance
  2. Browse to where the Appliance was exported and select Ubuntu JeOS 10.04.ovf
  3. On the Appliance Import Settings screen change the Name field to a new unique name, for example: Test VM 1
  4. Clicking Finish will start the import process. Once completed a new Virtual Machine should be in the list called Test VM 1
  5. Highlight the new Virtual Machine and click Start
  6. Logon to the machine with the username/password of test/test.
  7. One the machine is booted, configure a unique static IP address by modifying /etc/network/interfaces as follows:

    sudo vim /etc/network/interfaces

    # Testing network interface
    auto eth1
    iface eth1 inet static
            address 192.168.56.x
  8. Change the hostname of the VM as follows:

    sudo vim /etc/hostname

    ts-vm1
  9. Modify /etc/hosts and change the entry for 127.0.1.1 ubuntu.example.com as follows:

    127.0.1.1 ts-vm1.example.com ts-vm1
  10. Restart networking in Ubuntu to apply the changes:

    sudo /etc/init.d/networking restart

    sudo /etc/init.d/hostname start
  11. It should now be possible to attach to the new VM using the IP address set above from the host as follows:

    ssh test@192.168.56.x

No comments:

Post a Comment