Saturday, April 11, 2015

Auto start virtualbox windows virtual machine from mac os host


1. Make sure the virtual machine can start by invoking the below command from the terminal:
VBoxManage startvm WinXP
2. Add an automator action and copy the script
/usr/local/bin/VBoxManage startvm WinXPBig --type headless
/usr/local/bin/VBoxManage startvm WinXPBig2 --type headless

To start Vmware Fusion in headless way:

/Applications/VMware\ Fusion.app/Contents/Library/vmrun start /Users/peterpeng/Documents/Virtual\ Machines.localized/Windows\ XP\ Professional.vmwarevm/ nogui

/Applications/Mission\ Control.app/Contents/MacOS/Mission\ Control 1

3 Save and test

  • Go to System Preferences -> Accounts -> Login items
  • Add this app

I tried the plist method but failed to start it automatically by following the below links:

Auto-starting VirtualBox VMs on OS X

https://gist.github.com/reidransom/6042016

Start a VirtualBox VM at Boot on Mac OS X

https://www.petekeen.net/start-virtualbox-vm-at-boot-os-x

4.  Enable Prevent App Nap for VirtualBox. Right click on the VirtualBox application icon>Get Info>Prevent App Nap.
5. Disable the auto hibernation and set standbydelay to a bigger value (seconds)
sudo pmset -a hibernatemode 0
sudo pmset -a autopoweroff 0
sudo pmset standbydelay 10800000

Press Ctrl+Shit+Eject to turn off the screen


And the Energy Saver needs to be updated as below (after upgrade to macOS Sierra, it's changed, need check)