How are SCSI ID generated ?

Solution Unverified - Updated

Environment

  • Red Hat Enterprise Linux 8 (lsscsi --scsi_id command)
  • Red Hat Enterprise Linux 7 (lsscsi --scsi_id command)
  • Red Hat Enterprise Linux 6 (scsi_id command)
  • Red Hat Enterprise Linux 5 (scsi_id command)

Issue

  • How are scsi_id identifiers generated, such as 360060e80000000000000000000000000 as seen in multipath and within /dev/disk/by-id?
  • Why is there a '3' prefixing the WWID of a device?
  • storage displays a wwid for a device, but the kernel scsi id is slightly different, why?
  • the displayed scsi id within multipath for different storage are different lengths, why?
  • what is the difference between a WWID and a scsi_id?
  • is there any difference between a WWID and a scsi_id?

Resolution

  • a scsi identifier is assigned to each device for use within linux and is based upon information retrieved from each scsi device in question.

    • Optimally a World Wide IDentifier (WWID), if available, is returned by scsi_id and lsscsi --scsi_id commands. WWIDs are guaranteed to be world wide unique. If a WWID is not available from the device, then a scsi identifier is created from other available device information, such as device serial number or a vendor unique identifier.
  • different commands within the different RHEL versions can be used to compose and/or fetch the available scsi identifier for a device

    • Not every device provides a WWID, but when one is available, it is used and displayed by scsi_id (and lsscsi in 7 and later) along with a 3 prefix added to the WWID to identify the source of the id. See below for more information on the different prefix characters.

    • RHEL 7,8: The lsscsi --scsi_id -g utility from the lsscsi package can be used to return the scsi identifier associated with all scsi devices within the system (but only scsi devices, not all devices).

        $ lsscsi --scsi_id -g 
        [0:1:0:0]    disk    HP       LOGICAL VOLUME   5.70  /dev/sda   3600508b1001ca98d5d765bea5a0dd3fa  /dev/sg1 
        [0:1:0:1]    disk    HP       LOGICAL VOLUME   5.70  /dev/sdb   3600508b1001c82586ba0d5b418edfee3  /dev/sg2 
        [0:1:0:2]    disk    HP       LOGICAL VOLUME   5.70  /dev/sdc   3600508b1001c6a473db73aa58119d1fa  /dev/sg3 
        [3:0:1:0]    disk    ATA      ST6000NM0004-1FT NN01  /dev/sdd   35000c500676e2e11  /dev/sg5 
        [4:0:1:0]    disk    ATA      ST6000NM0004-1FT NN01  /dev/sde   35000c5007999d26b  /dev/sg6 
      
      • NOTE: In RHEL 7 and later kernels the WWID is available within the sysfs tree, for example:

          $ find /sys -name "wwid" 2>/dev/null | xargs -I {} grep -Hv "zz" {}
          /sys/block/sdaa/../../wwid:naa.60014055ac6df920033401995121467d
          /sys/block/sdab/../../wwid:naa.6001405b203b4fca4a64e799201fd243
          /sys/block/sdac/../../wwid:naa.6001405b203b4fca4a64e799201fd243
          /sys/block/sdad/../../wwid:naa.6001405cc0d69c03ec741fd9a04e9ebd
        
    • RHEL 5,6,7: The sg_inq utility from the sg3_utils package can be used to fetch the set of device identifiers directly from a specific device. These identifiers are the same ones that scsi_id and lsscsi --scsi_id utilize in building a scsi identifier.

    • RHEL 5,6: The scsi_id utility can be used to return the scsi identifier associated with a specific device

data from multipath -ll:
mpath8 (350002ac000000000) dm-13 3PARdata,VV
        ^<-------+------>
        |        |
        |        +----------- Id information retrieved from device (WWID)
        +-------------------- Prefix character assigned by linux indicating NAA based 
                              identifier from device is being used

mpath7 (360000970000000000000000000000000) dm-5 EMC,SYMMETRIX
^<-------+---------------------->
| |
| +----------- Id information retrieved from device (WWID)
+-------------------- Prefix character assigned by linux indicating NAA based
identifier from device is being used

