udev

Automount usb stick

File /etc/udev/rules.d/99-automount.rules

   1 ACTION=="add",KERNEL=="sd[b-z]", PROGRAM="automount"
   2 ACTION=="remove",KERNEL=="sd[b-z]", PROGRAM="automount"

File /lib/udev/automount with chmod 755:

   1 #!/bin/bash
   2 PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
   3 
   4 DEV=$(basename $DEVNAME)
   5 
   6 echo "$DEV $ACTION" >> /tmp/env.txt
   7 
   8 case $ACTION in
   9 add) mkdir -p /mnt/memory/$DEV
  10      logger "automount: $ACTION $DEV"
  11      mount -ouser,umask=0000 /dev/$DEV /mnt/memory/$DEV
  12   ;;
  13 remove) 
  14      logger "automount: $ACTION $DEV"
  15      umount /mnt/memory/$DEV
  16 ;;
  17 esac

udev (last edited 2014-01-13 18:31:17 by bl14-186-78)