* persistent SCSI tape names
@ 2007-01-29 19:34 Jamie Wellnitz
0 siblings, 0 replies; only message in thread
From: Jamie Wellnitz @ 2007-01-29 19:34 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 2167 bytes --]
Hi,
I'm trying to add persistent SCSI tape names to the
etc/udev/redhat/50-udev.rules file. The easiest implementation seems
to be something like:
diff --git a/etc/udev/redhat/50-udev.rules b/etc/udev/redhat/50-udev.rules
index d72cb83..b7e7cc6 100644
--- a/etc/udev/redhat/50-udev.rules
+++ b/etc/udev/redhat/50-udev.rules
@@ -109,6 +109,17 @@ KERNEL=="nst*", GROUP="disk", MODE="0660"
KERNEL=="osst*", GROUP="disk", MODE="0660"
KERNEL=="nosst*", GROUP="disk", MODE="0660"
+ACTION!="add", GOTO="persistent_tape_end"
+
+KERNEL=="nst[0-9]", BUS=="scsi", ENV{ID_SERIAL}=="", IMPORT{program}="/lib/udev/scsi_id -g -x -s %p -d $tempnode"
+KERNEL=="nst[0-9]", BUS=="scsi", ENV{ID_SERIAL}=="?*", SYMLINK+="tapes/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
+
+# type 8 devices are "Medium Changers"
+KERNEL=="sg*", BUS=="scsi", SYSFS{type}=="8", ENV{ID_SERIAL}=="", IMPORT{program}="/lib/udev/scsi_id -g -x -s %p -d $tempnode"
+KERNEL=="sg*", BUS=="scsi", SYSFS{type}=="8", ENV{ID_SERIAL}=="?*", SYMLINK+="tapes/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
+
+LABEL="persistent_tape_end"
+
# diskonkey devices
KERNEL=="diskonkey*", GROUP="disk", MODE="0640"
However this only supports 1 of the 8 names each tape device is
assigned (e.g. st0, st0a, st0l, st0m, nst0, nst0a, nst0l, nst0m).
To provide a persistent name for each of the 8 names, I have to resort
to having the udev rule invoke a shell script (called tape-names.sh -
attached). The script handles 2 issues:
1. the device names ending in [alm] apparently do not support the page
0x83 inquiry to get a persistent ID, and
2. if udev sends multiple inquiries to a device at the same time, only
one of them gets a response.
The script is invoked by these rules:
KERNEL=="st*", BUS=="scsi", PROGRAM="/etc/udev/scripts/tape-name.sh %k", SYMLINK+="tapes/by-id/%c"
KERNEL=="nst*", BUS=="scsi", PROGRAM="/etc/udev/scripts/tape-name.sh %k", SYMLINK+="tapes/by-id/%c"
Is it better to use the simple naming method (and provide persistence
for only one set of tape names) or to have a script bashing away with
retry logic?
Thanks,
Jamie
Jamie.Wellnitz@emulex.com
[-- Attachment #2: tape-name.sh --]
[-- Type: text/plain, Size: 935 bytes --]
#!/bin/bash
# this script is intended to be called by udev to provide a unique
# persistent name for SCSI tape devices
#LOG=/etc/udev/tape-name.log
function log_text {
if [ -n "$LOG" ] ; then
echo "$*" >> $LOG
fi
}
SCSI_ID="/lib/udev/scsi_id -g -u"
DEVICE=$1
SYSFS_TOP=/class/scsi_tape
PREFIX=${DEVICE%%st*}
SUFFIX=${DEVICE##${PREFIX}st[0-9]}
# remove prefix and suffix from device name
BASE_DEVICE=${DEVICE#${PREFIX}}
BASE_DEVICE=${BASE_DEVICE%${SUFFIX}}
SYSFS=$SYSFS_TOP/$BASE_DEVICE
retries=7
ID=$($SCSI_ID -s $SYSFS)
while [ $? -ne 0 -a $retries -gt 0 ] ; do
((retries--))
if [ $retries -gt 0 ] ; then
log_text "$SCSI_ID failed for $DEVICE, retries left $retries"
sleep 2
ID=$($SCSI_ID -s $SYSFS)
else
log_text "$SCSI_ID failed for $DEVICE, retries exhausted"
fi
done
log_text "For $DEVICE Using $BASE_DEVICE, id $ID"
# this echo produces the device's persistent name
echo "$PREFIX$ID$SUFFIX"
[-- Attachment #3: Type: text/plain, Size: 347 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-01-29 19:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-29 19:34 persistent SCSI tape names Jamie Wellnitz
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).