1

I'd like to create a service that triggers on certain mounts. Right now I have

[Unit]
Description=Triggers after usb storage device is mounted
RequiresMountsFor=/media/sda1

[Service]
ExecStart=/path/to/script.sh

[Install]
WantedBy=media-sda1.mount

But I'd like something like RequiresMountsFor=/media/sd[ab][1-9]+, i.e. match sda1, sda2, ... as well as sdb1, sdb2, ...

Is this possible?

1 Answer 1

2

No.

The value of RequiresMountsFor takes a space-delimited list of absolute paths, but not an expression:

RequiresMountsFor=

Takes a space-separated list of absolute paths. Automatically adds dependencies of type Requires= and After= for all mount units required to access the specified path.

Mount points marked with noauto are not mounted automatically through local-fs.target, but are still honored for the purposes of this option, i.e. they will be pulled in by this unit.

Reference: https://www.freedesktop.org/software/systemd/man/systemd.unit.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .