17

I have Ubuntu 10.04.1 (Lucid) running on a 2010 Mac Mini (4,1). It's a server, so I want it to be able to restart after a power failure ("server mode").

In Mac OS X, you can check "Start up automatically after a power failure" in the "Energy Saver" System Preferences. However, having this value checked doesn't seem to effect "server mode" behavior in Ubuntu (that is, it won't restart after a power failure).

This seems to be because the "server mode" value isn't persisted in pram/efi, but gets set by Mac OS X on every boot.

I found this tutorial on how to turn on "server mode" for a Mac Mini, but it doesn't work:

$ setpci -s 0:1f.0 0xa4.b=0
setpci: Warning: No devices selected for `0xa4.b=

A lot has changed with the new 4,1 Mac Minis-- just getting Ubuntu installed on it was quite a feat. Perhaps the "server mode" incantation has changed also?

My question is: how do I enable "server mode" on the new 4,1 Mac Minis?

6
  • 1
    In my experience, this is something typically handled by the bios. Since I know nothing about the lower workings of a Mac (other than that they use mostly standard Intel processors), I wouldn't be able to tell you how set the necessary values in the bios, let alone how to get into it in the first place.
    – MBraedley
    Nov 18, 2010 at 22:35
  • You mean EFI, not BIOS. Anyway there's no EFI setting for this. It's a chipset register that has to be poked on every bootup. I wish it were in the EFI, or in the pram at least, then we'd only have to set it one time!
    – paleozogt
    Nov 18, 2010 at 23:42
  • My point exactly.
    – MBraedley
    Nov 19, 2010 at 2:59
  • The current solution does not work for Mac Pro, but you can check this bug at Ubuntu bugs.launchpad.net/ubuntu/+source/linux/+bug/784571
    – sorin
    May 18, 2011 at 13:00
  • @Sorin Sbarnea: well, the question is for a mac mini
    – paleozogt
    May 18, 2011 at 14:54

7 Answers 7

20

On some Mac Minis (I tested on one circa 2014) it still seems to be:

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

I verified this after some research. The steps I took to find out, which theoretically can be done for future iterations of these machines too, were:

  1. Look for the LPC device:

    $ lspci | grep LPC
    00:1f.0 ISA bridge: Intel Corporation HM77 Express Chipset LPC Controller (rev 04)
    

    In this case, it's 00:1f.0.

  2. Find a datasheet for the device. E.g. Googling for "intel hm77 lpc controller datasheet" yielded this datasheet.

  3. Now you just have to find the right register, which could be a challenge depending on the data sheet. Here I found "5.13.7.5 Sx-G3-Sx, Handling Power Failures, p. 180" in the table of contents, which describes the control bit AFTERG3_EN.

  4. Searching through the document for that, we find it in section 13.8.1.3 (general PM config register 3) at the bottom of the table on page 530. From this we see it is bit 0 of the 16-bit register at 0xA4.

Then that can be used to construct the relevant setpci command.

So if this changes again in the future, find the device, find the datasheet, construct the command, test, and raise your fist in victory.

But basically the device and register address may differ on different machines, it's specific to the LPC controller; so that's the piece of hardware you have to check first before determining which command to use.

3
  • 1
    this works on an old iMac of 2007! the controller is a different one, but checking the relevant docs lead to the same command, in the end...
    – benzkji
    Nov 22, 2018 at 14:13
  • it is true that this must be executed on every boot, otherwise it's lost...
    – benzkji
    Nov 22, 2018 at 14:20
  • 1
    Thanks @jason-c that was a very interesting adventure!
    – reto
    Apr 20, 2023 at 11:26
10

I found the answered buried in this post. The new setpci command is

sudo setpci -s 00:03.0 0x7b.b=19

btw, this setting isn't "sticky" and won't persist across reboots-- it has to be set upon each boot.

You can put this command in a bash script and run it on startup. See here for details on start-up scripts.

4
  • Can you run that command in a start-up script, or will it still ask you for the su password?
    – MBraedley
    Nov 19, 2010 at 3:01
  • Yes you can run it in a start-up script. I've edited the answer to link to a start-up script how-to.
    – paleozogt
    Nov 19, 2010 at 16:03
  • Could you be so nice to add information regarding where to add this line in order to assure that it will be executed when the system boots, preferably as soon as possible? - Ubuntu
    – sorin
    May 18, 2011 at 11:32
  • @Sorin Sbarnea: in the answer is a link to info on start-up scripts in ubuntu
    – paleozogt
    May 18, 2011 at 15:00
7

There is a great summary on this matter here: http://www.macfreek.nl/memory/Reboot_Mac_running_Linux_after_power_failure

In a nutshell, the configuration of the Advanced Configuration and Power Interface (ACPI) depends on the model of southbridge used in the Mac.

In order to configure auto-boot on power failure identify your southbridge model by looking up your LPC devices and create a cron tab or systemd service to set the bit registers accordingly.

$ lspci | grep LPC

For a Mac Mini early 2006 / MacMini1,1 / A1176:

00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02)

For a Mac Mini early 2009 / MacMini3,1 / A1283:

00:03.0 ISA bridge: NVIDIA Corporation MCP79 LPC Bridge (rev b2)

For a Mac Mini early 2010 / MacMini4,1 / A1347:

00:03.0 ISA bridge: NVIDIA Corporation MCP89 LPC Bridge (rev a2)

For a Mac Mini Server 2011:

00:1f.0 ISA bridge: Intel Corporation HM65 Express Chipset Family LPC Controller (rev 05)

Please note that the configurations are not persistent across reboots so it requires configuration on startup (for example through systems as suggested by @Juan Carlos Méndez).

To create a systemd startup service, create a file etc/systemd/system/reboot_on_power_failure.service:

[Unit]
Description=Reboot after power failure

[Service]
Type=oneshot

# Please select the appropriate ISA bridge for your MAC below:

# reboot register for Mac Mini with nVidia ISA bridge
# ExecStart=setpci -s 00:03.0 0x7b.b=0x19

# reboot register for Mac Mini with Intel ISA bridge
# ExecStart=sudo setpci -s 0:1f.0 0xa4.b=0

# reboot register for PPC Mac Mini (not tested myself):
# ExecStart=echo server_mode=1 > /proc/pmu/options


[Install]
WantedBy=sysinit.target

And run with sudo systemctl enable --now reboot_on_power_failure.service

3

On a Mac Mini MD387LL/A Intel Core i5-3210M, running linux with systemd, I have it working adding a service like this:

cat /etc/systemd/system/reboot_on_power_failure.service  
[Unit]                                                                                                       
Description=Reboot after power failure                                                                       
                                                                                                             
[Service]                                                                                                    
Type=oneshot                                                                                                 
# reboot register for Mac Mini with Intel ICH7 south-bridge                                                  
ExecStart=setpci -s 0:1f.0 0xa4.b=0:1                                                                        
                                                                                                             
[Install]                                                                                                    
WantedBy=sysinit.target 

and of course the service is started with

systemctl enable --now reboot_on_power_failure.service
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Feb 1, 2022 at 16:57
1

I can confirm on a Mac Mini (late 2012) adding this to the root cron:

@reboot /usr/bin/setpci -s 00:1f.0 0xa4.b=0

will make it reboot on power failure.

2
  • You can confirm that your suggestion works on a Mac mini or you cannot confirm it works?
    – Ramhound
    Apr 23, 2021 at 14:19
  • @Ramhound I can confirm this works on Mac Mini 2012
    – Mads Y
    Feb 20, 2023 at 20:48
1

I've set up a Mac Pro 5,1 with iXsystems TrueNAS SCALE (Debian 11.2) and needed it to restart on power failure. I had found this Working Ninja link which explains how to look up the correct bits to set. This MacFreak link, mentioned by others, explains how to set up several Mac Minis, and how to use a bit mask.

On that machine I typed:

$ lspci | grep LPC
00:1f.0 ISA bridge: Intel Corporation 82801JIB (ICH10) LPC Interface Controller

Per Working Ninja, I looked on the Intel website for the manual for an ICH10 and found the bit address for AFTERG3_EN.

I added the command to set the first bit to zero:

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

to run as a "Pre Init" script in the TrueNAS web GUI's "Init/Shutdown Scripts", rather than using the command line and creating a startup service.

It works!

0

I can also confirm that to reboot the Mac Pro 2,8 (MacPro3,1) after power failure, the setcpi ubuntu command is the following:

sudo setpci -v -s 00:1f.0 0xa4.b=0:1

This Mac Pro has the Intel 631xESB/632xESB/3100 LPC ISA bridge.

Based on an earlier comment, to persist this command, the systemd service code is as follows:

[Unit]
Description=Reboot MacPro after power failure

[Service]
Type=oneshot

# Reboot register for MacPro 3.1 with Intel 631xESB/632xESB/3100 LPC ISA bridge
ExecStart=sudo setpci -v -s 00:1f.0 0xa4.b=0:1

[Install]
WantedBy=sysinit.target

Not forgetting the systemctl enable --now reboot_on_power_failure.service.

2
  • Same answer has been done more than 13 years before!
    – Toto
    Jan 26 at 22:30
  • @Toto Register locations are specific to the model so, yes the result is the same as some answers, but now when someone is searching for this specific mac model like I was, they can find this answer that tells them it will work successfully.
    – AfonsoFigs
    Jan 28 at 14:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .