Hello, On Tue, 07 Apr 2009, varadarajan narayanan wrote: > automount.rules in /etc/udev/rules.d > > KERNEL=="sd[a-z]", NAME="%k", SYMLINK+="usb%m", OPTIONS="last_rule" > ACTION=="add", KERNEL=="sd[a-z][0-9]", SYMLINK+="usb%n", NAME="%k" > ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mkdir -p /media/usb%n" > ACTION=="add", KERNEL=="sd[a-z][0-9]", RUN+="/bin/mount -t auto -o > rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /media/usb%n", > OPTIONS="last_rule" > ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/umount -l /media/usb%n" > ACTION=="remove", KERNEL=="sd[a-z][0-9]", RUN+="/bin/rmdir /media/usb%n", > OPTIONS="last_rule" > > And works like a charm !
I am not sure that this is a correct solution. 1. The "remove" rule will be applied after the device is removed. How will the "umount" work in that case? Looks like a recipe for data-loss! 2. The "udev" rules are (IMHO) not the proper place to implement mount and unmount rules. 3. One solution is to use automount daemons like autofs or autofs5 or afuse. This will also auto-unmount after a time delay (i.e. some period when the drive is unused) which is configurable. 4. Even if you do use "udev" to mount, you need to implement umount differently. For example, GNOME and KDE require that the user *requests* the unmounting of the device; you could do the same. Regards, Kapil. -- _______________________________________________ To unsubscribe, email [email protected] with "unsubscribe <password> <address>" in the subject or body of the message. http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
