UDEV Rule for usb/firewire removable storage media

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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=100,umask=002"

# 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

--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux