[NCLUG] Help w/udev rules

Maxwell Spangler maxlists at maxwellspangler.com
Tue Sep 24 13:34:41 MDT 2013


On Tue, 2013-09-24 at 00:30 -0600, Stephen Warren wrote: 

> On 09/24/2013 12:21 AM, Maxwell Spangler wrote:
> > On a backup server I have two external USB docks.  I'm writing scripts
> > so a user can install new offsite backup drives and tell the computer to
> > make them available to receive backups.  Another script will copy the
> > appropriate backup files to the drives.  For the backup script to work
> > consistently, I want to present the removable storage in a predictable
> > manner.
> > ...
> 
> This perhaps isn't an answer to your question, but I would instead
> propose using partition or filesystem UUIDs to identify the block
> devices, rather than attempting to make each device have a fixed name.


Thanks to several posters who suggested the same: using filesystem
labels and accessing offsite backup drives using device mapper entries
in /dev/.

However, I think using udev is the right approach for a couple of
reasons.

* I have two docks and they are not identical: one is slow USB2 and one
is fast USB3.  I want the comfort and easy of being able to "quickly"
copy 600G to the USB3 drive by mounting whatever drive is
in /dev/usb3dock and knowing I'm using the faster dock.

* All my drives will be labeled properly as offsite backup drives but I
can't predict in which dock they will appear.  So a 2TB drive that
yesterday was in the USB3 dock might get moved by someone on site (other
than me) to the USB2 dock.  If I don't check, I might start using the
slow dock, show up on site to collect it only to discover it has hours
of copying left to complete.

* If I do recognize a drive by filesystem label and want to walk the
chain of tools to discover where it is I think I'll be doing the same
amount of effort I've done with udev.

When I stopped working on this late last night it appeared as though my
udev solution was working perfectly and the only confusing thing was the
debugging information in my script that scans for partitions on new
devices.  When a udev event is triggered for /dev/sdf (one of my docks)
it creates the /dev/usb3dock symlink I want, triggers my script to run,
and then triggers 5 more udev events as partitions are found and
additional /dev entries are made.  If I remove the debugging and ignore
what's going on behind the scenes everything.. just works.

Thanks for the input. If anyone has other ideas, please share.  I'm not
a big fan of re-inventing the wheel.
-- 
Maxwell Spangler
========================================================================
Linux System Administration / Virtualization / Development / Computing
Services
Photography / Graphics Design / Writing
Fort Collins, Colorado
http://www.maxwellspangler.com


More information about the NCLUG mailing list