Score:0

Trying to set wake-on-lan persistently on linux fails

am flag

This is my box: Linux mediacenter 5.15.122-1-MANJARO #1 SMP PREEMPT Tue Jul 25 07:09:46 UTC 2023 x86_64 GNU/Linux

I am trying to follow https://wiki.archlinux.org/title/Wake-on-LAN

But I am failing to make the changes persistent.

I have tried the link solution, the systemd, and the udev rule one. Every time I reboot things look like:

sudo ethtool enp1s0 | grep Wake-on
    Supports Wake-on: pumbg
    Wake-on: d

Which seems to mean it's disabled.

Especially the systemd thing puzzles me. It appears the systemd script runs before the network interface has been renamed from eth0 to enp1s0.

ago 31 00:27:33 mediacenter systemd[1]: Starting Wake-on-LAN for enp1s0...
ago 31 00:27:33 mediacenter ethtool[373]: netlink error: no device matches name (offset 24)

I haven't been able to get it to apply the ethtool command on reboot. If I set it manually after rebooting, it works:

$ sudo systemctl start wol@enp1s0
$ sudo ethtool enp1s0 | grep Wake-on
    Supports Wake-on: pumbg
    Wake-on: umbg

Ideas?

Hack Saw avatar
tz flag
Have you tried setting up that configuration for eth0 and seeing if it stays through the renaming?
phtm avatar
am flag
Yep, and it did not work.
phtm avatar
am flag
I think what will work is to set the systemd unit to run at the end.
Score:1
fr flag

It appears the systemd script runs before the network interface has been renamed from eth0 to enp1s0.

In that case, make the systemd unit depend on a network interface named enp1s0. This is done by adding Wants= and After= for the corresponding /sys device path – though somewhat confusingly, systemd uses the made-up /sys/subsystem path for this (which was planned to come into existence but never did).

[Unit]
Wants=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

Also, while having the unit in multi-user.target is generally fine, you could make the device itself pull it in:

# Optional
[Install]
WantedBy=sys-subsystem-net-devices-%i.device

An even better method would be to invoke ethtool from a udev rule, as udev rules are processed when the device shows up and no earlier (obviously). In other situations (though not in yours) they also have the advantage that various other software (including systemd) is only notified of the device being "ready" after rule processing has finished.

# /etc/udev/rules.d/20-wol.rules

ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", RUN+="/sbin/ethtool -s %k wol g"

I think what will work is to set the systemd unit to run at the end.

There is no "at the end" in systemd, very deliberately. There are things that approximate it, but those are not what you want.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.