Skip to content

Instantly share code, notes, and snippets.

@suniltaneja
Forked from str8edgedave/macos-vbox.md
Created March 29, 2020 21:34
Show Gist options
  • Select an option

  • Save suniltaneja/aa70cfe573a0f6279673a87523b8a8d4 to your computer and use it in GitHub Desktop.

Select an option

Save suniltaneja/aa70cfe573a0f6279673a87523b8a8d4 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