How to auto start VMs on OS X Yosemite (10.10)

Hello,


I am running VirtualBox 4.3.20 r96996 on OS X Yosemite (10.10) Mac mini. I need to know the steps I can follow to auto start my Virtual Machines on reboot and/or on starting VirtualBox. Please advise me in the right direction

Mac mini, OS X Yosemite (10.10)

Posted on Jun 23, 2015 4:56 PM

Reply
19 replies

Oct 4, 2017 7:51 AM in response to scott88

Wait - ignore this. The "VBoxAutostartDarwin.sh" file (as I now look at it) scans through all users, filters out ones without a shell/home, then uses each reduced user to call into:


su ${user} -c "/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart --quiet --start --background --config ${CONFIG}"


So yeah, ignore my above comment.

Oct 4, 2017 7:36 AM in response to jay_francisco

I think you're on the right path @jay_francisco, you're just missing the --start argument to VBoxAutostartDarwin.sh.


That is, you should have these three lines where you have two currently:


<string>/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh</string>
<string>--start</string>
<string>/etc/vbox/autostart.cfg</string>


Note that you might need to add a --config line as well prior, and depending on the version of VirtualBox, the script might be called just "VBoxAutostart" (see the results of "ls -l /usr/local/bin | grep -i vbox"

Jun 23, 2015 8:55 PM in response to jay_francisco

To start it on reboot, you would have to create a launchd plist to start up the VM. This is the syntax for the command

/usr/bin/VBoxManage stratvm <name of vm>

There is a program on the App Store called Lingon 3 that can help, or search the web for Launchd plist examples and write your own.


I don't know how to tell VB to start a VM on launch.


A way around that for just about any program would be to create an Automator Application or Applescript Application that opens the VM. Use that application to launch VB instead of VB itself.

Jun 24, 2015 11:04 AM in response to Barney-15E

I have the following configuration setup


<?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>Disabled</key>

<false/>

<key>KeepAlive</key>

<true/>

<key>Label</key>

<string>org.virtualbox.vboxautostart</string>

<key>ProgramArguments</key>

<array>

<string>/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh</str ing>

<string>/etc/vbox/autostart.cfg</string>

</array>

<key>RunAtLoad</key>

<true/>

<key>LaunchOnlyOnce</key>

<false/>

</dict>

</plist>



$ cat /etc/vbox/autostart.cfg

default_policy = allow



Then I did the following


sudo chmod +x /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh

sudo chown root:wheel /etc/vbox

sudo chown root:wheel /etc/vbox/autostart.cfg

sudo chown root:wheel /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist


and


VBoxManage modifyvm va1 --autostart-enabled on

VBoxManage modifyvm va1 --autostop-type acpishutdown


VBoxManage modifyvm va2 --autostart-enabled on

VBoxManage modifyvm va2 --autostop-type acpishutdown


Then, I issued the following command for verification:

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


However, only one VM starts at reboot and sometimes both don't start.


What am I missing here?

Jun 24, 2015 11:47 AM in response to Eric Root

@eric, I am not sure if I know how to do that correctly, can you please guide me?


Also, I realized that launchctl has upgraded in OS X Yosemite (10.10). http://www.manpagez.com/man/1/launchctl/. The "load" and "unload" commands are called "legacy commands", and the new commands such as "kickstart", "bootstrap", "enable" are to be used.


No clue on how to use these new commands, please help!

Jun 24, 2015 1:54 PM in response to jay_francisco

VirtualBox is a GUI app. You can't set it to run at startup which you are doing because there is no GUI at startup.

As Eric pointed out the simple way of starting VB when you log in.

You could create a Launch Agent similar to what you did to have it launch at login for any user that logs in. Or, you can just put it in your user/Library/LaunchAgents

A Launch Agent runs at login.

A Launch Daemon runs at startup.


If you want to launch a specific VM (or VMs), I think you would need to create a LaunchAgent (not a Daemon) that would use the command I posted above as the thing to run. You don't need to create a shell file to run that line. You can just put it in the ProgramArguments.

<key>ProgramArguments</key>

<array>

<string>/usr/bin/VBoxManage</string>

<string>startvm</string>

<string><name of vm></string>

</array>


You don't need to load, unload, kickstart, or whatever. If it is a valid plist and is in your LaunchAgents folder, it will load unless you specifically unload it and set the -w option which tells it to remember the last load/unload setting (which is now enable).


I don't know what you were doing with the whole autostart.cfg stuff.

Jun 25, 2015 5:31 AM in response to jay_francisco

The following is my /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist file as used on a Mac running Yosemite and I have multiple VMs starting automatically.


<?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>Disabled</key>
  <false/>
  <key>KeepAlive</key>
  <true/>
  <key>Label</key>
  <string>org.virtualbox.vboxautostart</string>
  <key>ProgramArguments</key>
  <array>
  <string>/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh</string>
  <string>/etc/vbox/autostart.cfg</string>
  </array>
</dict>
</plist>

Jun 30, 2015 3:13 PM in response to jay_francisco

Virtualbox has also terminal client and you can use Automator app on your Mac to create an application to launch your VM.


Please review this chapter. If you need some additional parameters for VBoxManage tool.


Open Automator app and as a type of document, choose Application.


Next, as an action choose Utilities > Run Shell Script (double click on it). Have a look at bellow screenshot:

User uploaded file

In above example, my VM's name is Ubuntu 14.04 amd64 and full command is: VBoxManage startvm "Ubuntu 14.04 amd64"

As you probably know already, my VM is called Ubuntu 14.04 amd64.


Once your Automator document looks like above, save the document as the Application and save it in your user Application folder.


Then, go to System Preferences > Users & Groups > Login Items, and add your created application to the list of apps that will start automatically after your user has successfully logged in:

User uploaded file

If you have more than one VM you might need to create an app for each individual VM.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to auto start VMs on OS X Yosemite (10.10)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.