Configuring VirtualBox autostart on Linux
June 22, 2017
It is often useful to configure VirtualBox virtual machines to automatically start and stop on startup and shutdown. The official documentation was a bit unclear, so I’ve made a short tutorial about it.
1. Configuration files
/etc/default/virtualbox
sudo nano /etc/default/virtualbox
then add:
VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg
/etc/vbox/autostart.cfg
sudo nano /etc/vbox/autostart.cfg
then add:
default_policy = deny
# Create an entry for each user allowed to use autostart
myusername = {
allow = true
}
sudo chgrp vboxusers /etc/vbox
sudo chmod 1775 /etc/vbox
- Then, for each allowed username:
sudo usermod -aG vboxusers USERNAME
, then log out and in for it to apply.
2. Choose VMs to automatically start and stop
- The first time a user configures autostart, the command:
VBoxManage setproperty autostartdbpath /etc/vbox
needs to be run. - Note: The autostart options are stored in the /etc/vbox file, and the VM itself. If moving the vm, the options may need to be set again.
VBoxManage modifyvm <uuid|vmname> --autostart-enabled <on|off>
- You can also:
VBoxManage modifyvm <uuid|vmname> --autostop-type <disabled|savestate|poweroff|acpishutdown>
3. Restart VirtualBox autostart service
sudo service vboxautostart-service restart