I'm trying to automount a USB device upon plugin but it refuses to mount. I set a rule to execute the following script :
#!/bin/bash
mkdir /media/mnt
echo AFTER MKDIR > /home/output
sleep 5
echo AFTER SLEEP >> /home/output
mount /dev/sdb1 /media/mnt
echo $? >> /home/output
echo AFTER MOUNT >> /home/output
The script gets executed nicely, lsblk
shows that /dev/sdb1
is present, output
contain all the echoes, yet sdb1
won't be mounted in /media/mnt
. The mount command exit code is 0
When I execute the mount command in that script manually after the USB device is plugged in it mounts it without problem.
root
? Perhaps adding a line in your script to validate the effective UID might be a good idea:id >> /home/output
– Julie Pelletier Jul 31 '16 at 18:10/etc/udev/rules.d
both the script and the rule where made by root. id returns root – ChiseledAbs Jul 31 '16 at 18:30