You are not logged in.

#1 2008-11-25 18:37:51

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Udev rules to auto-mnt/unmnt usb drives - if/then and use of labels?

Hi All,

i've been using the udev auto-mounting approach outlined in the udev wiki for auto-mounting/un-mounting my USB drives.  i have 1-2 drives that are rarely disconnected, 2-3 that i hook up fairly often, then still 4 or 5 more little flash drives i use interchangeably.  i want to adjust my udev rules to accommodate all of these scenarios and any combination there of. 

as of right now; any usb drive i hot-plug will mount on /media/usb_sdXX where XX is b1, c1, d1, e1, etc.  i want any random flash drive i may be using to continue in this scheme.  this rule as it is today acts on all kernel sd[b-z][0-9] (because my fixed internal drive is sda).

what i plan to do is give some of my drives labels (quick/easy with e2label or tune2fs), after that i want my udev rule to do this:

     if: drive has a label, then: mount to /media/LABEL

     else: mount to /media/usb_sdXX (i.e. run my current rule as-is)

while still preserving the nice auto mkdir/rmdir feature i have now.

is this possible, appropriate?

i appreciate any help.

edit: my current udev-usb rules file here

Last edited by brisbin33 (2008-11-25 19:17:12)

Offline

#2 2008-11-25 23:03:07

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Udev rules to auto-mnt/unmnt usb drives - if/then and use of labels?

Actually, I was planning on doing something similar. It might be easiest to make your own "mountusb" script that will take a device path as an argument, and mount it appropriately in /media/. Then just latch it into your udev rule instead of using mount.

Offline

#3 2008-11-25 23:18:44

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Udev rules to auto-mnt/unmnt usb drives - if/then and use of labels?

that's not a bad idea at all actually.  i'm also considering moving everything to an internal+fstab approach (microcenter's got cheap 1TB drives) and keep those rules as-is just for random usb keys.  i'd be interested though if you do come up with a script; i'll post mine if i do it too.

Offline

Board footer

Powered by FluxBB