Automatically Start Oracle VM VirtualBox and Virtual Machines on Solaris 11

As with starting the VirtualBox Web Service on Oracle Solaris, the documentation regarding starting VirtualBox and auto-starting virtual machines is rather convoluted. In particular it is not immediately clear if the autostart database directory provisions necessary under Linux are required under Solaris (they are not) or how to specify which VMs to automatically start, regardless of platform. Here I will once again attempt to straighten the instructions out, for my purposes - your mileage may vary.

First we must create a configuration file which defines those users (local system user accounts) may autostart virtual machines and after what delay they may be started (to prevent the over-congestion of resources at bootup).

First we need somewhere to store configuration files:
# mkdir /etc/vbox

Even if only one user account is used to run virtual machines on the host it is good to retain the default deny policy outlined in the official documentation's example configuration as restrictive assumptions are often safe assumptions - not that the compromise of any other account and subsequent automatic running of virtual machines is a particularly impactful security concern.

Drop the following in /etc/vbox/autostart.cfg:
# Default policy is to deny starting a VM, the other option is "allow". default_policy = deny # user is allowed to start virtual machines but starting them # will be delayed for 10 seconds user = { allow = true startup_delay = 10 }

Now we need to tell svccfg where to find the configuration file:
# svccfg -s svc:/application/virtualbox/autostart:default setprop config/config=/etc/vbox/autostart.cfg

A ways before covering how to set up autostart the documentation for VBoxManage modifyvm shows us how to specify those VMs which should be automatically started and after how long a delay (for a staggered configuration that avoids over-taxing your host's resources at startup):

8.8.9. Autostarting VMs During Host System Boot

These settings configure the VM autostart feature, which automatically starts the VM at host system boot-up. Note that there are prerequisites that need to be addressed before using this feature. See Section 9.21, “Starting Virtual Machines During System Boot”.

  • --autostart-enabled on|off: Enables and disables VM autostart at host system boot-up, using the specified user name.
  • --autostart-delay : Specifies a delay, in seconds, following host system boot-up, before the VM autostarts.

As the user that owns the virtual machines run:
$ VBoxManage modifyvm vmname --autostart-enabled on $ VBoxManage modifyvm vmname --autostart-delay seconds

This is also a good time to change your VMs' default frontend to headless, for reasons why please see A Word on Oracle VM VirtualBox Start Modes (defaultfrontend):
$ VBoxManage modifyvm vmname --defaultfrontend headless

You may wish to consider Preallocating VirtualBox VM RAM for Greater Stability and Avoiding Overcommitment:
$ VBoxManage setextradata vmname VBoxInternal/RamPreAlloc 1

When the configuration has been completed and you are ready to enable autostart, as root run:
# svcadm enable svc:/application/virtualbox/autostart:default


There are no comments for this item.