From mboxrd@z Thu Jan 1 00:00:00 1970 From: "John Stoffel" Date: Mon, 06 Jul 2009 15:58:18 +0000 Subject: howto get serial number of a tape drive? Message-Id: <19026.7962.882759.229031@stoffel.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org 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