SG_INQ(8)

NAME
sg_inq - outputs data retrieved from the SCSI INQUIRY command

SYNOPSIS
sg_inq [-c] [-cl] [-d] [-e] [-h] [-i] [-o=<opcode_page>] [-p=<vpd_page>] [-P] [-r] [-s] [-v] [-V] [-x] [-36] [-?] <scsi_device>

DESCRIPTION

This utility sends an INQUIRY SCSI command to the given device and then outputs the response. All SCSI devices are meant to respond to a "standard" INQUIRY command with at least a 36 byte response (in SCSI 2 and higher). An INQUIRY is termed as "standard" when both the EVPD and CmdDt bits are clear.

An important "non-standard" INQUIRY page is the Device Identification Vital Prodoct Data (VPD) page (page number: 0x83). In recent SPC-3 drafts support for this page has been flagged as mandatory. The '-i' option decodes this page.

If <scsi_device> exists and the SCSI INQUIRY fails (because the SG_IO ioctl is unknown) then an ATA IDENTIFY is tried. If it succeeds then device identification strings are output. If the "-r" option is given then the 256 byte IDENTIFY block is output in binary.

The reference document used for interpreting an INQUIRY is T10/1416-D Revision 21a (9th November 2004) found at http://www.t10.org . Obsolete items in the standard INQUIRY response are displayed in brackets.

-c  set the Command Support Data (CmdDt) bit (defaults to clear(0)). Used in conjunction with the '-o=<opcode>' option to specify the SCSI command opcode to supply the support data for. The command support data is a mask of the same length as the command with bits set in positions that are modifiable. For example, '12 03 ff 00 ff 01' shows the device supports the EVPD and CmdDt bits [byte 1, bits 0 and 1] in an INQUIRY command. The CmdDt bit is now obsolete. It has been replaced by the REPORT SUPPORTED OPERATION CODES command which is accessed via the sg_opcodes utility.

-cl lists the command data for all supported commands (followed by the command name) by looping through all 256 opcodes. This option uses the CmdDt bit which is now obsolete. See the sg_opcodes utility.

-d  lists version descriptors. There are up to 8 version descriptors in the upper bytes of a standard INQUIRY, If the code is recognised then the corresponding string is output. Version descriptors are versions of standards and drafts that the device claims to comply with (e.g. SAM, SPC, SBC, SAS etc).

-e  enable (i.e. sets) the Vital Product Data (EVPD) bit (defaults to clear(0)). Used in conjunction with the '-p=<vpd_page>' option to specify the VPD page to fetch. If '-p' is not given then VPD page 0 (list supported VPD pages) is assumed. Support for VPD page 0 and page 0x83 (device identification) have been made mandatory in recent SPC-3 drafts.

-h  outputs INQUIRY response in hex rather than trying to decode it. When used with '-i' outputs partially decoded device identification descriptors with the identifier itself output in hex.

-i  outputs the Device Identification Vital Product Data (VPD) page [0x83]. If '-r' is not given then attempts to decode the response which can be made up of several "identification descriptors". If '-h' is given then each descriptor header is decoded and the identifier itself is output in hex. To see the whole VPD 0x83 page response in hex use '-p=83 -h'. Recent SPC-3 drafts have made support of the device identification VPD page mandatory.

-o=<opcode_page>
    used in conjunction with the '-e' or '-c' option. If neither given then the '-e' option assumed. When the '-e' option is also given (or assumed) then the argument to this option is the VPD page number. The argument is interpreted as hexadecimal and is expected to be in the range 0 to ff inclusive. Only VPD page 0 is decoded and lists supported VPD pages and their names (if known). To decode the mandatory device identification page (0x83) use the '-i' option. A now obsolete usage is when the '-c' option is given in which case the argument to this option is assumed to be a command opcode number. Recent SCSI draft standards have moved this facility (see sg_opcodes). Defaults to 0 so if '-e' is given without '-o=' then VPD page 0 is output.

-p=<vpd_page>
    same action as '-o=<opcode_page>' option described above. Since the opcode value with the CmdDt is now obsolete, the main use of this option is to specify the VPD page number. The argument is interpreted as hexadecimal and is expected to be in the range 0 to ff inclusive. Defaults to 0 so if '-e' is given without '-p=' then VPD page 0 is output.

-P  outputs the Unit Path Report Vital Product Data (VPD) page [0xc0], which is specific to selected EMC devices. To see the whole VPD 0xc0 page response in hex use '-o=c0 -h'.

-r  outputs the INQUIRY response in binary. If the SCSI INQUIRY has failed and an ATA IDENTIFY succeeds then the 256 byte IDENTIFY response is output in hex. Standard output should be redirected to a file or some other program that can process binary data.

-s  outputs the SCSI Ports Vital Product Data (VPD) page [0x88]. If '-r' is not given then attempts to decode the response. The response contains information about the target (or rarely the initiator) ports associated with the addressed device server (i.e. the target). In practice this is a way to find all target port addresses of a dual ported disk. If '-h' is given then each target (and/or initiator) descriptor is output in hex. To see the whole VPD 0x88 page response in hex use '-p=88 -h'.

-v  verbose: print out cdb of issued commands prior to execution

-V  print out version string

-i  outputs the Extended INQUIRY Vital Product Data (VPD) [0x86] page. If '-r' is not given then attempts to decode the response. If '-h' is given then prints out VPD page in hex which is similar to using '-p=86 -h'.

-36 only requires 36 bytes of response data for an INQUIRY. Furthermore even if the device indicates in its response it can supply more data, a second (longer) INQUIRY is not performed.

-?  output usage message and exit. Ignore all other parameters.

Some device with weak SCSI command set implementations lock up when they receive commands they don't understand (or even response lengths that they don't expect). Such devices need to be treated carefully hence the '-36' option. Without this option this utility will issue a standard INQUIRY requesting 36 bytes of response data. If the device indicates it could have supplied more data then a second INQUIRY is issued to fetch the longer response.

In the 2.4 series of Linux kernels the given device must be a SCSI generic (sg) device. In the 2.6 series block devices (e.g. disks and SCSI DVDs) can also be specified. For example "sg_inq /dev/sda" will work in the 2.6 series kernels. From lk 2.6.6 other SCSI "char" device names may be used as well (e.g. "/dev/st0m").

AUTHOR
Written by Doug Gilbert

REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>.

COPYRIGHT
Copyright © 2001-2004 Douglas Gilbert
This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

SEE ALSO
sgdiag(scsirastools), sg_opcodes(sg3_utils), sg_modes(sg3_utils), sg_logs(sg3_utils), blktool(internet)