Skip to content

Instantly share code, notes, and snippets.

@mig8447
Forked from str8edgedave/macos-vbox.md
Last active April 8, 2020 19:55
Show Gist options
  • Save mig8447/ee4140afc2db3a2cde7fefa22b041b2d to your computer and use it in GitHub Desktop.
Save mig8447/ee4140afc2db3a2cde7fefa22b041b2d to your computer and use it in GitHub Desktop.
Auto-starting VirtualBox VMs on macOS

Auto-starting VirtualBox VMs on macOS

Updated Jul 22/2019

There are lots of different how-tos out there for automatically launching VMs using VirtualBox on MacOS. Most of them focus on older versions of VirtualBox or old versions of MacOS.

Tested using macOS Mojave 10.14.4 running VirtualBox 6.0.8. The guest OS is RHEL 7.

Following the instructions on the VirtualBox website (https://www.virtualbox.org/manual/ch09.html#autostart), copy the Virtualbox autostart plist template file to your system's LaunchDaemons folder.

mig8447$ sudo cp \
    /Applications/VirtualBox.app/Contents/MacOS/org.virtualbox.vboxautostart.plist \
    /Library/LaunchDaemons

Backslashes for readability :-).

Edit /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist and set Disabled to false.

Create the file /etc/vbox/autostart.cfg with the following content:

default_policy = deny
mig8447 = {
    allow = true
    startup_delay = 10
}

Change mig8447 to match your MacOS username ($ whoami).

Next, get a list of VMs on the system:

$ VBoxManage list vms
"Linux VM" {GUID for server displayed here}

For each server that you want to automatically start, enable autostart, configure the autostop-type method, and enable headless mode.

VBoxManage modifyvm "Linux VM" --autostart-enabled on
VBoxManage modifyvm "Linux VM" --autostop-type acpishutdown
VBoxManage modifyvm "Linux VM" --defaultfrontend headless

For the --autostop-type you can also use savestate. For the --defaultfrontend you can also use gui

Finally, test the configuration by running:

sudo launchctl load /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist

You may need to restart the host computer to test your configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment