Making a Mac Mini power up when power is restored: Debian 11 version
Yesterday, I wrote about getting Debian 11 running on an old Mac Mini.
It wasn’t much of a write-up, as it was very easy.
Since I am running it as a server, I’d like it to reboot automatically if there is a power outage. Well, when the power outage is over and power is restored. It’s behind a UPS, so hopefully that should offer a measure of protection against mains blips anyway.
But still.
It appears – thanks, ant! – that a small change to the Mini’s power settings will make this happen:
setpci -s 0:1f.0 0xa4.b=0
(There is a seemingly credible explanation.)
However, it is not just a case of setting it once, but setting it on every (re)boot.
Most of the guides – now dated – suggest putting this in /etc/rc.local
. As this has been / is being deprecated, that didn’t seem like a good idea, so I went for a systemd
approach instead.
I created a .service file:
vim /etc/systemd/system/rebootonpowerrestoration.service
with content:
[Unit]
Description=Enable reboot on power restoration
[Service]
Type=oneshot
ExecStart=/usr/bin/setpci -s 0:1f.0 0xa4.b=0
[Install]
WantedBy=multi-user.target
I enabled it:
systemctl enable --now rebootonpowerrestoration.service
(The use of the the --now
switch means that, as well as it being enabled for next boot, it is started/run now too.)
Did it work?
Yes. It booted fine once power was re-applied.
When I’d logged in, I checked
systemctl status rebootonpowerrestoration.service
and the log showed that the script had run.
Excellent!
You may also like:
- Installing Debian Bullseye and VirtualBox on a Mac Mini
- Installing Debian 10 Linux on a Microsoft Surface Pro 6
- Raspberry Pi 4 with the PoE+ HAT: LUKS and a working fan
- Installing vanilla Debian 11 on a Raspberry Pi 4
- Fixing a font which shows in macOS Font Book but not in macOS LibreOffice
- Unlocking a LUKS-encrypted partition via ssh on Debian 10 and Debian 11
- Gemini PDA running Debian: a properly portable computer
- Handwriting, and annotating PDFs: a stylus on Debian 10 on Surface Pro 6 compared with an iPad
- Removing the default games in GNOME 3 on Debian 10
- Internet access via iPhone's personal hotspot on Lubuntu 21.04
- Lubuntu 21.04: forcing natural scrolling on a mouse
- Debian 10 on a Samsung NC10
- Running Jitsi on a Raspberry Pi 4
- wireguard via algo: a simpler, faster(ish) alternative to IPSec