WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Uncategorized / Enable Auto Startup After Power Failure For Apple Mac Mini

Enable Auto Startup After Power Failure For Apple Mac Mini

02.11.2013 by William Lam // 39 Comments

I recently came across a very useful tidbit after receiving several inquires asking how to configure an Apple Mac Mini to automatically startup after a power failure. This is extremely useful for situations where power is eventually restored and you are not physically around to press the power button. Automatically starting up after a power failure is not a new feature of the Mac Mini and it actually exists on most modern day systems and can be configured using a variety of tools.

The challenge arises when you are running ESXi, how do you go about enabling this functionality in ESXi itself? Well the answer is actually quite simple, you can enable this outside of ESXi. Normally to enable this feature you can either run a setpci command on UNIX/Linux system or configure the energy saver settings in OS X. Several folks from the VMTN community such as zippytiff and twuhabro have already confirmed having success using the latter option when booting OS X off a USB or SD card to modify the energy saving settings.

I finally got a chance to look into this a bit more for myself and with a bit of research, I found several other methods which also works and may potentially be easier.

Note: I have heard that historically the auto startup flag has not persisted in older Apple hardware, but for the new Mac Mini 5,3 and 6,2, they seem to be persisting without any issue from my testing. YMMV depending on your hardware and/or firmware.

Method 1 (Configure in OS X)

If you already have OS X install on your Mac Mini, then you just need open up the System Preferences and enable auto startup under the Energy Saver section. Once that has been enabled, you can then perform your ESXi installation.

If you already have ESXi installed, then you can use either Method 2 or 3.

Method 2 (Configure using bootable Ubuntu on USB)

We can create a bootable Ubuntu image running off of a USB device (minimal footprint) and run the following setpci command to enable auto startup:

setpci -s 0:1f.0 0xa4.b=0

If you are interested in the gory details on the above command, please refer to this great article which breaks it all down for you. After you have created your Ubuntu image using the instructions in the above link, you can boot off of the USB device (Make sure to hold down ALT/OPT key so you can select to boot off of the USB device). Once Ubuntu has booted up, you will right click on the purple icon on the upper left hand corner and type in terminal.

You will then launch the terminal application and type the following to change over to root user.

sudo su -

Finally, you will enter the above setpci command which will enable the auto startup. At this point, you can type reboot and remove the USB device.

Method 3 (Configure using bootable OS X on USB)

Another method is to create a bootable OS X image running off of a USB device and change the power management settings by using the pmset utility. To enable auto startup, run the following command in the terminal:

pmset autorestart 1

You will need the original OS X installer and if you are using either Lion or Mountain Lion, you can use Lion DiskMaker to help you create the bootable USB image (Make sure to hold down ALT/OPT key so you can select to boot off of the USB device). Once the OS X installer boots up, at the top select Utilities and click on the Terminal application.

Go ahead and run the above command to enable auto start and then type reboot and remove the USB device.

The last thing to do of course is to actually test this out on your Mac Mini. Go ahead and let the system boot up and then yank the power cord and then give it a few seconds before plugging it back in. You should see the Mac Mini automatically power back on after you plug the power back in.

References:

  • http://www.beasts.org/support/macminicolo_howto.html
  • http://smackerelofopinion.blogspot.com/2011/09/mac-mini-rebooting-tweaks-setpci-s-01f0.html

 

More from my site

  • Aquantia/Marvell AQtion (Atlantic) driver now inbox in ESXi 7.0 Update 2
  • Apple Mac Mini on VMware HCL!
  • Aquantia 10GbE ESXi Driver for Apple 2018 Mac Mini
  • ESXi on the new 2018 Apple Mac Mini
  • Retrieving Apple hardware details (Model, Serial, Board & EFI Boot ROM & SMC Version) from ESXi

Categories // Uncategorized Tags // apple, ESXi, mac mini, power management

