* UDEV Rule for usb/firewire removable storage media
@ 2010-01-21 10:27 Roger
0 siblings, 0 replies; only message in thread
From: Roger @ 2010-01-21 10:27 UTC (permalink / raw)
To: linux-hotplug
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,gid\x100,umask\02"
# 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-01-21 10:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-21 10:27 UDEV Rule for usb/firewire removable storage media Roger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).