After rebooting I discovered my VMs weren't running, so I took a look online to figure out how to do this, and many places pointed to the same blog post:
http://lifeofageekadmin.com/how-to-set-your-virtualbox-vm-to-automatically-startup/
While the procedure worked, it wasn't perfect, so I'm posting my modified version of the procedure here, mostly for my own reference. (run these commands as the user who owns the VBox VMs which will be autostarted.)
- Create the file /etc/default/virtualbox with the following contents:
sudo bash -c 'cat << EOF > /etc/default/virtualbox
# virtualbox defaults file
VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg
EOF'
*NOTE: Don't use vbox.cfg as found in the above link. Apparently some VirtualBox scripts look for that file for other purposes. - Make sure your user is a member of the vboxusers group:
if ! groups | grep -w nobody; then sudo usermod -aG nobody $LOGNAME; echo Log out; fi
If you see "Log out" as the output of the above command, log out and back in so your group membership is updated. If you're okay, you should see the output of the groups command. - Create the /etc/vbox directory and the autostart.cfg file:
sudo mkdir -p -m 1775 /etc/vbox
sudo chgrp vboxusers /etc/vbox
sudo bash -c "cat << EOF > /etc/vbox/autostart.cfg
# Default policy is to deny starting a VM, the other option is "allow".
default_policy = deny
# Create an entry for each user allowed to run autostart
$LOGNAME = {
allow = true
}
EOF"
You set the sticky bit (the "1" in the "1775" to keep users in the vboxusers group from deleting the files aside from their own. This is how the /tmp directory works - 1777 and users can only delete their own files. - Set the autostart property via VBoxManage
vboxmanage setproperty autostartdbpath /etc/vbox - Modify the appropriate VM with autostart enabled:
vboxmanage modifyvm Graphite --autostart-enabled=on - Restart the vboxautostart-service"
systemctl restart vboxautostart-service - Restart your system and confirm that the VMs have started:
vboxmanage list runningvms
No comments:
Post a Comment