Ubuntu VirtualBox Server Redux Addendum

In: VirtualBox
Written by: Taylor Gerring


25 May 2010

Although the last article on running a VirtualBox server gets you up and running with a minimum installation, there are several things that can be configured or installed to make the experience of managing a VirtualBox server much easier.

Guest Additions

Probably the most common need is to install guest additions. Because the virtual machines are running in headless mode, there’s no menu to easily select “Install Guest Additions”. However, this option merely automates the mounting of an ISO. We can replicate this functionality from the command line. Note that the path to the ISO may vary depending on your host environment.

#run this on your host
VBoxManage storageattach "LAMP1" --storagectl "IDEController" --port 1 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso
#run these commands on the guest
#install packages necessary to build and install the additions
sudo apt-get install build-essential linux-headers-`uname -r`
#run the Guest Addtions installation and reboot
sudo mount /media/cdrom
sudo /media/cdrom/VBoxLinuxAdditions-x86.run

If you’d like to mount another disc, you’ll need to eject the ISO first.

#unmount the disc in the guest
sudo umount /media/cdrom
#instruct VirtualBox to emulate an empty drive
VBoxManage storageattach "LAMP1" --storagectl "IDEController" --port 0 --device 0 --type dvddrive --medium emptydrive

Shared Folders (guest additions neccessary for shared folders)

Shared folders are a common way to transfer files between guest and host. First, you’ll need to successfully install guest additions. Once done, adding is easy as following the below template. Just customize the VM name, share name and host path.

VBoxManage sharedfolder add "LAMP1" --name "dropbox" --hostpath ~/Dropbox/

Changing the MAC address

This is probably not a common need, but if you’ve got IP addressed reserved for certain devices, you’ll need to ensure the MAC address stays the same between VM setups and tear-downs. The change from auto-generated is easy.

#First, check the current MAX address
VBoxManage showvminfo "LAMP1"|grep NIC\ 1:
#Now, set the MAC address to whatever you want
VBoxManage modifyvm "LAMP1" --macaddress1 0800279859FF

USB support

I’m not sure how many people use USB support in headless mode, but if you need to mount a device directly in the guest OS, VirtualBox provides that ability. Permission settings borrowed from http://wiki.flexion.org/VirtualBox.html

#Add proper permissions to USB device
printf "none /proc/bus/usb usbfs devgid=%s,devmode=664 0 0" $(grep vboxusers /etc/group | cut -f3 -d':') | sudo tee -a /etc/fstab
VBoxManage modifyvm "LAMP1" --usb on --usbehci on

VM Management with VBoxTool

By far, the best tool I’ve used for automated VM management is VBoxTool. It’s really just a collection of scripts to automate tasks, but the killer feature is the autostart and autosave of virtual machines on boot and shutdown. While it facilitates other aspects of VM management, those two alone make it worth the trouble of configuring it.

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
unzip vboxtool-0.4.zip
cd script
chmod 755 vboxtool*
sudo chown root:root vboxtool*
sudo mv vboxtool /usr/local/bin
sudo mv vboxtoolinit /etc/init.d
sudo update-rc.d vboxtoolinit defaults 99 10
sudo mkdir -p /etc/vboxtool
cd /etc/vboxtool
#Configure /etc/vboxtool/machines.conf to register machines with VBoxTool
echo 'LAMP1,3391' | sudo tee -a machines.conf
#Configure /etc/vboxtool/vboxtool.conf to indicate which user that machines should start under
printf "vbox_user='%s'" $(whoami) | sudo tee -a vboxtool.conf
vboxtool autostart

If for some reason you ever decide to remove VBoxTool, you’ll need to unregister it from boot with the below command.

update-rc.d -f vboxtoolinit remove

VBoxWeb

Although the VBoxWeb project still has some rough edges and the blog isn’t updated often, it holds a lot of promise. If you’d like to check it out, use the following commands to download and install it. Full guide available on their own website.

sudo apt-get install python-simplejson subversion
svn checkout http://vboxweb.googlecode.com/svn/trunk/ vboxweb-read-only
cd vboxweb-read-only
python VBoxWebSrv.py adduser $(whoami)
#Below starts VBoxWeb in the background
python VBoxWebSrv.py &

1 Response to Ubuntu VirtualBox Server Redux Addendum

Avatar

Ubuntu VirtualBox Server Redux | Idea Excursion

May 25th, 2010 at 5:29 am

[...] The addendum for extra features is up. var a2a_config = a2a_config || {}; a2a_config.linkname="Ubuntu VirtualBox Server Redux"; [...]

Comment Form

@TaylorGerring


Unless specified otherwise, this website is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.
Stop SOPA
Unless specified otherwise, this website is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States.