2

So I am trying to create a udev rule to automatically mount a drives exfat partition to /media/offsite. My goal is to automatically mount a drive to /media/offsite and then kick off a .sh script to copy files around. I have been reading many guides and have learned a lot, but I am still getting stuck. Many of the guides are very outdated and apply to USB drives where as I have a docked drive.

Just to see if a rule would trigger, I created this rule in /etc/udev/rules.d/80-external-disk.rules:

ACTION=="add", ENV{DEVTYPE}=="partition", ENV{ID_FS_UUID}=="5359-818E", RUN+="/bin/mount -t exfat -U $env{ID_FS_UUID}"

I reloaded rules, rebooted server, few other things, and it appeared the rule wasn't firing.

udevadm test $(udevadm info -q path -n /dev/sdb) 2>&1 | grep /etc/udev/rules.d

That only produces the following;

parse_file: reading '/etc/udev/rules.d/70-persistent-cd.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-net.rules' as rules file
parse_file: reading '/etc/udev/rules.d/80-external-disk.rules' as rules file

My thought is that the UUID belongs to the partition and not the drive. With the partition being an exfat, can UDEV even see that UUID?

2
  • With some help from Jordan_U in IRC, I have determined the disk does show up in /dev/disk/5359-818E. Its just not getting that rule applied to it.
    – MLindsay
    May 15, 2014 at 20:22
  • Check pluging the disk while running sudo udevadm monitor -u in terminal.
    – user.dz
    Apr 3, 2018 at 10:41

1 Answer 1

0

mount is not allowed in the late releases of udev. Better to go with udisks if you are using Gnome/Unity or any other alternative for other DE.

man udev

RUN

Note that running programs that access the network or mount/unmount filesystems is not allowed inside of udev rules, due to the default sandbox that is enforced on systemd-udevd.service.

You must log in to answer this question.

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