home index sites engineering software hardware email

How-To: VirtualBox

Documentation & resources


Under Ubuntu (tested with 10.04) run the following:

echo "deb http://download.virtualbox.org/virtualbox/debian lucid contrib" | \
   sudo tee /etc/apt/sources.list.d/virtualbox.list
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | \
   sudo apt-key add - && sudo aptitude update
sudo aptitude install virtualbox-4.0

Download the extension pack from http://www.virtualbox.org/wiki/Downloads and install it:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.*.vbox-extpack

Add yourself to the vboxusers group:

sudo gpasswd -a $USERNAME vboxusers

Finally, logout then back in (so your account has access to the new group) and run the following:

VirtualBox &

Creating a VM

Use the GUI to create the VM however you might want to change the "Remote Display" (if you use the feature) to only listen on localhost (127.0.01) by running the following via the command line (it's only possible to set the port with the current version of the GUI), make sure to change "some vm" to the name of your VM:

VBoxManage modifyvm "some vm" --vrdeaddress

You can verify the remote display settings with:

VBoxManage showvminfo "some vm" | grep VRDE

Guest additions

Select "Install Guest Additions" from the VirtualBox "Devices" menu to get seamless window, keyboard and mouse integration (under Linux you will need to manually run the .run file off the mounted CDROM, choose the file appropriate for your architecture).

Mounting host directories/folders

Select "Shared Folders" from the VirtualBox "Devices" menu, click "Machine Folders" then click on the "plus" symbol to the right and select a host directory to export, set the "Folder Name" to "vbox" (for example).

To mount the shared folder under a Linux guest run the following to create a directory (you can use any directory you want):

sudo mkdir /host

Then run the following to mount the shared folder under the newly created directory:

sudo mount -t vboxsf vbox /host

To make the mount permanent add the following to /etc/fstab:

vbox /host vboxsf defaults 0 0

To mount the shared folder under a Windows guest run Windows Explorer, select "Tools/Map Network" Drive and select an unused drive letter then enter the following as the "Folder":


Resizing Virtual Disks

On the host (with the VM shutdown), expand the size of the VDI image. For example, this resizes the disk image to 20GB:

VBoxManage modifyhd "name of disk.vdi" --resize 20000

Then either:

  • Boot the VM with a GParted rescue CD and re-distribute the partition(s) as necessary, or
  • If the partition is the last/only one on the virtual disk just resize it with fdisk then run the appropriate tool to expand the file system after a reboot (for EXT3/4 that would be resize2fs).

Tips & Tricks

Updating the extension pack

First remove the current extension pack:

sudo VBoxManage extpack uninstall 'Oracle VM VirtualBox Extension Pack'

Then install the new extension pack (get it from http://www.virtualbox.org/wiki/Downloads ):

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.*.vbox-extpack

Sending ctrl-alt-fX

To send ctrl-alt-fX press 'host'-fX (by default 'host' is the right control key).