Comments

  1. *protectedJon says

    05/27/2013 at 4:48 am

    Will this setting stick once it's set? I have bootcamp for Windows 8. I use Windows 8 full time for Media Center cablecard DVR. When the power goes out I'd like the macmini to power back on. I went into Mac OS X and checked the box. Hopefully that's good enough. I don't want to "try" it if I can just ask first.

    Reply
  2. *protectedJon says

    05/27/2013 at 4:52 am

    EDIT: never mind, I see that Boot Camp Control Panel in windows actually has the Power option of "Restart automatically after a power failure" I should be good to go now!

    Reply
  3. *protectedAnonymous says

    06/13/2013 at 8:16 pm

    I'm in the same boat, running Windows 7 only on Mac Mini and need to set it to reboot after power failure. I wonder what Apple is running to do it, I would think it would be an nvram command or something.

    Reply
  4. *protectedAnonymous says

    10/01/2013 at 12:04 pm

    and with VMWare ESXI 5.1 installed, there is an option to Start up after power Failure?

    Reply
  5. *protectedJulfikar Rahman says

    11/02/2013 at 5:39 pm

    zeg op
    opzeggen
    uitschrijven
    afmelden
    tijdschriften

    Cancel.my is a wonderful site for opzeggen. I was almost in trouble in that but this site preserves me from that and helped me to cover the problem, that is why I like to take their support always.

    Reply
  6. *protectedNick James says

    02/14/2014 at 4:45 am

    The problem is that this setting does not survive subsequent reboots.

    The setting is written everytime OSX boots, so if you don't boot OSX each time the setting will be lost and the mini will not power on after power is restored.

    In windows you can use the WPCRSET utility to set the flag each time and this achieves the same behaviour as the setting in OSX, however I am still looking for a way to run a similar utility or something every time ESXi boots so the setting sticks.

    Is anyone aware of a utility that can do this, and how to set it so ESX executes it on every boot?

    Reply
    • *protectedWilliam Lam says

      02/14/2014 at 1:28 pm

      I'm currently using this method on my Mac Mini 6,2 and the settings have persisted for me on both ESXi 5.1 & 5.5. In fact, I've had a power outage a couple months back and once the power was back it started up the system as I expected

      Reply
  7. *protectedMarc says

    04/09/2014 at 3:06 am

    Just tried the USB OSX boot method with the pmset command and it doesn't seem to work. Is there something that needs to be done in order to make the setting "stick"?

    Reply
    • William Lam says

      04/09/2014 at 4:56 am

      afaik, that should work. Perhaps something has changed with the latest release of OSX?

      Reply
  8. *protectedMarc says

    04/09/2014 at 12:38 pm

    Perhaps. I was using a Mavericks installer USB.

    I subsequently tried the bootable Ubuntu (13.10) USB method which worked like a charm.

    Thanks!

    Reply
    • *protectedMarc says

      04/10/2014 at 7:12 pm

      Seems like the setting has reverted itself now. Is there something that needs to be done to make it stick? Or is there something that would cause it to revert?

      Reply
  9. *protectedPaul Richardson says

    05/06/2014 at 8:27 pm

    It seems that Mac OS oriented MOBOs and Firmware are more likely to include this capability than Windows-oriented BIOS. Is a magic packet (WOL) the only option then, for slightly older Windows PCs? Is there potentially an App/Script that might somehow help boot it back up when power returns?

    Reply
    • *protectedBen Peddell says

      06/24/2014 at 11:22 am

      On most PCs made since about 2000, there is an option in the BIOS to set the "Restore from AC power loss" (or something similar) to "Always On".

      On the Mac Mini, it looks almost as if this setting is cleared by the firmware during shutdown - the Mac Mini will only automatically power on if the OS did not gracefully shutdown and power off the system.

      Reply
  10. *protectedClaude Morin says

    07/09/2014 at 8:20 pm

    [Success, and a tweak]

    This worked for me on a Mac Mini 6,2 using method 2: I used Ubuntu 14.04 on a DVD to run setpci.

    Before making the change I checked the existing value:
    # setpci -v -s 0:1f.0 0xa4.B
    0000:00:1f.0:a4 = 09
    #
    Here we see that it was "09", which is binary 1001. I don't know what bit three does but I'd rather not find out the hard way :-).

    So I made one tweak to the invocation of setpci. Instead of clearing the entire register by setting the value to zero, one can set arbitrary bits using the value:mask feature of setpci. Here, I set the least-significant bit to zero. Adding the "-v" flag produces verbose output:
    # setpci -v -s 0:1f.0 0xa4.B=0:1
    0000:00:1f.0 @a4 = 09->(00:01)->08
    #
    So we see that the value "09" was modified by the value:mask "00:01" and became the value "08". I could have just forced the value to "08" but the value:mask approach is more general.

    For extra safety, do a dry run first by adding the "-D" option:
    # setpci -vD -s 0:1f.0 0xa4.B=0:1

    --klodefactor

    Reply
    • *protectedMisterA says

      12/09/2023 at 1:39 am

      This worked for me and seems the safer bet as it's a more subtle edit than the original proposal. Like others using macOS to do it did not persist through reboots, this did.

      In my case as I was using Proxmox as my hypervisor, which is Debian based, I could simply run the setpci command via it's shell.

      Reply
      • *protectedMike Wheeler says

        03/13/2025 at 7:52 am

        Yup.
        Used the shell in Proxmox to set this up. So far its tested out great!

        Reply
  11. cyril+*protectedCyrl says

    08/17/2014 at 10:09 pm

    Little tip about Method 3:
    Instead of creating a full USB bootable media, you can just create a USB recovery stick by using the Recovery Disk Assistant included in Mac OS X.
    It creates the "Recovery HD" on the key and you will need a 1GB usb stick. It is far away faster than creating a full USB Installer media πŸ˜‰

    Reply
  12. *protectedpaopaomj says

    09/09/2014 at 5:06 pm

    Hi, thanks for this article.
    Just tried the 2nd and 3rd method, on Mac mini 5,2 (MC816) with ESXi 5.5 installed.
    The pmset way under Mavericks installation usb disk doesn't work , it can't keep persistant, every time I reboot into installation use pmset -g to checkout that autorestart status, it always return back to 0.
    The ubuntu way works!!! Just as you described, it works like a magic.
    Thank you again, that helped me so much!

    Reply
  13. *protectedmichalmmac says

    02/04/2015 at 6:50 am

    Hi, great article
    How would you deal with this -> https://communities.vmware.com/thread/500931
    Basically I need to replicate halt -u behavior from OS X on ESXi hypervisor running on Mac mini.

    Reply
    • William Lam says

      02/04/2015 at 2:15 pm

      I don't have any suggestions, the halt command in ESXi only provides the following options:

      ~ # halt --help
      BusyBox v1.20.2 (2012-12-11 11:54:28 PST) multi-call binary.

      Usage: halt [-d DELAY] [-n] [-f] [-w]

      Halt the system

      -d SEC Delay interval
      -n Do not sync
      -f Force (don't go through init)
      -w Only write a wtmp record

      I've shot a note to one of the Engineers to see if he has any ideas.

      Reply
      • *protectedmichalmmac says

        02/04/2015 at 8:10 pm

        Thank you for response.

        My current solution would be to shuddown all running VMs and than wait for power loss to occur. Hypervisor would die. What is the worst thing that can happen? What kind of write IO operations is hypervisor doing while not running any VMs?

        If engineers could come up with cleaner solution (replicating halt -u in some way), that would be great πŸ™‚

        Reply
        • William Lam says

          02/05/2015 at 12:12 am

          There can still be write operations happening even when there are no VMs running. Administrator could still be making changes to ESXi host, config, etc. If none of that's running, there's also auto backup script that flushes configuration files to disk every 5minutes. So, yes there can be IO operations running.

          I know some other approaches that folks have done including myself, not specific to Mac Mini is to have a VM be able to talk to your UPS and once it notices it's turned on due to power outage, you can issue commands to ESXi host via SSH or using the vSphere API. I know APC/Eaton has similar solutions doing this. So, perhaps something you may want to look into.

          Also remember that the Mac Mini platform is not an officially supported

          Reply
          • *protectedmichalmmac says

            02/05/2015 at 4:14 pm

            Just for clarity. Problem is not how to talk UPS. Problem is how to put ESXi host software to state when it is no longer running (halted) but power is still on so SMC in Mac mini can detect loss of power and restart automatically.

            Would is be possible to tell init daemon to shut down every service but not itself?

          • *protectedmichalmmac says

            02/08/2015 at 9:08 pm

            btw what about /bin/shutdown.sh script? It stops all running VMs and some ESXi services. Wouln't that be enough?

          • William Lam says

            02/09/2015 at 4:16 am

            That actually initiates a shutdown of the host, once VMs are off, it shutdowns rest of services and then the host

          • *protectedmichalmmac says

            02/09/2015 at 9:05 am

            But there is no 'poweroff' or other shutdown command in /bin/shutdown.sh (ESXi 5.5U2).
            Last thing it does is to shutdown syslog.
            During my testing this script always stops services but host does not power off.
            Perhaps I am misusing terminology (shutdown vs. poweroff)?

            #!/bin/ash

            log() {
            echo "$1"
            logger init "$1"
            }

            #Extract and save the random seed
            dd if=/dev/urandom of=/etc/random-seed count=1 2>/dev/null

            #Power off autostart configured VMs
            /sbin/vmware-autostart.sh stop

            /sbin/services.sh stop

            #Backup the config (including the random seed)
            /sbin/backup.sh 1

            #Shutdown syslog daemon
            /usr/lib/vmware/vmsyslog/bin/shutdown.sh

          • William Lam says

            02/09/2015 at 4:42 pm

            Sorry, meant to say for poweroff. Yes, I guess /bin/shutdown.sh should technically should work, SSH looks to still be running least with the active session.

  14. *protectedroy says

    01/24/2016 at 9:15 am

    Hi i am looking for a way to auto start / power on my mac,

    i am using a switch to turn of al my side equipment of my studio computer and also the computer it self.
    speaker, midi keyboard, screen. etcetera. now i am looking for a way to auto start up my mac mini the way i can do it whit my pc,
    so that when i use the remote switch everything starts up. and that I don't have to start my computer manual.
    So that when I am inspired to make music I would like to start as fast as possible.

    Kind regards Roy

    Reply
  15. *protectedgrandavebb says

    04/11/2016 at 8:23 pm

    Thanks for this article. I was faced with turning this feature on on a Mac Mini 1,1 (first Intel), and so far, it isn't sticking.

    This was a throwaway machine that I decided to experiment with reconfiguring as a MikroTik x86 router, so that I could run the newest Dude network monitoring package on it. It boots and runs fine in MikroTik ROS, and when I hold the option key down, boots fine from an external drive containing OS X. I can set the auto-boot feature on in OS X, and if I reboot into OS X, it stays on, but once I boot into ROS, it seems to disappear. I also tried the pmset route in Terminal, with the same results. A shame, since auto-on is a key requirement for a network monitoring system. πŸ™

    Reply
  16. *protectedDean Zook says

    07/21/2016 at 1:17 pm

    I have ESXi 6 on a mid 2012 mac pro and would like to know if the method outlined in this post or some other would work to enable a startup after a power failure.

    Reply
  17. manny.veloso+*protectedmanny says

    05/05/2017 at 9:04 am

    The easiest way to persist this setting is to boot into a Mac OS recovery USB, go to terminal, and do a

    pmset -a autostart 1 force

    The 'force' writes it to nvram immediately. Normally it needs to be set by a disk file on boot up.

    Reply
    • manny.veloso+*protectedmanny says

      05/05/2017 at 2:27 pm

      This has been tested on a 1,1 and a 3,1.

      Reply
    • manny.veloso+*protectedmanny says

      06/13/2017 at 12:07 pm

      Oops, that should be pmset -a autorestart 1 force

      Reply
  18. *protectedJoe says

    05/30/2018 at 11:36 am

    Anyone know if the setpci... command be run from the esxi 6 command line via ssh to apply this to a Mac Pro 6,1 (2013)?

    Reply
  19. *protectedAndre Garkauskas says

    12/26/2020 at 2:55 pm

    Thank you so much! Running pfsense on a MacMini 2014 over ProxMox and this feature is very important.

    Reply
  20. *protectedJim says

    09/26/2024 at 8:11 am

    Thank you, the setpci -s 0:1f.0 0xa4.b=0 is exactly what I needed! πŸ™‚

    Reply
  21. fabianoecjr+*protectedFabiano says

    02/17/2025 at 8:52 am

    I have a YunoHost instance running on a 2014 Mac Mini.
    This worked perfectly!
    THANK YOU!

    Reply

Trackbacks

  1. VirtualMaster Home Lab with vSphere 6.0 – Part 1 | virtualmaster.it says:
    12/10/2015 at 9:47 am

    […] Enable Auto Startup After Power Failure For Apple Mac Mini: link […]

    Reply
  2. pmset autorestart is not persisted when run from install media - PhotoLens says:
    12/19/2021 at 8:38 pm

    […] Mac mini (Intel) that runs vSphere and I want to set auto startup on power on. Based on what I read here I created a macOS bootable USB installer and booted from it. Then from Terminal I […]

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download TokenΒ  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025