VirtualBox autostart on macOS High Sierra: launchctl questions

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
paulbeard
Posts: 15
Joined: 13. Jun 2013, 18:51

VirtualBox autostart on macOS High Sierra: launchctl questions

Post by paulbeard »

Trying to get a Virtualbox guest to restart when the OS X (High Sierra) host is rebooted (power failure or whatever).

I have tried using the launchctl plist that comes with VirtualBox but something is going on I can't work out. I can load it and it appears in the list of jobs managed by launchctl:

Code: Select all

launchctl load -w /Applications/VirtualBox.app/Contents/MacOS/org.virtualbox.vboxautostart.plist; launchctl list | grep org
-	1	org.postfix.master
8310	0	org.virtualbox.vboxautostart
245	0	org.cups.cupsd
-	0	org.wireshark.ChmodBPF
84	0	org.macports.net-snmp
-	0	org.macosforge.xquartz.privileged_startx
But if I check again a minute later, the list doesn't include it:

Code: Select all

launchctl list | grep org
-	1	org.postfix.master
245	0	org.cups.cupsd
-	0	org.wireshark.ChmodBPF
84	0	org.macports.net-snmp
-	0	org.macosforge.xquartz.privileged_startx
I have changed the Disabled flag to false, per the docs at Oracle. I have a cfg file that permits me to run a VM, also from those docs.

I have even tried starting it from cron using the @reboot option but nothing works.

Code: Select all

/usr/local/bin/VBoxHeadless -s ed8b8574-9a71-4b27-b0a9-c6ac81721fe2
/usr/local/bin/VBoxManage startvm ed8b8574-9a71-4b27-b0a9-c6ac81721fe2
The VM starts just fine on the command line or through the GUI app. So there is a missing piece here. I have an rc script (called from the supplied plist) but I have never used it, just teh examples shared or the GUI app.

The VM is currently running and I don't know if that's an issue.
granada29
Volunteer
Posts: 690
Joined: 3. Mar 2015, 07:27
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: Linux, macOS, Windows

Re: VirtualBox autostart on macOS High Sierra: launchctl questions

Post by granada29 »

One of the problems in starting a VM at boot is that the file system may not be available at the time the launchd task is run. You could put a delay in your start script, or test for the file system being available before running VirtualBox
paulbeard
Posts: 15
Joined: 13. Jun 2013, 18:51

Re: VirtualBox autostart on macOS High Sierra: launchctl questions

Post by paulbeard »

I wouldn't expect cron to run until the filesystems are available…where else would it get it's instructions. Especially from a user crontab. I think there is something not right with the plist file, which might explain why it drops out of the listing of active services. And perhaps to do with how High Sierra handles launchctl…obviously cron would be preferred as a way around all of that.
Post Reply