Wiki Index All Recent Edit Bottom

Virtual Box

1.   Introduction
2.   Installing Virtual Box on Ubuntu
2.1   Post install configuration
2.2   Ubuntu 9.04 are earlier
2.3   Reconfigure after Kernel update
3.   VirtualBox Optimisation
4.   VirtualBox GUI on headless Server
5.   VirtualBox Web Console
5.1   phpVirtualBox
5.2   VboxWeb
6.   VirtualBox Remote Client Connection
6.1   Using rdesktop-vrdp
6.2   Using rdesktop
6.3   vrdp authentication
7.   Auto Start Virtual Box Guests
7.1   Installing VBoxTool
7.2   Configuring VBoxTool
8.   Migrating VMWare to Virtual Box

Introduction

I used to use VMWare at home but migrated to VirtualBox when it hit version 2.1. Like some of my other wiki pages this is not all new information, just an aggregation of information I found online plus some bits of my own.

Installing Virtual Box on Ubuntu

There are two versions of Virtual Box, the Open Source Edition (OSE) and the Closed Source Edition. I am interested in the Closed Source Edition because I require most of the features it provides, not least USB 2.0 support.

I'm not going to repeat the clear installation instruction that are already available on the VirtualBox website.

Post install configuration

Add yourself to the vboxusers group

 sudo adduser YOURUSERNAME vboxusers

Ubuntu 9.04 are earlier

This step is only required for older Ubuntu versions.

Find the devgid for 'vboxusers'

 grep vboxusers /etc/group | cut -f3 -d':'

It will return something like...

 128

Add this line to the bottom of '/etc/fstab', replacing the devgid number with the one from your system.

 none /proc/bus/usb usbfs devgid=128,devmode=664 0 0

Reboot and you should now have Virtual Box installed with USB support.

Reconfigure after Kernel update

REMEMBER Run the following to reconfigure VirtualBox kernel modules after a kernel update.

 sudo /etc/init.d/vboxdrv setup

References

VirtualBox Optimisation

I currently researching how best to optimise my VirtualBox hosts and guests, more details will follow. The links below are what I've found useful thus far.

References

VirtualBox GUI on headless Server

To enable X11 forwarding on the server you need at least the xauth program. Install 'xbase-clients' on the server so that you can connect to the server with SSH.

 aptitude install xbase-clients

To run the remote VirtualBox GUI on your local Linux workstation do the following.

 ssh -X user@server.example.com VirtualBox

You should now see the VirtualBox GUI and can remotely administer your virtual machines.

VirtualBox Web Console

phpVirtualBox

Simply put phpVirtualBox is brilliant! This is what you want to use.

VboxWeb

NOTE! VboxWeb is a proof of concept from the Virtualox developers and no longer maintained or developed.

The VirtualBox Web Console (VBoxWeb) is an open source project implementing an AJAX version of the popular VirtualBox user interface. As a modern web interface, it allows you to access and control remote VirtualBox instances.

NOTE! At the time of writing VirtualBox Console is shaping up nicely but it is not complete yet or suitable for production use.

You'll require VirtualBox 3.0.6 (or better) already installed on your computer. I've tested this on Ubuntu Jaunty 9.04.

 sudo -s -H
 aptitude -y install python-simplejson   
 mkdir -p /opt/vboxweb
 cd /opt/vboxweb
 svn checkout http://vboxweb.googlecode.com/svn/trunk/ .

Create a user account for VirtualBox Console.

 python VBoxWebSrv.py adduser myuser mypassword

You can find how to use VBoxWebServ.py using the following command.

 python VBoxWebSrv.py help

Try out starting up VBox Web Console the first time.

 python VBoxWebSrv.py

You should see something like this.

 VirtualBox Version: 3.0.8, Platform: linux2
 Using config file: /opt/vboxweb-read-only/VBoxWeb.conf
 Downloading Sun RDP Web Control ...
 Status: 0%
 Status: 11%
 Status: 22%
 Status: 33%
 Status: 45%
 Status: 56%
 Status: 67%
 Status: 78%
 Status: 90%
 Status: 100%
 Download complete. Extracting ...
 Extracting rdpweb_1.0.swf
 Extracting license.txt
 Cleaning up ...
 Installation successful.
 [16/Oct/2009:09:19:35] ENGINE Bus STARTING
 [16/Oct/2009:09:19:35] ENGINE Started monitor thread '_TimeoutMonitor'.
 [16/Oct/2009:09:19:35] ENGINE Started monitor thread 'Autoreloader'.
 [16/Oct/2009:09:19:35] ENGINE Serving on 0.0.0.0:8080
 [16/Oct/2009:09:19:35] ENGINE Bus STARTED
 [16/Oct/2009:09:19:57] ENGINE Started monitor thread 'Monitor'.

