Printing tape drive serial numbers

While automating a process this week I needed a way to get the serial number off a batch of tape drives. At first I thought I could retrieve this information through /sys. But after a bunch of poking around with cat, systool and udevadm I realized I couldn’t get what I want through /sys. One such failure:

$ udevadm info -a -n /dev/nst0 | grep -i serial

If I can’t get the serial # through /sys I can always poke the drive directly, right? Definitely! SCSI vital product data (VPD) is stored on the drive in a series of SCSI mode pages. These pages can be viewed with the sg_vpd utility:

$ sg_vpd –page=0x80 /dev/nst0

VPD INQUIRY: Unit serial number page
  Unit serial number: 123456789012

The command above retrieves SCSI mode page 0x80 (Unit Serial Number) and displays it in an easily parsed format. Seagates SCSI commands reference is an excellent reference for understanding the SCSI protocol.

1 thought on “Printing tape drive serial numbers”

  1. So happy you are writing again. This has always been one of my favourite blogs!

    Would love to read about your experiences with Docker so far!

    Great to have you back!

    -Alex

Leave a Reply

Your email address will not be published. Required fields are marked *