VirtualBox and Ubuntu 11.10

So I'm switching over from VMWare Server to VirtualBox because, while it works well on Windows, I couldn't get it going on Linux.

VirtualBox has little troublesome setup if you want the same features of VMWare like: web interface and auto-starting VMs. Instructions were a little hard to come by so here they are mashed together for you.

Installing Virtual Box 

This is a simple one. Install the package:
sudo apt-get install VirtualBox-OSE 

Reference: https://help.ubuntu.com/community/VirtualBox/Installation

Installing the Headless Extension

sudo vi /etc/apt/sources.list
add line:
# Virtual Box Headless
deb http://download.virtualbox.org/virtualbox/debian oneiric contrib


Download Public Key:
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

Update and Install
sudo apt-get update
sudo apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.1 dkms

Download Extension Pack from: http://www.virtualbox.org/wiki/Downloads
Install (Change Pack version to match your downloaded version)
cd ~/Downloads #your download location for the extension pack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.12-77245.vbox-extpack


Create new user that will run Virtualbox and add user to vboxusers group.
sudo adduser virtualbox vboxusers
sudo adduser virtualbox 

Reference: http://www.howtoforge.com/vboxheadless-running-virtual-machines-with-virtualbox-4.1-on-a-headless-ubuntu-11.10-server


Installing Web Interface


For the web interface you need a web server that supports PHP5. You should already have the heavy Apache2 web server installed, if not install it
sudo apt-get install apache2

Add on the PHP5 support and restart Apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart

Download phpvirtualbox from http://code.google.com/p/phpvirtualbox/downloads/list

Extract phpvirtualbox to your web hosting location
cd ~/Downloads #your download location for phpvirtualbox
mkdir /var/www/phpvirtualbox
unzip phpvirtualbox-4.1-7.zip /var/www/phpvirtualbox/

Rename config.php-example to config.php
mv /var/www/phpvirtualbox/config.php-example /var/www/phpvirtualbox/config.php

Edit the config file
nano /var/www/phpvirtualbox/config.php

Enter the credentials for the virtualbox user you created to run the vboxweb-service earlier.
var $username = ‘virtualbox’;
var $password = ‘plain-text-password’;

Edit the vboxweb-service 
nano /etc/default/virtualbox


Enter the username you for the same user account you created to run the vboxweb-service.
VBOXWEB_USER=virtualbox

Start the vboxweb-service
/etc/init.d/vboxweb-service start

Now navigate to the web interface
http://localhost/phpvirtualbox

Login with the default credentials:
username:admin
password:admin

Change your password by clicking File > Change Password in the web interface

References:
http://thestorey.ca/wordpress/?p=24
http://ethertubes.com/virtualbox-4-1-phpvirtualbox-on-ubuntu-10-04-lts-server/

Installing VM Auto-Start


Download VBoxTool from: http://sourceforge.net/projects/vboxtool/files/

Unzip VBoxTool to a new folder vboxtool
cd ~/Downloads #your download location for vboxtool
unzip vboxtool-0.4.zip -d vboxtool

If the version has changed from 0.4 then refer to the readme.txt for the location of the file. The steps below follow the instructions in the 0.4 readme.txt


cd vboxtool/script 
sudo cp vboxtool /usr/local/bin/
sudo chmod +x /usr/local/bin/vboxtool
sudo cp vboxtoolinit /etc/init.d/
sudo chmod +x /etc/init.d/vboxtoolinit
sudo update-rc.d vboxtoolinit defaults 99 10
sudo mkdir /etc/vboxtool

Create empty config files
sudo touch /etc/vboxtool/machines.conf
sudo touch /etc/vboxtool/vboxtool.conf

Now you can add your VM(s) to the list of VM(s) to start up by editing the /etc/vboxtool/machines.conf file.

For Example, to start a VM named tristan and override its  VRDP port add the following line to machines.conf
tristan,3390,,
To start the VM type:
vboxtool start "tristan"
To start all configured VMs:
vboxtool autostart
Reference:
http://vboxtool.sourceforge.net/
http://automation.binarysage.net/?p=925

0 comments: