There’s the great FreeNAS jail phpVirtualBox. It lets you run headless VirtualBox-machines on your FreeNAS server, in case you need a different operating system than FreeBSD. I’m using it to run Icinga and Musicbrainz. There’s only one problem: After a server reboot (yes, that happens) the VMs do not automatically start again.

Luckily there’s a method to to achieve that.

First you’ll have to connect to your FreeNAS (and the Virtualbox-jail) on the shell. If you don’t know how to do it, have a look here. After connecting its just a matter of editing one file: the rc.conf.

The file rc.conf contains descriptive information about the local host name, configuration details for any potential network interfaces and which services should be started up at system initial boot time.

To edit the rc.conf, enter the following command on the shell:

edit /etc/rc.conf

Then you have to put the following code into the now open file (copy&paste it). You’ll have to replace “yourm” with the name of your virtual machine.

# this is required for networking (replaces loading remaining modules manually)

# start VirtualBox

# VMs to start (whitespace-separated list):

# definition for VM with acronym "yourvm":

Press escape then Enter twice to save and exit the file.

If you want to add another virtual machine, simply add it to the vboxheadless_machines-list and append the three following lines, again replacing the name.

Here’s an example where two virtual machines are automatically started at boot:

# VMs to start (whitespace-separated list):
vboxheadless_machines="icinga musicbrainz"

# definition for VM with acronym "icinga":

# definition for VM with acronym "musicbrainz":

That is all you have to do. Next time your FreeNAS server reboots, the VMs will start, too!

Related posts: