Mapping /dev/*st0* to fixed names using scsi_id

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

 



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
--
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