All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger <rogerx@sdf.lonestar.org>
To: linux-hotplug@vger.kernel.org
Subject: UDEV Rule for usb/firewire removable storage media
Date: Thu, 21 Jan 2010 10:27:16 +0000	[thread overview]
Message-ID: <1264069636.11735.5.camel@localhost2.local> (raw)

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


                 reply	other threads:[~2010-01-21 10:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1264069636.11735.5.camel@localhost2.local \
    --to=rogerx@sdf.lonestar.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.