Power loss behaviour - is there some basic action?

Bo Berglund bo.berglund at gmail.com
Wed Mar 26 10:22:18 UTC 2025


On Sat, 15 Feb 2025 19:26:16 +0100, Bo Berglund <bo.berglund at gmail.com> wrote:

>On Sat, 15 Feb 2025 16:17:08 +0000, Colin Law <clanlaw at gmail.com> wrote:
>
>>On Sat, 15 Feb 2025 at 15:35, Bo Berglund <bo.berglund at gmail.com> wrote:
>>>
>>> Should I move the new server off of the UPS but keep the other devices hooked up
>>> so that the server will experience a "power outage" and therefore start when
>>> power returns?
>>> Or is there some other way to handle this situation?
>>>
>>> I am thinking about having a task running on one of the RaspberryPi units which
>>> checks that it can ping the server say a minute or two after boot and if
>>> unsuccessful send a Wake-On-LAN command to the server's MAC address.
>>
>>With the BIOS setting, my server laptop does auto start when the power
>>is re-applied, even if normally shutdown.  However, just in case it
>>does not, I have my router configured to send it WOL every 5 minutes.
>>If you cannot set that up in the router then do it in the pi.  No need
>>to check whether the server is running, just do it every 5 mins
>>anyway.
>>
>>Colin L.
>
>OK thanks!
>
>I did not know this was possible.
>I have an ASUS RT-AX86U PRO main router and I don't know if it is able to "do
>stuff on a schedule" but I can for sure set up one of the 24/7 RPi devices via
>crontab so it will send a WOL command every so often.
....

>
>So the full solution:
>
>1) Set the NUC13 BIOS to enable the WakeOnLan function

I have done this now when I could reboot and get to BIOS.
Turns out that it was set active by default...

>2) Also set it in BIOS to start when power is re-applied
>This might only work with real power disruptions, so in that case I might be
>better off not enabling the nut functionality for shutting down when power is
>about to disappear from the UPS.

I have decided NOT to install nut at all so if the system runs on the UPS and
its battery empties the result will be a "power outage" on the system, but no
protective shutdown before power disappears.

>
>3) Configure WOL inside Ubuntu, apparently it has to be re-armed every time it
>boots. So I would probably do that from a crontab entry on reboot.

This is really crazy! Why would a function like this have to be rearmed every
time the system starts??? Especially since there is no clear advice on *how* to
do it.

I actually found an article describing how one could set up a systemd one-shot
service to do this, so I tested it. But on the first reboot after the
installation of the service it did not work at all!!
The system came up with wol disabled!! :-(

So I need to skip systemd for this and install a task that runs on boot after a
short delay to enable the WOL for the next boot cycle.
For this I have created a script that is called from cron @reboot like this:

# Enable Wake-On-LAN after each reboot+ a 60s sleep to let things stabilize
@reboot /home/bosse/bin/enable_wol > /dev/null 2>&1

The script enable_wol looks like this:

#!/bin/bash
#This script enables Wake-On-LAN and should be run when the system starts

sleep 60 #To let the system stabilize
# Enable the wake-on-lan since it is volatile
sudo /usr/sbin/ethtool -s enp86s0 wol g
exit

I have not been able to check yet if it actually works to arm wol on a reboot,
though.

>4) Enable a regular WOL call from an RPi4 device for example every 5 minutes or
>so to trigger its wakeup if it is not running.

#!/bin/bash
# This is set to run on a RaspberryPi every 10 minutes from cron
#Which is the better command?
etherwake a4:ae:12:7f:4d:c3
wakeonlan a4:ae:12:7f:4d:c3


Is this OK?



-- 
Bo Berglund
Developer in Sweden





More information about the ubuntu-users mailing list