Virtualbox On A Headless Ubuntu Server

When you want a virtual machine on a headless server you will have to download and install, configure it from the commandline. I will here explain how you would proceed.
First you will need the latest version from the sun website for your linux version:
VirtualBox for linux
Then you will need to download and install it:

wget “” -O virtualbox-3.0_3.0.8-53138_Ubuntu_karmic_i386.deb

Install it:
sudo dpkg -i virtualbox-3.0_3.0.8-53138_Ubuntu_karmic_i386.deb

Fix the depencencies with
sudo apt-get -f upgrade

Create the virtualmachine:
VBoxManage createvm -name windowsxp -register

Configure the virtualmachine:
VBoxManage modifyvm windowsxp -memory “512MB” -acpi on -boot1 dvd -nic1 nat

Create the virtualdisk:
VBoxManage createvdi -filename “/var/vbox/windowsxp.vdi” -size 10000 -register

add the disk to the virtual machine:
VBoxManage storagectl windowsxp --name "IDE Controller" --add ide --controller PIIX4

And to add the vdi to the virtualmachine
VBoxManage storageattach windowsxp --storagectl "IDE Coltroller" --port 1 --device 0 --type hdd --medium /home/virtualmachines/windowsxp.vdi

register the installation iso
VBoxManage registerimage dvd /var/vbox/windowsxp.iso

Mount the iso on the virtualmachine:
VBoxManage modifyvm windowsxp -dvd /var/vbox/windowsxp.iso

and ofcourse start the virtualmachine:
VBoxHeadless -startvm windowsxp -p 3389 &

To see which virtualmachine you have register type:
VBoxManage list vms

To poweroff a virtual machine type:
VBoxManage controlvm windowsxp poweroff

And to reset
VBoxManage controlvm windowsxp reset

connect the virtualmachine with a bridged adapter use the following (assuming that your server has eth1)
VBoxManage modifyvm windowsxp --nic1 bridged
VBoxManage modifyvm windowsxp --bridgeadapter1 eth1

To add a shared folder use:
 VBoxManage sharedfolder add windowsxp --name share --hostpath /home/user

When it crashes (and it does sometimes) and it would not reinstall again because of kernal headers missing type:
sudo apt-get install linux-headers-`uname -r`

Set up hostonly networking
VBoxManage modifyvm windowsxp --hostonlyadapter1 eth1

To address 1024MB memory to the machine first look how much is assigned with the command:
VBoxManage showvminfo "windowsxp"

When the size is too small upgrade it with
VBoxManage modifyvm "windowsxp" --memory 1024

To add more videoram type
VBoxManage modifyvm wxp --vram 16

To add an extra cpu type
 VBoxManage modifyvm wxp --cpus 2
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License