Monday, September 22, 2014

udev rule - mount/unmount USB memory stick.

Create "98-usb-mount.rules" file at /lib/udev/rules.d. Add the following rules in the file.

KERNEL=="sd?[0-9]", ACTION=="add", RUN+="/bin/mkdir -p /media/usb", RUN+="/bin/mount -o gid=1000,uid=1000 /dev/%k /media/usb"

KERNEL=="sd?[0-9]", ACTION=="remove", RUN+="/bin/umount  /media/usb", RUN+="/bin/rmdir /media/usb"

No comments: