<div dir="ltr"><div></div><div>I'be been having issues lately trying to automatically remount an external USB drive that is mounted at boot from an fstab entry:</div><div>LABEL=data-ssd  /opt/data-ssd  ext4  defaults,nofail,users  0  2</div><div><br></div><div>I'm using systemd 244 and after some investigation I learned about the possibility to launch a systemd unit from a udev rule via ENV{SYSTEMD_WANTS} (see here <a href="https://github.com/systemd/systemd/issues/22589#issuecomment-1047940003">https://github.com/systemd/systemd/issues/22589#issuecomment-1047940003</a> and <a href="https://github.com/systemd/systemd/pull/11373#issuecomment-594014841">https://github.com/systemd/systemd/pull/11373#issuecomment-594014841</a>)</div><div><br></div><div>In particular the second suggestion is exactly what I need, but the only way I could make it work was launching a dummy.service that "Wants" the corresponding mount unit:</div><div><br></div><div>udev rule:</div><div>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"<br></div><div><br></div><div>dummy.service:</div><div>[Unit]<br>Description=Dummy service<br>Wants=opt-data\x2dssd.mount<br><br>[Service]<br>Type=simple<br>ExecStart=/bin/echo "I'm dummy"<br><br>[Install]<br>WantedBy=local-fs.target</div><div><br></div><div>I also tested using ACTION!="remove" in the udev rule, but same result.</div><div><br></div><div>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):<br><br># udevadm info --query=property --path=/sys/class/block/sda1<br>[...]<br>SYSTEMD_WANTS=opt-data\x2dssd.mount<br>[...]<br><br>whereas it disappears if launching the dummy.service first.</div><div><br></div><div>Thanks<br></div></div>