Re: Launch a mount unit from udev rule via ENV{SYSTEMD_WANTS}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mi, 15.02.23 17:59, Jacopo (fingolfin00@xxxxxxxxx) 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



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux