You are not logged in.
Pages: 1
Hoping someone can shed some light on this issue.
I'm writing own udev rule to automatically mount a USB drive used for backing up my system. The below udev rule works fine:
KERNEL=="sdc1", NAME="%k", RUNSYMLINK+="usb_storage"
The problem I'm having now is with the RUN+="<shell script here>"
The script will not execute. Does anyone see something that stands out in my rule?
Offline
Seems there was a copy/paste error there. There is no RUNSYMLINK key.
Regardless of that, you should be aware that it is strongly discouraged to mount things directly from udev rules. You should rather use a storage daemon such as udisks (for stuff that should be owned by the active user) or fstab (for stuff that should be owned by the system). In the latter case you really want systemd in order to handle hotplugging properly though, as initscripts can't do that.
Offline
KERNEL=="sdc1"
That's a terrible way of matching. Use e.g.:
ACTION=="add", KERNEL=="sd*", ATTRS{serial}=="0042597blahblah", SYMLINK+="mydrive%n", RUN+="mount /media/mydrive"
To get the serial, use e.g.:
udevadm info -a --name /dev/sdc1 | grep serial
And of course, there should be an entry in /etc/fstab, e.g.:
/dev/mydrive1 /media/mydrive vfat noauto,noatime,users,flush,gid=100,umask=007
And the mountpoint should already exist:
mkdir -p /media/mydrive
Edit: Another nice udev rule is:
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},flush,utf8,gid=100,umask=002"
Last edited by brebs (2013-05-22 09:48:11)
Offline
Pages: 1