I heard you like headless VMs on your Mac so I wrote this script for your launchd
s.
- Tested on Mac OS X 10.6.4 with VMware Fusion 2.0.5 and 3.1.1.
- A interactive user automatically logs into the system at startup. I had some issues trying to get this running without an interactive user logged in. I automatically log in for Airfoil Speakers anyway.
- Your virtual machines live in
/Virtual Machines
- Place the
vmdaemon
script into/Virtual Machines
and make it executable (sudo chmod 755 vmdaemon
) and owned by root (sudo chown root:wheel vmdaemon
). - Copy the template plist into
/Virtual Machines
. The plist should also bechmod 644
andchown root:wheel
. - For each VM you want to run headless, copy the
template
property list file and change the filename, label and 2nd program argument to match your VM name. - Symlink the plist into
/Library/LaunchDaemons
- Run
launchctl load -w $PLIST
to start the VM. - Use
launchctl unload -w $PLIST
to initiate a graceful shutdown of the VM. By default it will wait up to 5 minutes for the VM to shutdown. This can be configured inExitTimeOut
in the plist
If you try this out with your own setup, I'd like to hear how things go. Patches via gist forks are welcome.
- Jason Weathered (@jasoncodes)
plist files in
/Library/LaunchDaemons
will automatically load upon system boot (well, whenever launchd says to after system boot), but plists in/Library/LaunchAgents
will load after user login. Obviously,/Library/LaunchAgents
are loaded for all users system wide, and~/Library/LaunchAgents
are loaded per-user.It would probably be best to put this plist in the
/Library/LaunchAgents
directory, and it might be a better idea to put them in the user's~/Library/LaunchAgents
directory, just to ensure you aren't loading unnecessary resources into memory and consuming CPU if there is more than one account, with the added benefit of making sure the system is fully operational before you start trying to boot another underneath it.