mpath9 (20017380000000000) dm-23 IBM,2810XIV
^<-------+------>
| |
| +----------- Id information retrieved from device (WWID)
+-------------------- Prefix character assigned by linux indicating EUI-64 based
identifier from device is being used

using scsi_id command

scsi_id --replace-whitespace --whitelisted /dev/sda

SATA_WDC_WD10EZEX-00_WD-WMC1S2966970 ^<-------+------------------------->
| |
| +------------------- Id information retrieved from device (not a WWID)
+---------------------------- Prefix character assigned by linux indicating serial number
from device is being used (plus vendor and model information
from the device).

scsi_id --replace-whitespace --whitelisted /dev/st0

SHP_C7438A_HU110180G4 ^<-------+---------->
| |
| +------------------- Id information retrieved from device (not a WWID)
+---------------------------- Prefix character assigned by linux indicating serial number
from device is being used (plus vendor (HP) and model
information (C7438A) from the device).

scsi_id --replace-whitespace --whitelisted /dev/sdc

1IET_00010001 ^<----+---->
| |
| +---------------------- Id information retrieved from device (not a WWID)
+---------------------------- Prefix character assigned by linux indicating T10 vendor
id from device is being used.

  • the identifier information returned by storage can be in different forms (ascii or binary) and different formats (NAA, EUI-64, Vendor, etc) -- the length of the identifier varies by which form and format the storage device provides to the host

    • warning: the created unique identifier is an ascii string -- when using the "wwid" from scsi_id in places like multipath, make sure to use the string exactly as displayed.

    • world wide unique identifiers use information from VPD (vital product data) inquiry page 0x83. While this is the device identifier page, it does not necessarily always include an identifier that is world wide unique. To be world wide unique it must be expressed in a standard format that includes an IEEE OUI (Organization Unique Identifier). The device identifier page can include multiple identifiers in different formats.

        # sg_inq -p 0 /dev/sde
        VPD INQUIRY, page code=0x00:
           [PQual=0  Peripheral device type: disk]
           Supported VPD pages:
             0x0	Supported VPD pages
            0x80	Unit serial number
            0x83	Device identification                              <<<<<<<<<< identifier page available
      
        # sg_inq -p 0x83 /dev/sde
        VPD INQUIRY: Device Identification page
          Designation descriptor number 1, descriptor length: 20       <<<<<<<<<< 1st identifier
            designator_type: vendor specific [0x0],  code_set: ASCII   <<<<<<<<<< Vendor specific/ascii string (not a WWID)
            associated with the addressed logical unit
              vendor specific: 50014380212E90E0
          Designation descriptor number 2, descriptor length: 8        <<<<<<<<<< 2nd identifier
            designator_type: vendor specific [0x0],  code_set: Binary  <<<<<<<<<< Vendor specific/binary (not a WWID)
            associated with the addressed logical unit
              vendor specific:
                00 00 00 00
      
      
        # sg_inq -p 0x83 /dev/sdf
        VPD INQUIRY: Device Identification page
          Designation descriptor number 1, descriptor length: 20       <<<<<<<<<< 1st identifier
            designator_type: NAA,  code_set: Binary                    <<<<<<<<<< NAA format (is a WWID)
            associated with the addressed logical unit
              NAA 6, IEEE Company_id: 0x508b                           <<<<<<<<<< format type and OUI
              Vendor Specific Identifier: 0x1001c4c98
             Vendor Specific Identifier Extension: 0xd3b101921097c450
              [0x600508b1001c4c98d3b101921097c450]                     <<<<<<<<<< WWID (composed of above fields)
          Designation descriptor number 2, descriptor length: 8        <<<<<<<<<< 2nd identifier
            designator_type: vendor specific [0x0],  code_set: Binary  <<<<<<<<<< Vendor specific/binary (not a WWID)
            associated with the addressed logical unit
              vendor specific:
                01 00 00 00
      
        # scsi_id --replace-whitespace --whitelisted /dev/st0
        3600508b1001c4c98d3b101921097c450
      
    • serial number based identiers use information from VPD inquiry page 0x80. To make the identifier more unique, the vendor and model information is also used.

        # sg_inq -p 0 /dev/sde
        VPD INQUIRY, page code=0x00:
           [PQual=0  Peripheral device type: disk]
           Supported VPD pages:
             0x0	Supported VPD pages
            0x80	Unit serial number              <<<< identifier page 0x83 is not available
      
      
        # sg_inq -p 0x80 /dev/st0
        VPD INQUIRY: Unit serial number page
          Unit serial number: HU110180G4             <<<< serial number information
      
        # sg_inq /dev/st0
        standard INQUIRY:
          PQual=0  Device_type=1  RMB=1  version=0x03  [SPC]
         [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
         SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  [BQue=0]
         EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
        [RelAdr=0]  WBus16=0  Sync=0  Linked=0  [TranDis=0]  CmdQue=0
        [SPI: Clocking=0x0  QAS=0  IUS=0]
           length=74 (0x4a)   Peripheral device type: tape
        Vendor identification: HP                  <<<<< vendor information
        Product identification: C7438A             <<<<< model information
        Product revision level: ZU8B
      
        # scsi_id --replace-whitespace --whitelisted /dev/st0
        HP_C7438A_HU110180G4
      
  • since the information returned by a device can be in different declared formats, a prefix character is added to the front of the scsi unique identifier to specify the specific source and format used in creating the id. The underlined character within the above examples specify the source of the identifier (the prefix character is only used within the linux kernel and is not part of the identifier provided from storage):

    • 'S' for string based (serial number from scsi INQUIRY page 0x80)
    • '3' for NAA based (identification record within scsi INQUIRY page 0x83)
    • '2' for EUI-64 based (identification record within scsi INQUIRY page 0x83)
    • '1' for T10 Vendor id based (identification record within scsi INQUIRY page 0x83)
    • '0' for Vendor specific (identification record within scsi INQUIRY page 0x83)
  • NOTE: while all identifiers output by scsi_id are unique within the context of the host, not all are world wide unique (WWID)

    • scsi unique identifiers that are also world wide unique identifiers (WWIDs) by prefix:

      • '3' for NAA based (identification record within scsi INQUIRY page 0x83)
      • '2' for EUI-64 based (identification record within scsi INQUIRY page 0x83)
    • scsi unique identifiers that are only vendor unique (not WWIDs) by prefix:

      • 'S' for string based (serial number from scsi INQUIRY page 0x80)
      • '1' for T10 Vendor id based (identification record within scsi INQUIRY page 0x83)
      • '0' for Vendor specific (identification record within scsi INQUIRY page 0x83)
  • See How do I find the FC ID (WWN) of a disk/LUN on Red Hat Enterprise Linux for additional details and information on wwids.

Root Cause

The man page for the scsi_id command states:

scsi_id - retrieve and generate a unique SCSI identifier

Indeed it does retrieve identification information from the scsi device and generates from that information a unique scsi identifier. As part of generating an identifier from device information, a prefix code will be added to flag the source of the identifier.

The scsi identification information is retrieved from storage by extracting pieces of information from a scsi device's inquiry data. There are three sources for identification information retrieved from the scsi device:

  • the standard inquiry page (sg_inq /dev/sdN)
  • Vital Product Data (VPD) page 0x80 (serial number:: sg_inq -p 0x80 /dev/sdN), and
  • VPD page 0x83 (identification:: sg_inq -p 0x83 /dev/sdN).

Several different identifier forms, ascii and binary based, as well as formats may be simultaneously present and available from a given scsi device. The scsi_id utility utilizes a priority algorithm to select which form and format to utilize and generates the identifier.

For example if both a serial number (VPD page 83) is available and an NAA format identifier is available in VPD page 0x83, then the NAA format identification number is utilized based upon the priority algorithm in scsi_id.

#  sg_inq -p 0x80 /dev/sdz
VPD INQUIRY: Unit serial number page
  Unit serial number: 12345678-1234-1234-1234-123456789012

sg_inq -p 0x83 /dev/sdz

VPD INQUIRY: Device Identification page
Designation descriptor number 1, descriptor length: 20
designator_type: NAA, code_set: Binary associated with the addressed logical unit
NAA 6, IEEE Company_id: 0x1405
Vendor Specific Identifier: 0x3b986567f
Vendor Specific Identifier Extension: 0x5594ddea271e7e13
[0x60014050000000000000000000000000]
Designation descriptor number 2, descriptor length: 58
designator_type: T10 vendor identification, code_set: ASCII associated with the addressed logical unit
vendor id: LIO-ORG
vendor specific: buddisk3:12345678-1234-1234-1234-123456789012 :
.

scsi_id -g -u -d /dev/sdz

360014053b986567f5594ddea271e7e13

In the above example, the device makes available three forms of identification:

  • serial number: 12345678-1234-1234-1234-123456789012 (ascii)
  • NAA identifer: 0x60014050000000000000000000000000 (binary), and
  • T10 vendor identification: buddisk3:12345678-1234-1234-1234-123456789012 (ascii).

The scsi_id, based upon priority, uses the NAA format. But notice that a '3' has been pre-pended to the NAA identifier by scsi_id to flag the source (and thus form and format) of the identifier. The prefix used, other than 'S' for serial number based, are values defined by the scsi standard for each of the above designator field types:

SCSI Primary Commands - 4 (SPC-4)

7.7.3.1 Device Identification VPD page overview
:

Code Description Reference
0h Vendor specific 7.7.3.3
1h T10 vendor ID based 7.7.3.4
2h EUI-64 based 7.7.3.5
3h NAA 7.7.3.6

The reference numbers are the section header number within the scsi standard that describes the individual formats. The identifier format number that is prefixed by linux is not part of the actual identifier provided from storage -- it should be removed when trying to use the identifier to match identifiers within vendor storage utilities or within the storage box itself.

Diagnostic Steps


NOTE: sg_inq command is available by installing the sg3_utils package.

Use of the sg_inq (scsi INQUIRY command) can be used to retrieve the available identification information from a device:


scsi_id -g -u -s /block/sdN  {RHEL5, or}
scsi_id -g -u -d /dev/sdN    {RHEL6}
sg_inq           /dev/sdN
sg_inq -p 0x00   /dev/sdN
sg_inq -p 0x80   /dev/sdN
sg_inq -p 0x83   /dev/sdN

Although VPD page 0x80 is almost always available, page 0x83 may not be especially on older devices. Even when page 0x83 is available, it may only contain vendor specific identifiers and no WWIDs.

The previous example showed how an NAA identifier is retrieved and generates a scsi id. The following example of the above commands highlight the identification information available and presented for a common scsi disk where a serial number based identifier is output from scsi_id.

# /sbin/scsi_id -g -u -s /block/sda
SATA_WDC_WD10EZEX-00_WD-WMC1S2966970
# sg_inq /dev/sda
# /usr/bin/sg_inq  /dev/sda
standard INQUIRY:
  PQual=0  Device_type=0  RMB=0  version=0x05  [SPC-3]
  [AERC=0]  [TrmTsk=0]  NormACA=0  HiSUP=0  Resp_data_format=2
  SCCS=0  ACC=0  TPGS=0  3PC=0  Protect=0  BQue=0
  EncServ=0  MultiP=0  [MChngr=0]  [ACKREQQ=0]  Addr16=0
  [RelAdr=0]  WBus16=0  Sync=0  Linked=0  [TranDis=0]  CmdQue=0
  [SPI: Clocking=0x0  QAS=0  IUS=0]
    length=96 (0x60)   Peripheral device type: disk
 Vendor identification: ATA    
 Product identification: WDC WD10EZEX-00
 Product revision level: 80.0
 Unit serial number:      WD-WMC1S2966970
# sg_inq -p 0x00 /dev/sda
 Only hex output supported
VPD INQUIRY, page code=0x00:
   [PQual=0  Peripheral device type: disk]
   Supported VPD pages:
     0x0        Supported VPD pages
     0x80       Unit serial number
     0x83       Device identification
     0x86       Extended INQUIRY data
     0xb0       Block limits (sbc2)
     0xb1       Block device characteristics (sbc3)
# sg_inq -p 0x80 /dev/sda
VPD INQUIRY: Unit serial number page
  Unit serial number:      WD-WMC1S2966970
sg_inq -p 0x83 /dev/sda
VPD INQUIRY: Device Identification page
  Designation descriptor number 1, descriptor length: 24
    id_type: vendor specific [0x0],  code_set: ASCII
    associated with the addressed logical unit
 00     20 20 20 20 20 57 44 2d  57 4d 43 31 53 32 39 36         WD-WMC1S296
 10     36 39 37 30                                         6970            
  Designation descriptor number 2, descriptor length: 72
    id_type: T10 vendor identification,  code_set: ASCII
    associated with the addressed logical unit
      vendor id: ATA    
      vendor specific: WDC WD10EZEX-00RKKA0                         WD-WMC1S2966970

In the above example, because the prefix code on the identifier output from scsi_id is 'S', we know the identifer is serial number based. Since serial numbers are only vendor unique at best, the vendor and product information is concatenated with the serial number to create the scsi identifer:

Prefix                : S + 
Vendor identification :  ATA + 
Product identification:      WDC WD10EZEX-00 + 
Unit serial number    :                      WD-WMC1S2966970 => 
scsi_id               : SATA_WDC_WD10EZEX-00_WD-WMC1S2966970

Note that page 0x83 consists of multiple records (underlined descriptor numbers). Each record can define a record containing string (ascii) or binary data plus an id type. The creation of a scsi id uses the best source (NAA before T10 before vendor specific, etc.). In this case the serial number was used as the best available identifier.
 
 


The links herein to external websites are provided for convenience only. Red Hat has not reviewed the link and is not responsible for the content or its availability. The inclusion of any link to a website does not imply endorsement by Red Hat of the website or their entities, products or services. You agree that Red Hat is not responsible or liable for any loss or expenses that may result due to your use of (or reliance on) the external site or content.
  The NAA format (prefix='3') and EUI-64 formats (prefix='2') include an OUI - Organizationally Unique Identifier. That makes these formats world wide unique. The format of these identifiers are described in IEEE's Content from standards.ieee.org is not included.Guidelines for Fibre Channel Use of the Organizationally Unique Identifier. The OUI registration database is also available from IEEE Content from standards.ieee.org is not included.oui.txt.

Combining the information about identifier formats, such as above, along with the knowledge of what the prefix characters mean in terms of source/format of the scsi identifiers from scsi_id we can parse most identifiers into sub-parts and, if OUI is available within the identifier format, decode the vendor they belong to.


The following information has been provided by Red Hat, but is outside the This content is not included.scope of coverage of the posted This content is not included.Service Level Agreements and support procedures. The information is provided as-is and any configuration settings or installed applications made from the information in this article could make the Operating System unsupported by Red Hat Global Support Services. The intent of this article is to provide information to accomplish the system's needs. Use of the information in this article at the user's own risk.

Source for the program that parses and generates the following output is available at This content is not included.'scsiid' source but is for illustrative purposes only and, per the above, is provided as-is and is unsupported. Included within the source is a second id parser, wwid, which can be used to parse world wide names in NAA format.


test: mpath8 (350002ac0002615bd) dm-13 3PARdata,VV
$ ./scsiid 350002ac000000000
Format base: NAA    ('3')
                  Vendor
 NAA     OUI      Specific  OUI name
   5     00-02-AC 000000000 3PAR data                       

test: mpath7 (360000970000000000000000000000000) dm-5 EMC,SYMMETRIX
$ ./scsiid 360000970000000000000000000000000 Format base: NAA ('3')
Vendor Vendor
NAA OUI Specific Specific Ext. OUI name
6 00-00-97 000000000.0000000000000000 EMC Corporation <&lt notice the NAA format is 6, a longer
identifer format then format 5 above

test: mpath20 (20017380000000000) dm-23 IBM,2810XIV
$ ./scsiid 20017380000000000 Format base: EIU-64 ('2')
Vendor
OUI Specific OUI name
00-17-38 0000000000 International Business Machines

test: scsi_id -g -u -s /block/sda
SATA_WDC_WD10EZEX-00_WD-WMC1S2966970 $ ./scsiid SATA_WDC_WD10EZEX-00_WD-WMC1S2966970 Format base Serial Number ('S'):
Vendor
Vendor Model Serial Number (pg 80)
ATA WDC WD10EZEX-00_WD-WMC1S2966970

test: /sbin/scsi_id -g -u -s /class/scsi_tape/nst0
SHP_C7438A_HU110180G4 $ ./scsiid SHP_C7438A_HU110180G4 Format base Serial Number ('S'):
Vendor
Vendor Model Serial Number (pg 80)
HP C7438A HU110180G4

SBR
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.