Skip to content

Instantly share code, notes, and snippets.

@gerardag
Created February 5, 2022 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerardag/9c2295ce6cfef3e368fb1e5c4516feee to your computer and use it in GitHub Desktop.
Save gerardag/9c2295ce6cfef3e368fb1e5c4516feee to your computer and use it in GitHub Desktop.
Auto-start VirtualBox VMs (headless) after reboot on Mac OSX
<!--
First of all get your username and machine name using the following commands
$ whoami
$ VBoxManage list vms
After that, locate (or create) the following file and open it:
$ cat /Users/[your-username]/Library/LaunchAgents/org.virtualbox.launch.[your-machine-name].plist
Once opened, paste the following content:
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.virtualbox.launch.[your-machine-name]</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/VirtualBox.app/Contents/MacOS/VBoxManage</string>
<string>startvm</string>
<string>[your-machine-name]</string>
<string>--type</string>
<string>headless</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
<!--
Save the file and you can test if the script works using the below command:
$ launchctl load /Users/[your-username]/Library/LaunchAgents/org.virtualbox.launch.[your-machine-name].plist
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment