udev rules in /etc/udev/rules.d/ ignored/not-loaded on boot; exec manually OK at shell ?
Lennart Poettering
lennart at poettering.net
Fri Dec 22 14:00:49 UTC 2023
On Fr, 22.12.23 08:25, pgnd (pgnd at dev-mail.net) wrote:
> > "enp5s0" is a predictable name how systemd/udev configures them, not
> > the kernel. When a netif is renamed then this results in a "move"
> > event, not "add" or "bind" or "change".
> >
> > Generally, in the vast majority of cases rules should be written with
> > either a check of ACTION!="remove" or ACTION=="remove" depending on
> > whether they should apply if the device is there, or when it goes
> > away. The important part here is: don't list the many positive
> > actions, but instead only specify the single negative action
> > (i.e. "remove"). That's both more robust and safer for future actions
> > to be added.
>
>
> useful, thx.
>
> but still, with
>
> edit /etc/udev/rules.d/99-test.rules
> - ACTION=="add|bind|change", SUBSYSTEM=="net", KERNEL=="enp5s0", RUN+="/bin/touch /etc/test-touch.txt"
> + ACTION!="remove", SUBSYSTEM=="net", KERNEL=="enp5s0", RUN+="/bin/touch /etc/test-touch.txt"
>
> after boot, nothing done
>
> ls -al /etc/test-touch.txt
> (empty)
You do realize that /etc/ is generally not transferred from the initrd
to the host? If you look into /etc/ from the host, then no files you
created there from the initrd will exist.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list