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

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

 



Am 16.02.23 um 11:17 schrieb Lennart Poettering:
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.


This is an interestring thread - I have here an old implementation
of an automount (luks/externaldevice), that also uses udev as follows:

SUBSYSTEM=="block", \
ENV{ID_FS_TYPE}=="crypto_LUKS", \
ENV{DEVTYPE}=="partition", \
ATTR{partition}=="1", \
ENV{ID_SERIAL}==" {{LONGSERIAL}} ", \
ACTION=="add|change", SYMLINK+="backup/usbhd5", \
RUN+="/usr/bin/systemctl start backup@%E{ACTION}"


The actions are handled in the script that the
unit starts, decryption / mounting also. The mount
point is in this case namespaced, that already bothered me.
Maybe I should revised this solution to be future save.
So, ENV{SYSTEMD_WANTS} is the way to go?

--
Leon





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

  Powered by Linux