Ubuntu: Virtualisation Server

From ReceptiveIT
Jump to: navigation, search

This is not a complete howto. At the moment it contains only random thoughts. I will tidy this up later.

VirtualBox

Install

sources.list

deb http://download.virtualbox.org/virtualbox/debian natty contrib
deb http://download.virtualbox.org/virtualbox/debian maverick contrib non-free
deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free
deb http://download.virtualbox.org/virtualbox/debian karmic contrib non-free
deb http://download.virtualbox.org/virtualbox/debian hardy contrib non-free
deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free
deb http://download.virtualbox.org/virtualbox/debian lenny contrib non-free

Add the signing key

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

Install Virtualbox

sudo apt-get update
sudo apt-get install virtualbox-4.0

Configure

We need to create a user that the headless virtualbox instance will run as, and that user needs access to raw disks if you want to use a block device as the storage for a VM.

adduser vbox
adduser vbox disk
adduser vbox vboxusers

Virtualbox Extension Pack

wget http://download.virtualbox.org/virtualbox/4.0.8/Oracle_VM_VirtualBox_Extension_Pack-4.0.8-71778.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.0.8-71778.vbox-extpack 
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully installed "Oracle VM VirtualBox Extension Pack".

Virtualbox Web Service

mkdir -p /etc/vbox

/etc/vbox/vbox.cfg

VBOXWEB_USER=vbox
#VBOXWEB_HOST=
#VBOXWEB_PORT=
#VBOXWEB_TIMEOUT=
#VBOXWEB_CHECK_INTERVAL=
#VBOXWEB_THREADS=
#VBOXWEB_KEEPALIVE=
#VBOXWEB_LOGFILE=/tmp/virtualbox.log

Start the service

/etc/init.d/vboxweb-service restart

phpVirtualbox

Installation

Get the latest version

cd /var/www
wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt` -O phpvirtualbox-latest.zip
unzip phpvirtualbox-latest.zip
ln -s phpvirtualbox-4.0-6 phpvirtualbox

Configure

cd /var/www/phpvirtualbox
mv config.php-example config.php
vi config.php

You will want to change the password for the vbox user to match its login credential.

/* Username / Password for system user that runs VirtualBox */
var $username = 'vbox';
var $password = 'pass';
var $consoleHost = '192.168.20.10';

Advanced

Use a LVM logical volume as a virtual storage device

sudo VBoxManage internalcommands createrawvmdk -filename /data/virt/centosraw.vmdk -rawdisk /dev/vg0/centos
sudo chown vbox:vboxusers /data/virt/centosraw.vmdk

Import a VM from KVM

  • Make sure you have PAE NX turned on
  • Make sure that you have IO-APIC turned on
  • Make sure that the IDE controller is PIIX-3