Now open your browser and type in the URL

Login using the username and password you just created. If you have already configured some virtual machines you should see them in the VM list on the left side.

When you've finished testing VBoxWeb console, press CTRL+C in your console window to quit the server part and close the web browser.

I will create an init.d script for VBoxWeb soon.

References

VirtualBox Remote Client Connection

You can remotely connect to the console of the virtual guest using the RDP protocol, also known as Terminal Services. In order to connect to a remote guest you establish a RDP connection the the Virtual Box host but use the VRDP port number assigned to the guest OS.

Here are some examples of how to connect to a guest OS using 'rdesktop-vrdp' (which is bundled with Virtual Box) and vanilla 'rdesktop'. The '-k' option sets the keyboard mapping for the United Kingdom.

Using rdesktop-vrdp

The advantage of the modified 'rdesktop-vrdp' is that is support USB redirection.

 rdesktop-vrdp -k en-gb -z -r clipboard:PRIMARYCLIPBOARD -5 virtualboxhost.example.org:3389

Using rdesktop

 rdesktop -k en-gb -z -r clipboard:PRIMARYCLIPBOARD -5 virtualboxhost.example.org:3389

vrdp authentication

TODO!

References

Auto Start Virtual Box Guests

Unlike VMWare you can't simply tick a box to get your guests booting when the host boots. However, a simple init.d script can do the job and there are even a couple of 3rd party tools to manage things for you.

I suggest using VBoxTool to manage guest auto start and shutdown.

Installing VBoxTool

 sudo -s -H
 cd
 mkdir VboxTool
 cd VBoxTool
 wget "http://downloads.sourceforge.net/project/vboxtool/vboxtool/0.4/vboxtool-0.4.zip?use_mirror=kent" -O vboxtool-0.4.zip
 vboxtool-0.4.zip
 cp script/vboxtool /usr/local/bin
 chmod +x /usr/local/bin/vboxtool
 cp script/vboxtoolinit /etc/init.d
 chmod +x /etc/init.d/vboxtoolinit  
 update-rc.d vboxtoolinit defaults 99 10
 mkdir -p /etc/vboxtool 
  
If you ever need to remove vboxtoolinit from autostart run the following
 update-rc.d -f vboxtoolinit remove

Configuring VBoxTool

Configuration from vboxtool does not taking place on running sessions, so save or stop all sessions before issuing the autostart command.

Create '/etc/vboxtool/machines.conf'. The format is as follows.

 <session name>,<VRDP-port>

For example...

 WindowsXP,3389
 UbuntuServer,3390
 UbuntuDesktop,3391

The VRDP-port enables RDP-clients like 'rdesktop' to connect. It may be left blank.

Create '/etc/vboxtool/vboxtool.conf'. The format is as follows.

 vbox_user='<user name>'

Issue the following command:

 vboxtool autostart

VBoxTool will configure sessions (VRDP-port). By now, session(s) should be up and running and configured.

Check if sessions or running, with the assumed vrdp-port:

 vboxtool show 

Show only the running sessions:

 vboxtool showrun

Check if sessions configured in '/etc/vboxtool/machines.conf' are be automatically started at reboot. Reboot your system, check with:

 vboxtool showrun

References

Migrating VMWare to Virtual Box

I had several Ubuntu Server 8.04 VMWare guests that were previously running on VMWare Server 1.0.6. Here is how I migrated the Ubuntu guests.

 sudo vmware-uninstall-tools.pl
 sudo aptitude install dkms build-essential linux-headers-`uname -r`
 sh ./VBoxLinuxAdditions-x86.run
 sudo nano /etc/udev/rules.d/70-persistent-net.rules

References

$Id: VirtualBox,v 1.44 2010/08/11 17:28:23 martin Exp $

Wiki Index All Recent Edit Top