[systemd-devel] Launch a mount unit from udev rule via ENV{SYSTEMD_WANTS}
Lennart Poettering
lennart at poettering.net
Thu Feb 16 10:17:15 UTC 2023
On Mi, 15.02.23 17:59, Jacopo (fingolfin00 at gmail.com) wrote:
> udev rule:
> ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd*", SUBSYSTEMS=="usb",
> ENV{DEVTYPE}=="partition", IMPORT{builtin}="blkid",
> ENV{ID_FS_TYPE}=="ext4", ENV{ID_FS_LABEL_ENC}=="data-ssd",
> ENV{SYSTEMD_WANTS}+="dummy.service"
Matching against "add" is almost certainly wrong, as devices typically
see "change" and other events throughout their early lifetime, and in
that case any settings you make here would get very quickly lost.
In almost all cases you want a check like ACTION!="remove" instead
which matches all "positive" events and ignores the only negative
event.
> As I mentioned in the github issue before being redirected here, if I query
> with udevadm, ENV{SYSTEMD_WANTS} is printed out only with in the
> non-working case (.mount unit launched directly from the udev rule):
>
> # udevadm info --query=property --path=/sys/class/block/sda1
> [...]
> SYSTEMD_WANTS=opt-data\x2dssd.mount
> [...]
>
This is almost certainly an escaping issue. What's the precisely rule
you are using? It's generally a good idea to start with the line that
doesn't work, not the one that works.
Also, 244 is ancient 4y old stuff. Consider updating.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list