Skip to content

Instantly share code, notes, and snippets.

@rickyzhang82
Forked from str8edgedave/macos-vbox.md
Created December 18, 2018 13:05
Show Gist options
  • Save rickyzhang82/0edd4d618d0efda1a527f6da78c4699f to your computer and use it in GitHub Desktop.
Save rickyzhang82/0edd4d618d0efda1a527f6da78c4699f to your computer and use it in GitHub Desktop.
Auto-starting VirtualBox VMs on MacOS High Sierra

Auto-starting VirtualBox VMs on MacOS High Sierra

Updated May 21/2018

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 High Sierra 10.13.4 running VirtualBox 5.2.12. The guest OS is Fedora 28.

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.

david$ 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
david = {
    allow = true
    startup_delay = 10
}

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

Next, get a list of VMs on the system:

$ VBoxManage list vms
"Fedora Server" {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 "Fedora Server" --autostart-enabled on
VBoxManage modifyvm "Fedora Server" --autostop-type acpishutdown
VBoxManage modifyvm "Fedora Server" --defaultfrontend headless

Finally, test the configuration by running:

sudo launchctl load /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment