Start VirtualBox virtual machines on boot

NOTE: check the vboxcontrol section for up to date information. This article is a bit stale.

Today, uptime of Far Fewer Toes suffered. That’s because we’ve bought a new computer to host the site on. Previously, we were hosting on an old Pentium III 600, which badly needed a replacement. We also needed to free up another box, in order to use it for real reviews and tests (as opposed to in VirtualBox).

Yesterday evening and today I’ve been working on setting everything up, and this site is now hosted in a VirtualBox instance on the new machine: an AMD Athlon64 x2 4400+ with 4 GB of RAM.

Now, VirtualBox doesn’t come with some kind of init script to automatically start all virtual machines on boot of the host, and after searching how others solved this problem, i stumbled on the blog of Mandriva’s Adam Williamson. He has written a blog post containing among other things the required steps to set up VirtualBox with host-based networking.

His post didn’t cover how to start everything on boot of the host machine, and shutting down VirtualBox and all virtual machines gracefully on reboot or shutting down of the host.

After some more reading around, I’ve created an initial working version of a VirtualBox init.d script, which does the following things for you:

The script was developed on and for Ubuntu 7.10 Gutsy Gibbon, and needs some modifications if you want to run it on other distributions.

Also, the script assumes a few things:

Instructions to install the script on Ubuntu 7.10:


Note: the script is kind of hackish, and is open to improvements. I’ve released it without a license, in the public domain

Update 20080311: configure your virtual machines to have a static ip address if your host is also the dhcp server for your network. The reconfiguring of your network interfaces at boot doesn’t work well with a running dhcp service.

Update 20080331: uploaded new version of script. Cleaned it up, added bridge-up/bridge-down, taps-up/taps-down methods, rename setup_* to enable_*, show VM names in ’status’ output, and check if taps are already configured before bringing them up

Update 20080511: Renamed the script to vboxcontrol, cleaned it up put it some more functionality (requested in the comments), and gave it its own section on farfewertoes.

Download and instructions here!

 
blog comments powered by Disqus