From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roger Date: Thu, 21 Jan 2010 10:27:16 +0000 Subject: UDEV Rule for usb/firewire removable storage media Message-Id: <1264069636.11735.5.camel@localhost2.local> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org I'm trying to create a udev rule to simulate gnome-volume-manager as I'm straying away from Gnome with using a slimmer desktop (DWM). Here's what I have so far that works. (Notice, I snipped some of this from archlinux. ;-) Any ideas, cleanup suggestions or pointers?? --- Begin UDEV Rule --- KERNEL!="sd[c-z][0-9]", GOTO="media_by_label_auto_mount_end" # left out sda and sdb devices because those are my system hard drives & not removable!!! # Any better ideas?? # UDEV Add/Mount Section # # Global mount options ACTION="add", ENV{mount_options}="relatime,users" # Filesystem specific options ACTION="add", PROGRAM="/sbin/blkid -o udev -s LABEL /dev/%k", RESULT="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid0,umask2" # Find folder partition label or folder usb id name ACTION="add", PROGRAM="/sbin/blkid -o udev -s LABEL /dev/%k", ENV{dir_name}="$env{ID_FS_LABEL}" ACTION="add", PROGRAM!="/sbin/blkid -o udev -s LABEL /dev/%k", ENV{dir_name}="usbhd-%k" # Mount the device # Uncomment to send debug notice to logger #ACTION="add", RUN+="/usr/bin/logger Adding sd device file" ACTION="add", RUN+="/bin/mkdir -p /media/$env{ID_FS_LABEL}", RUN +="/bin/mount -o $env{mount_options} /dev/%k /media/$env{ID_FS_LABEL}" # UDEV Remove/Unmount Section # # Uncomment to send debug notice to logger #ACTION="remove", ENV{dir_name}="?*", RUN+="/usr/bin/logger Removing and umounting sd device file" # Find folder partition label or folder usb id name ACTION="remove", PROGRAM="/sbin/blkid -o udev -s LABEL /dev/%k", ENV{dir_name}="$env{ID_FS_LABEL}" ACTION="remove", PROGRAM!="/sbin/blkid -o udev -s LABEL /dev/%k", ENV{dir_name}="usbhd-%k" # Umount the device ACTION="remove", ENV{dir_name}="?*", RUN+="/bin/umount -l /media/% E{dir_name}", RUN+="rmdir /media/%E{dir_name}" LABEL="media_by_label_auto_mount_end" --- End of UDEV Rule --- -- Roger http://rogerx.freeshell.org