I setup a rule in udev to run a script in background to automount the USB drive. It managed to run the script fine, but the mounting is failing for some reason.
RULE:
ACTION=="add", KERNEL=="sd[a-z]*", RUN+="/etc/mntUsbChk.sh &" In this script:
#!/bin/sh sleep 2 mkdir /mnt/usb foundUsb=false if [ -e /dev/sda1 ]; then mount /dev/sda1 /mnt/usb $foundUsb=true fi if [ -e /dev/sdb1 ]; then mount /dev/sdb1 /mnt/usb $foundUsb=true fi if [ -e /dev/sdc1 ]; then mount /dev/sdc1 /mnt/usb $foundUsb=true fi if [ $foundUsb -eq false ]; then exit fi echo "USB MOUNTED" [ 1610.868626] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
EDIT: More details: The script was being executed for sure because the /mnt/usb folder was created after I plugged in the USB.
And also, if I manually type mount /dev/sda1 /mnt/usb after I plug in USB before I enable the rule, it was able to mount it just fine. I just don't get it why it cannot mount in the rules udev.