linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "John Stoffel" <john@stoffel.org>
To: linux-hotplug@vger.kernel.org
Subject: Mapping /dev/*st0* to fixed names using scsi_id
Date: Wed, 03 Jun 2009 19:45:32 +0000	[thread overview]
Message-ID: <18982.53980.652743.304603@stoffel.org> (raw)


Hi all,

I've been pounding my head against this issue for a while, and cursing
the lack of comments in the example rules for udev.  Basically, I've
got a tape library with two drives and a robot on a Debian system,
with a bunch of SCSI devices including disks and tapes.  The robot is
easy, I just use the following snippet:

    # SCSI ATL P1000 Autoloader - make if /dev/changer
    BUS="scsi", SYSFS{model}="P1000     6220051",SYSFS{vendor}="ATL",SYMLINK="changer"

And it works fine.  Now I want to map the two tape drives to some
fixed names:

    /dev/nst?a  -> /dev/dlt7k-{left,right}

easily.  I used to do this with the script I posted way back in 2008
to list this, found at:

    http://article.gmane.org/gmane.linux.hotplug.devel/12579

But I never followed up on it.  Lately, it's been taking multiple
invocations of 'udevadm trigger' after each reboot to make my tape
devices show up properly.  So now I'm trying to figure out what I can
do.

Right now, I've got a rule which looks like this, which works, but
maps to /dev/sg# instead of the proper /dev/nst#a device:

    SUBSYSTEM="scsi_generic", PROGRAM="/lib/udev/scsi_id --replace-whitespace --whitelisted /dev/%k",RESULT="SQUANTUM_DLT7000_CX752S1059", SYMLINK="dlt7k-left"

I've looked at the /lib/udev/rules.d/60-persistent-storage-tape.rules
but I honestly can't make heads or tails of the ${DEV_BSG} stuff,
since it's not documented to explan what's really going on here.

I think I need to add the --whitelisted arg to the scsi_id command to
make this section work properly:

    KERNEL="st*[0-9]|nst*[0-9]",           ENV{ID_SERIAL}!="?*", \
	    SUBSYSTEMS="scsi", KERNELS="[0-9]*:*[0-9]", \
	    ENV{BSG_DEV}="$root/bsg/$id"
    KERNEL="st*[0-9]|nst*[0-9]",           ENV{ID_SERIAL}!="?*", \
	    WAIT_FOR="$env{BSG_DEV}", \
	    ENV{ID_BUS}="scsi", \
	    IMPORT{program}="scsi_id --export --device=$env{BSG_DEV}"

    KERNEL="st*[0-9]|nst*[0-9]",           ENV{ID_SERIAL}="?*", \
	    SYMLINK+="tape/by-id/$env{ID_BUS}-$env{ID_SERIAL}"

    KERNEL="st*[0-9]|nst*[0-9]", \
	    IMPORT{program}="path_id $devpath"
    KERNEL="st*[0-9]",                     ENV{ID_PATH}="?*", \
	    SYMLINK+="tape/by-path/$env{ID_PATH}"
    KERNEL="nst*[0-9]",                    ENV{ID_PATH}="?*", \
	    SYMLINK+="tape/by-path/$env{ID_PATH}-nst"

But the path_id script called here is poorly documented and hard to
follow.  Sorry for sounding whiny, but it's a pain to figure out
without well documented examples.

Can anyone point me in the right direction here?  

Thanks,
John

             reply	other threads:[~2009-06-03 19:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-03 19:45 John Stoffel [this message]
2009-06-04 21:03 ` Mapping /dev/*st0* to fixed names using scsi_id John Stoffel
2009-06-07 10:04 ` John Huttley
2009-06-09 15:27 ` John Stoffel

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=18982.53980.652743.304603@stoffel.org \
    --to=john@stoffel.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 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).