Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 4056

General Questions • Re: Automount external HDD when pluggedin

$
0
0

@luckyluca, apologies, as I've just discovered, it's not that trivial indeed because of the F-in systemd, which tends to break more and more parts of the system. I promise myself I will migrate to Devuan next month every month, but of course lack of time (read: my laziness) tends to stand in my way also every month ;-]
In this case you cannot mount anything from a script in a RUN expression, instead you need to remove your drive form /etc/fstab and create a freakin systemd.mount unit named after after your mount point. So in your case /etc/systemd/system/mnt-wd_black.mount:

Code:

[Unit]Description=My WD Black USB DriveAfter=local-fs.target[Mount]What=/dev/YOUR-PARTITION-DEVICE-FILE-OR-UUID-LINK ## replace meWhere=/mnt/wd_blackType=ntfs-3gOptions=noatime

Then the udev rule should tell the moron that he wants this mount unit:

Code:

ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1058", ATTR{idProduct}=="25a2", TAG+="systemd", ENV{SYSTEMD_WANTS}+="mnt-wd_black.mount"

Now to umount the drive you need to do systemctl stop mnt-wd_black.mount...

BTW: instead of USB IDs, it would be better to use the partition's UUID as well in the rules, but I couldn't make it work: rules of the form

Code:

ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_UUID}=="8eb7ceff-5601-42f0-8916-04fad4933979", TAG+="systemd", ENV{SYSTEMD_WANTS}+="mnt-wdroot.mount"

or

Code:

ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_UUID_ENC}=="8eb7ceff-5601-42f0-8916-04fad4933979", TAG+="systemd", ENV{SYSTEMD_WANTS}+="mnt-wdroot.mount"

just didn't fire for me despite the matching UUID:

Code:

$ udevadm info /dev/sda2 |grep ID_FS_UUIDE: ID_FS_UUID=8eb7ceff-5601-42f0-8916-04fad4933979E: ID_FS_UUID_ENC=8eb7ceff-5601-42f0-8916-04fad4933979

If anyone knows what I'm doing wrong, please help :)

UPDATE:
NVM, found it: https://bbs.archlinux.org/viewtopic.php ... 1#p1283621
It's really silly IMO ;-] Anyway, use UUID-based rules, but the filename containing it must start with a number >60...

Statistics: Posted by morgwai — 2026-01-26 21:06



Viewing all articles
Browse latest Browse all 4056

Trending Articles