Procedure to Automatically Launch a Virtual Machine at Mac Startup

Procedure to Automatically Launch a Virtual Machine at Mac Startup

I have headless Mac mini computers that operate as "servers". They automatically launch VMware Fusion virtual machines at startup. Here is how I configured it.

Procedure for Automatically Launching a VMware Fusion Virtual Machine at Mac Startup

  • Login to your Mac using your admin account.
  • Set the Mac so that it automatically restarts if there is a power failure. Go to System Preferences, Energy Saver.
  • Create an account for automatic login at startup. I create the same set of accounts in the same order on all of my Macs, so that Unix user IDs match. On my Macs, I named the automatic login account "<Lastname>Server". In this procedure, let us call the account, "ServerUser"
  • Set the ServerUser account to login automatically. Go to System Preferences, Users & Groups, Login Options, and select the ServerUser account from the pulldown menu. You will be prompted for the ServerUser account password.
  • If you will be running your Mac as a headless machine with no keyboard or mouse (like my Mac mini computers), disable "Open Bluetooth Setup Assistant at startup if no keyboard is detected" and disable "Open Bluetooth Setup Assistant at startup if no mouse or trackpad is detected". You will probably want to configure some type of remote access so that you can control your Mac from another system. See Remote Access Notes, below.
  • Logout from your admin account.
  • Login to the Mac under the ServerUser account.
  • Launch VMware Fusion in the ServerUser account. Enable the desired virtual machine to "Start automatically when VMware launches" in the chosen virtual machine's VMware Settings, General.
  • Reboot the Mac. It should automatically login to the ServerUser account, launch VMware Fusion, and then VMware Fusion will automatically start the virtual machine.
  • You may want to run a power failure test to verify that the virtual machine launches automatically after a power failure. This test has risks. See Power Failure Test, below.

Security Notes

  • Automatic restart on power failure won't work if you have FileVault enabled.
  • Security Risk: If you configure automatic login on your Mac, the password is stored in a file that only root can access. The password is encoded, but not really encrypted. If someone can get physical access to your Mac itself, they could gain access to any file on your Mac, including the virtual machine itself, the ServerUser password file, etc. That is because you cannot enable FileVault if you want the virtual machine to launch automatically.
  • Security Risk: Your Mac is configured to login automatically at startup. If someone steals your Mac, they can connect a keyboard, mouse, and monitor to it and then boot it. It will be logged in to your ServerUser account. (That is one reason why you do not use your admin account for automatic login.) You can mitigate some of the risks by:
    • Set the ScreenSaver in the ServerUser account to start after 1 minute. System Preferences, Desktop & Screen Saver, Screen Saver tab, Start after (pulldown menu). Set the System Preferences, Security & Privacy, General tab, Require password "immediately" after sleep or screen saver begins.
    • Better solution for experts: In addition to the above, you can configure your Mac to display the login prompt immediately after startup, even though the ServerUser account is logged in and the virtual machine is running.
      • Create a small application that locks the screen and displays the OS X login prompt. See: Terminally Geeky: use automatic login more securely
      • I converted the shell script above into a Mac application, and added it to the ServerUser Login Items list.
      • I found that it didn't work on a headless Mac, unless I fooled the Mac into thinking that a display was attached. I made a little "VGA Dummy Plug". See: https://rumorscity.com/2013/12/06/how-to-create-dummy-plugs-for-your-graphics-cards/
      • Additional Note: One of the Mac's is running Windows Server 2012 R2 in its virtual machine, which has bridged networking. For some reason, it would not receive external network connections if the login prompt was displayed on the Mac screen. I had to remove the application from the Login Items list and rely on the Screen Saver lock above. Someday I will troubleshoot this to see if I can make it work.

Remote Access Notes

  • If you are running your Mac as a headless machine, you will probably want to configure some type of remote access that that you can control your Mac from another system. You will want to install Apple security updates on your headless Mac, for example.
  • Some people attach a keyboard, mouse, and monitor when needed, but it can be a lot of trouble over time.
  • I still use Timbuktu Pro to remotely operate headless Macs. Unfortunately, Timbuktu Pro is no longer supported or available.
  • Others may try Apple Remote Desktop or another solution. I do not know whether LogMeIn, TeamViewer, GoToMyPC, or similar products are viable solutions. I found this in a quick web search: http://www.geekersmagazine.com/remote-access-mac-applications.html
  • You may also want remote access to your running virtual machine:
    • If your virtual machine runs Windows, it may support Windows Remote Desktop. One of my virtual machines runs Windows 2012 R2 Server, and I connect to it from my Mac using Microsoft Remote Desktop (free from the App Store).
    • If your virtual machine run Linux, you can connect to it using VNC. Your Mac comes with a basic VNC client called "Screen Sharing.app" in /System/Library/CoreServices/Applications/. It is very basic, and the VNC connections it makes are not secure. There are other VNC applications for your Mac that you may want to consider.
      • If you are Linux guru, you can configure your Mac to tunnel VNC through SSH.
      • If you are Linux guru, why use VNC, which is slow? Why not run a remote X-session directly on your Mac?

Power Failure Test

First, please read the important note, below.

  • Shutdown the virtual machine.
  • Disconnect power from the Mac.
  • Reconnect power from the Mac.
  • The Mac should boot, login under your ServerUser account, launch VMware Fusion, and start your virtual machine.

Important Note about the risks of a Power Failure Test:

Disconnecting power from your Mac when it is running poses a risk to your system. You may corrupt files or cause other damage to the file system on your Mac's hard drive. OS X is designed to withstand occasional power failures, but you do not want to run this test more than necessary. I ran it once only. Since then, there have been several power failures over the years that have done the same thing - and the Macs have handled them correctly.

This document was generated from the following discussion: Procedure to Automatically Launch a Virtual Machine at Mac Startup

Version history
Revision #:
1 of 1
Last update:
‎03-06-2016 02:15 PM
Updated by: