linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* howto get serial number of a tape drive?
@ 2009-07-06 15:58 John Stoffel
  2009-07-06 16:09 ` Kay Sievers
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: John Stoffel @ 2009-07-06 15:58 UTC (permalink / raw)
  To: linux-hotplug


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
@ 2009-07-06 16:09 ` Kay Sievers
  2009-07-06 18:22 ` John Stoffel
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2009-07-06 16:09 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Jul 6, 2009 at 17:58, John Stoffel<john@stoffel.org> wrote:
> 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.

Some tape nodes don't like to be opened, they rewind the tape, that's
why they are not used.

> How do I map from /dev/st0 to /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.

> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
  2009-07-06 16:09 ` Kay Sievers
@ 2009-07-06 18:22 ` John Stoffel
  2009-07-06 19:56 ` John Stoffel
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: John Stoffel @ 2009-07-06 18:22 UTC (permalink / raw)
  To: linux-hotplug

>>>>> "Kay" = Kay Sievers <kay.sievers@vrfy.org> writes:

Kay> On Mon, Jul 6, 2009 at 17:58, John Stoffel<john@stoffel.org> wrote:
>> 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.

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. 

>> How do I map from /dev/st0 to /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?  

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

  > 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
  2009-07-06 16:09 ` Kay Sievers
  2009-07-06 18:22 ` John Stoffel
@ 2009-07-06 19:56 ` John Stoffel
  2009-07-06 23:00 ` Kay Sievers
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: John Stoffel @ 2009-07-06 19:56 UTC (permalink / raw)
  To: linux-hotplug


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



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
                   ` (2 preceding siblings ...)
  2009-07-06 19:56 ` John Stoffel
@ 2009-07-06 23:00 ` Kay Sievers
  2009-07-06 23:02 ` Kay Sievers
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2009-07-06 23:00 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Jul 6, 2009 at 20:22, John Stoffel<john@stoffel.org> wrote:
>>>>>> "Kay" = Kay Sievers <kay.sievers@vrfy.org> writes:
>
> Kay> On Mon, Jul 6, 2009 at 17:58, John Stoffel<john@stoffel.org> wrote:
>>> 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.
>
> 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.

That can work, but the bsg nodes should just be easier to handle.

>>> How do I map from /dev/st0 to /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?

That's what the rules do, yes.

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

Sounds fine.

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

No, they are the path to the device, not the serial number stuff. That
would be in by-id/.

> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
                   ` (3 preceding siblings ...)
  2009-07-06 23:00 ` Kay Sievers
@ 2009-07-06 23:02 ` Kay Sievers
  2009-07-07  1:08 ` John Stoffel
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2009-07-06 23:02 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Jul 6, 2009 at 21:56, John Stoffel<john@stoffel.org> wrote:
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
                   ` (4 preceding siblings ...)
  2009-07-06 23:02 ` Kay Sievers
@ 2009-07-07  1:08 ` John Stoffel
  2009-07-07  3:12 ` John Stoffel
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: John Stoffel @ 2009-07-07  1:08 UTC (permalink / raw)
  To: linux-hotplug


Kay> On Mon, Jul 6, 2009 at 21:56, John Stoffel<john@stoffel.org> wrote:
>> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
                   ` (5 preceding siblings ...)
  2009-07-07  1:08 ` John Stoffel
@ 2009-07-07  3:12 ` John Stoffel
  2009-07-07  7:50 ` Kay Sievers
  2009-07-07 19:34 ` John Stoffel
  8 siblings, 0 replies; 10+ messages in thread
From: John Stoffel @ 2009-07-07  3:12 UTC (permalink / raw)
  To: linux-hotplug

>>>>> "John" = John Stoffel <john@stoffel.org> writes:

Kay> On Mon, Jul 6, 2009 at 21:56, John Stoffel<john@stoffel.org> wrote:
>>> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
                   ` (6 preceding siblings ...)
  2009-07-07  3:12 ` John Stoffel
@ 2009-07-07  7:50 ` Kay Sievers
  2009-07-07 19:34 ` John Stoffel
  8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2009-07-07  7:50 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Jul 7, 2009 at 05:12, John Stoffel<john@stoffel.org> 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.
>
> John> Do you need me to spin up a doc patch for Udev on this?

Added to the README.

> Heh, this seems to have done the trick now, I get my devices properly
> created on reboot.

Great.

Thanks,
Kay

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: howto get serial number of a tape drive?
  2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
                   ` (7 preceding siblings ...)
  2009-07-07  7:50 ` Kay Sievers
@ 2009-07-07 19:34 ` John Stoffel
  8 siblings, 0 replies; 10+ messages in thread
From: John Stoffel @ 2009-07-07 19:34 UTC (permalink / raw)
  To: linux-hotplug

>>>>> "Kay" = Kay Sievers <kay.sievers@vrfy.org> writes:

Kay> On Tue, Jul 7, 2009 at 05:12, John Stoffel<john@stoffel.org> 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.
>> 
John> Do you need me to spin up a doc patch for Udev on this?

Kay> Added to the README.

Thanks!

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-07-07 19:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-06 15:58 howto get serial number of a tape drive? John Stoffel
2009-07-06 16:09 ` Kay Sievers
2009-07-06 18:22 ` John Stoffel
2009-07-06 19:56 ` John Stoffel
2009-07-06 23:00 ` Kay Sievers
2009-07-06 23:02 ` Kay Sievers
2009-07-07  1:08 ` John Stoffel
2009-07-07  3:12 ` John Stoffel
2009-07-07  7:50 ` Kay Sievers
2009-07-07 19:34 ` John Stoffel

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