My goal: when I connect a certain USB harddisk, mount it and run a bash script.
To reach this goal, I have this in my fstab for this disk:
fstab:
UUID=76c6c02b-231d-4e0b-ac7a-5744175562ae /media/usbarchive btrfs defaults,noatime,noauto,compress-force=zstd:5,x-systemd.automount,x-system.idle-timeout="10min" 0 0
When I do sudo mount -a
, this disk is not mounted, which is correct since it has noauto
.
A systemd service file I created:
/etc/systemd/system/btrbk-usbarchive.service
[Unit]
Description=Run btrbk for usbarchive
Requires=media-usbarchive.mount
After=media-usbarchive.mount
[Service]
ExecStart=/home/asterix/docker/HOST/btrbk/archive-mail.sh
Type=forking
[Install]
WantedBy=media-usbarchive.mount
a udev rule I created: /etc/udev/rules.d/99-btrbk.rules
SUBSYSTEM=="block", ENV{ID_TYPE}=="disk", ENV{ID_FS_UUID}=="76c6c02b-231d-4e0b-ac7a-5744175562ae", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}="btrbk-usbarchive.service"
It works: when I connect the disk via USB, it is mounted to /media/usbarchive
and the script is launched!
But Nemo File Manager has issues: I can’t launch it, it takes 2 minutes to launch. Syslog shows Nemo is constantly trying to mount /media/usbarchive
even though the disk is not connected!
Nemo should not even be triggering the mount in fstab, since I use noauto
. Note I use noauto
for 3 other disks: Nemo leaves them alone even though they are unmounted internal SATA disks. Nemo shows these 3 disks under “Devices” but without eject button.
How can I make sure Nemo stays away from this disk, especially when the disk is not connected?
EDIT:
commenting out the line in fstab + rebooting makes Nemo start normally again. When uncommenting the line + sudo mount -a
, Nemo still launches normally and I see usbarchive
under devices without eject button (the disk is not connected). It goes wrong when I reboot. Then I can start Nemo and wait for almost 2 minutes for it to launch and it still behaves slow.