VMware Fusion Tips and Tricks
This post documents strategies for managing virtual machines on VMware Fusion through automation. I wanted to enable automatic VM startup and shutdown on a schedule while allowing the host laptop to enter sleep mode during off-hours.
The solution involves two key components: the vmrun command-line tool and macOS's LaunchD scheduler.
VMware Fusion Command Line Tool
The vmrun command provides command-line control over virtual machines. Basic syntax requires three elements:
- The
-T fusionflag to specify VMware Fusion - An action such as
startorstop - The full path to the VM file
Example commands:
vmrun -T fusion start /Users/davidpacold/Virtual\ Machines.localized/Windows\ 10\ x64.vmwarevm
vmrun -T fusion stop /Users/davidpacold/Virtual\ Machines.localized/Windows\ 10\ x64.vmwarevmLaunchD Implementation
I created shell scripts containing sequential vmrun commands with sleep intervals between VM startups to stagger boot sequences.
A property list (plist) file configures LaunchD to execute scripts on a schedule. The example configuration runs a startup script daily at 7:00 AM:
<?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>com.davidpacold.vm.start</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>7</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>ProgramArguments</key>
<array>
<string>/Users/davidpacold/documents/startvm.bashrc</string>
</array>
</dict>
</plist>The plist file is saved to ~/Library/LaunchAgents/ and loaded with:
launchctl load ~/Library/LaunchAgents/com.davidpacold.start.vm.plistVerification uses:
launchctl list | grep com.davidpacold