Apply custom udev rule at boot

I have the following custom udev rule in /etc/udev/rules.d/90-r8169-aspm.rules:

ACTION=="add|change", DRIVER=="r8169", ATTR{link/l1_aspm}="1"

The udev rule seems to work correctly when I use udevadm trigger or soft-remove the network card and then trigger a rescan on the PCI bus. However, on boot, the rule is not applied (causing the system to suck about 1W of useless electricity).

Is there any reason why custom udev rules are not applied at boot? Did I do anything wrong, and how can I fix it?

1 Like
sudo tee /etc/udev/rules.d/00-debug-net.rules << "EOF" > /dev/null
SUBSYSTEM=="net", OPTIONS="log_level=debug"
sudo reboot
journalctl -b -u systemd-udevd.service

I have used SUBSYSTEM=="net|pci" since the udev rule seems to be applied by the PCI subsystem when it works. Approximately at 18:09, I ran udevadm trigger.

1 Like

Try to play with the priority of that rule.
If that doesn’t help, then it might be a timing issue.
You can add some delay before applying the parameters:

If your problem is related to power management, see also:

1 Like

Thank you, it was a timing issue indeed. The driver would not be loaded yet by the time udev considered the rule, and loading the driver resets the attribute to 0. I solved the issue by changing the rule as follows:

ACTION=="add|bind|change", ATTR{vendor}=="0x10ec", ATTR{device}=="0x8168", ATTR{link/l1_aspm}="1"
1 Like