howto get serial number of a tape drive?
Hi,
I'm trying to make sure that my tape drives get named properly on bootup in my tape library. As far as I can determine, the /lib/udev/scsi_id command requires that you use the SCSI Generic device for the inquiry.
How do I map from /dev/st0 to /dev/sg? within a udev rule so I can pull out the proper serial number?
I've looked at the 60-persistent-storage-tape.rules file, but it doesn't seem to help, or I'm just being dense somewhere?
Here's my /etc/udev/rules.d/10-tape.rules file that I'm working with:
# Sun SCSI DLT7k tape drive - make it /dev/tape by default BUS="scsi", SYSFS{model}="DLT7000",SYSFS{vendor}="SUN",SYMLINK="tape"
# SCSI ATL P1000 Autoloader - make if /dev/changer
BUS="scsi", SYSFS{model}="P1000 6220051",SYSFS{vendor}="ATL",SYMLINK="changer"
#-------------------------------------------------------------------------
# SCSI ATL P1000 DLT 7000 tape drives
# SCSI 2 is drive 0 in library, SerialNumber: 'CX752S1059' (left drive) # SCSI 3 is drive 1 in library, SerialNumber: 'PXB09S0552' (right drive)
# ---------
# Old tape_id script
# ---------
#BUS="scsi", KERNEL="nst[0-9]", PROGRAM="/lib/udev/tape_id %k", RESULT="CX752S1059", SYMLINK="dlt7k-left" #BUS="scsi", KERNEL="nst[0-9]", PROGRAM="/lib/udev/tape_id %k", RESULT="PXB09S0552", SYMLINK="dlt7k-right"
# ---------
# Try using /lib/udev/scsi_id --replace-whitespace --whitelisted # ---------
# SQUANTUM_DLT7000_PXB09S0552
#SUBSYSTEM="scsi_generic", PROGRAM="/lib/udev/scsi_id --replace-whitespace --whitelisted /dev/%k", RESULT="SQUANTUM_DLT7000_CX752S1059", SYMLINK="dlt7k-left"
# Match scsi subsystem tape devices, stuff info into $BSG_DEV
KERNEL="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*", \
SUBSYSTEMS="scsi", KERNELS="[0-9]*:*[0-9]", \
ENV{BSG_DEV}="$root/bsg/$id" # Wait for the $BSG_DEV var to be defined, then run scsi_id on that value
KERNEL="st*[0-9]|nst*[0-9]", ENV{ID_SERIAL}!="?*", \
WAIT_FOR="$env{BSG_DEV}", \
ENV{ID_BUS}="scsi", \
IMPORT{program}="/lib/udev/scsi_id --replace-whitespace --whitelisted --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]",ENV{ID_SERIAL}="SQUANTUM_DLT7000_PXB09S0552", \
SYMLINK+="dlt7k-right-st"
KERNEL="nst*[0-9]",ENV{ID_SERIAL}="SQUANTUM_DLT7000_PXB09S0552", \
SYMLINK+="dlt7k-right-nst" KERNEL="st*[0-9]|nst*[0-9]", \
IMPORT{program}="/lib/udev/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"Any hints on how I make this work better would be appreciated.
Thanks,
John
Quoted 4 lines · John Stoffel
I'm trying to make sure that my tape drives get named properly on bootup in my tape library. Â As far as I can determine, the
/lib/udev/scsi_idcommand requires that you use the SCSI Generic device for the inquiry.
Some tape nodes don't like to be opened, they rewind the tape, that's why they are not used.
Quoted 2 lines
How do I map from
/dev/st0to/dev/sg? within a udev rule so I can pull out the proper serial number?
The old sg stuff willnot work, bsg has the same name as the SCSI LUN and is guaranteed to be there.
Quoted 2 lines
I've looked at the 60-persistent-storage-tape.rules file, but it doesn't seem to help, or I'm just being dense somewhere?
Which udev version? What's missing in /dev/tape/?
Kay
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kay" = Kay Sievers <[email protected]> writes:
Quoted 4 lines · John Stoffel
Quoted 4 lines
I'm trying to make sure that my tape drives get named properly on bootup in my tape library. As far as I can determine, the
/lib/udev/scsi_idcommand requires that you use the SCSI Generic device for the inquiry.
Kay> Some tape nodes don't like to be opened, they rewind the tape, Kay> that's why they are not used.
That's fine, since I can poke at the SG device for the tape drive and get it's serial number. And I think I can write a UDEV rule to do so, if I can figure out how to map a SCSI_TAPE device to it's SCSI_GENERIC device.
Quoted 2 lines
Quoted 2 lines
How do I map from
/dev/st0to/dev/sg? within a udev rule so I can pull out the proper serial number?
Kay> The old sg stuff willnot work, bsg has the same name as the SCSI Kay> LUN and is guaranteed to be there.
So I should be running /lib/udev/scsi_id at the bsg device? Is that device kept in an environment variable?
Quoted 2 lines
Quoted 2 lines
I've looked at the 60-persistent-storage-tape.rules file, but it doesn't seem to help, or I'm just being dense somewhere?
Kay> Which udev version? What's missing in /dev/tape/?
I'm using a Debian testing system running udev 141 right now. Right now in /dev/tape I have:
Quoted 1 line
find
/dev/tape
/dev/tape
/dev/tape/by-path /dev/tape/by-path/pci-0000:00:0d.1-scsi-0:0:2:0-st /dev/tape/by-path/pci-0000:00:0d.1-scsi-0:0:2:0-nst-nst /dev/tape/by-path/pci-0000:00:0d.0-scsi-0:0:3:0-st /dev/tape/by-path/pci-0000:00:0d.0-scsi-0:0:3:0-nst-nst
Do I need to pull out the various #:#:#:# part of the by-path stuff to figure out which device ID I need to query against to get my low level SCSI ID?
Sorry to be asking so many questions, but udev isn't the easiest thing to wrap my brain around for some reason.
Please let me know if I need to provide more details or information.
Thanks,
John
Kay,
Do I need to have
Block layer SG support v4 (EXPERIMENTAL)
enabled on my system to take advantage of all the rules in udev 141 (or newer) these days? That might explain why I'm not having things working as I expect.
I'm running 2.6.29 right now on this server, but I'll put in the new stuff ASAP. I was trying out 2.6.30, but I kept getting hard lockups and didn't have the time to diagnose them on this server since it's my main NFS home server.
I'll turn on this option and recompile my system and see how it works. More details when I get this done.
Thanks,
John
Quoted 8 lines · John Stoffel
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kay" = Kay Sievers <[email protected]> writes:
Quoted 4 lines · John Stoffel
Quoted 4 lines
I'm trying to make sure that my tape drives get named properly on bootup in my tape library. As far as I can determine, the
/lib/udev/scsi_idcommand requires that you use the SCSI Generic device for the inquiry.
Quoted 7 lines
Kay> Some tape nodes don't like to be opened, they rewind the tape, Kay> that's why they are not used.
That's fine, since I can poke at the SG device for the tape drive and get it's serial number. And I think I can write a UDEV rule to do so, if I can figure out how to map a
SCSI_TAPEdevice to it'sSCSI_GENERICdevice.
That can work, but the bsg nodes should just be easier to handle.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
How do I map from
/dev/st0to/dev/sg? within a udev rule so I can pull out the proper serial number?Kay> The old sg stuff willnot work, bsg has the same name as the SCSI Kay> LUN and is guaranteed to be there.
So I should be running
/lib/udev/scsi_idat the bsg device? Is that device kept in an environment variable?
That's what the rules do, yes.
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
I've looked at the 60-persistent-storage-tape.rules file, but it doesn't seem to help, or I'm just being dense somewhere?
Kay> Which udev version? What's missing in
/dev/tape/?I'm using a Debian testing system running udev 141 right now. Right now in
/dev/tapeI have:
Sounds fine.
Quoted 11 lines
> find
/dev/tape
/dev/tape
/dev/tape/by-path /dev/tape/by-path/pci-0000:00:0d.1-scsi-0:0:2:0-st /dev/tape/by-path/pci-0000:00:0d.1-scsi-0:0:2:0-nst-nst /dev/tape/by-path/pci-0000:00:0d.0-scsi-0:0:3:0-st /dev/tape/by-path/pci-0000:00:0d.0-scsi-0:0:3:0-nst-nstDo I need to pull out the various #:#:#:# part of the by-path stuff to figure out which device ID I need to query against to get my low level SCSI ID?
No, they are the path to the device, not the serial number stuff. That would be in by-id/.
Quoted 2 lines
Sorry to be asking so many questions, but udev isn't the easiest thing to wrap my brain around for some reason.
No problem, just keep asking. :)\
Kay
Quoted 7 lines · John Stoffel
Do I need to have
Block layer SG support v4 (EXPERIMENTAL)
enabled on my system to take advantage of all the rules in udev 141 (or newer) these days? That might explain why I'm not having things working as I expect.
Yes, that's what we use since a while.
Kay
Quoted 7 lines · John Stoffel
Quoted 7 lines
Do I need to have
Block layer SG support v4 (EXPERIMENTAL)
enabled on my system to take advantage of all the rules in udev 141 (or newer) these days? That might explain why I'm not having things working as I expect.
Kay> Yes, that's what we use since a while.
Is it still considered experimental? We should submit a patch to Linus to change the Kconfig entry to reflect that Udev since version 1XX (?) wants to use this feature. And we should also mention this prominently in the Udev docs as well.
Do you need me to spin up a doc patch for Udev on this?
John
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"John" = John Stoffel <[email protected]> writes:
Quoted 7 lines · John Stoffel
Quoted 7 lines
Quoted 7 lines
Do I need to have
Block layer SG support v4 (EXPERIMENTAL)
enabled on my system to take advantage of all the rules in udev 141 (or newer) these days? That might explain why I'm not having things working as I expect.
Kay> Yes, that's what we use since a while.
John> Is it still considered experimental? We should submit a patch John> to Linus to change the Kconfig entry to reflect that Udev since John> version 1XX (?) wants to use this feature. And we should also John> mention this prominently in the Udev docs as well.
John> Do you need me to spin up a doc patch for Udev on this?
Heh, this seems to have done the trick now, I get my devices properly created on reboot.
I think someone needs to put in a patch to Linus to get the experimental label removed, and the default changed to Y now.
John
Quoted 6 lines · John Stoffel
John> Is it still considered experimental? We should submit a patch John> to Linus to change the
Kconfigentry to reflect that Udev since John> version 1XX (?) wants to use this feature. And we should also John> mention this prominently in the Udev docs as well.John> Do you need me to spin up a doc patch for Udev on this?
Added to the README.
Quoted 2 lines
Heh, this seems to have done the trick now, I get my devices properly created on reboot.
Great.
Thanks,
Kay
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kay" = Kay Sievers <[email protected]> writes:
Kay> On Tue, Jul 7, 2009 at 05:12, John Stoffel<[email protected]> wrote:
John> Is it still considered experimental? We should submit a patch John> to Linus to change the Kconfig entry to reflect that Udev since John> version 1XX (?) wants to use this feature. And we should also John> mention this prominently in the Udev docs as well.
Quoted 1 line
Quoted 1 line
John> Do you need me to spin up a doc patch for Udev on this?
Kay> Added to the README.
Thanks!
Quoted 2 lines
Quoted 2 lines
Heh, this seems to have done the trick now, I get my devices properly created on reboot.
Kay> Great.
And I've submitted a patch to the BSG Kconfig entry to remove it from experimental status and to make it be turned on by default in the future.
I'm actually thinking that we should just include it no matter what in another release or two, without the option to turn it off since it's so core a feature.
We'll see how my patch flies, it might even make it into 2.6.31-rc3 if we're lucky.
John