http://man-wiki.net/index.php/8:sg_inq

      sg_inq - outputs data retrieved from the SCSI INQUIRY or ATA IDENTIFY (PACKET) DEVICE command
      

Contents

[hide]

SYNOPSIS

      sg_inq  [-a] [-A] [-b] [-c] [-cl] [-d] [-e] [-h] [-H] [-i] [-m] [-m] [-o=<opcode_page>] [-p=<vpd_page>] [-P] [-r]
      [-s] [-v] [-V] [-x] [-36] [-?]  <device>

DESCRIPTION

      This utility by default 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 Product Data (VPD) page (page number:
      0x83). Since SPC-3, support for this page has been flagged as mandatory. The '-i' option decodes this page.
 
      If  <device> exists and the SCSI INQUIRY fails (because the SG_IO ioctl is unknown) then an ATA IDENTIFY (PACKET)
      DEVICE is tried. If it succeeds then device identification strings are output. If the "-r" option is  given  then
      the  512  byte  IDENTIFY  response  is  output in binary. If the "-H" (or "-h") option is given then the 512 byte
      response is output in ASCII hex, grouped as 256 16 bit words, 8 words per line.  If the "-A" option is given then
      the  SCSI  INQUIRY  is  not performed and the device is assumed to be ATA (or ATAPI). This allows ATAPI transport
      information to be found for ATAPI cd/dvd drives; since without this option such drives respond to a SCSI  INQUIRY
      command.
 
      The  reference  document used for interpreting an INQUIRY is T10/1713-D Revision 4 (SPC-4, 9 March 2006) found at
      http://www.t10.org .  Obsolete items in the standard INQUIRY response are displayed in  brackets.  The  reference
      document for the ATA IDENTIFY (PACKET) DEVICE command is ATA8-ACS found at http://www.t13.org .
 
      ATA or ATAPI devices that use a SCSI to ATA Translation layer (see SAT at www.t10.org) may support the ATA Infor-
      mation VPD page. This returns the IDENTIFY (PACKET) DEVICE response amongst other things.  See the '-a' option.
 
      -a     decodes the ATA Information Vital Product Data (VPD) page [0x89].  If '-H' is given then the whole page as
             ASCII  hex bytes; with '-HH' the IDENTIFY (PACKET) DEVICE response is output in ASCII hex bytes; and with-
             out either the IDENTIFY (PACKET) DEVICE response is output in 16 bit ASCII hex words. This page is defined
             in SAT (revision 5) at www.t10.org .
 
      -A     Assume  given  <device> is an ATA or ATAPI device which can receive ATA passthrough commands from the host
             operating system. Skip the SCSI INQUIRY command and use either the ATA IDENTIFY DEVICE command  (for  non-
             packet  devices)  or  the  ATA IDENTIFY PACKET DEVICE command. This option is not available in the FreeBSD
             port.
 
      -b     decodes the Block Limits Vital Product Data (VPD) page [0xb0].  This page is defined  in  SBC-2  (revision
             16) at www.t10.org .
 
      -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  sup-
             port  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     decodes  depending  on  context.  If  '-e'  option is given, or any option that implies '-e' (e.g. '-i' or
             '-p=80'), then this utility attempts to decode the indicated VPD page.  Otherwise the version  descriptors
             (if  any)  are  listed following a standard INQUIRY response. There are up to 8 version descriptors in the
             response of a standard INQUIRY, If the version descriptor 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, SPI, FCP, 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 SPC-3 .
 
      -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.  When  selected,  ATA
             IDENTIFY  responses  are  output in 16 bit words if '-h' is given; they are output in bytes when '-hh' (or
             '-HH') is given. The '-hh' option has a similar effect on the ATA information VPD page decoding (i.e. when
             the '-a' option is given).
 
      -H     same action as "-h". For compatibility with many other sg3_utils programs in which "-H" is for hex output.
 
      -i     decodes the Device Identification Vital Product Data (VPD) page [0x83].  This page is 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'. Since SPC-3,  sup-
             port for the device identification VPD page is mandatory.
 
      -m     decodes  the  Management  network  addresses Vital Product Data (VPD) page [0x85]. This page is made up of
             several "network service descriptors".  If '-h' is given then each descriptor payload is output in hex.
 
      -M     decodes the Mode page policy Vital Product Data (VPD) page [0x87].  This page is made up of several  "mode
             page policy descriptors".  If '-h' is given then each descriptor payload is output in hex.
 
      -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  argu-
             ment  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  iden-
             tification  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  stan-
             dards 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 with-
             out '-p=' then VPD page 0 is output.
 
      -P     decodes  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 '-p=c0 -h'.
 
      -r     outputs the INQUIRY response in binary. If the SCSI INQUIRY has failed and an ATA IDENTIFY  succeeds  then
             the  512  bytes  of the IDENTIFY response is output in binary. Overrides the various VPD decoding options.
             Standard output should be redirected to a file or some other program that can process binary data. Can  be
             used  twice  and  if  used  with  the  '-A'  or  '-a'  option  yields  output with the same format as "cat
             /proc/ide/hd<x>/identify" so that it can then be piped to "hdparm --Istdin".
 
      -s     decodes the SCSI Ports Vital Product Data (VPD) page [0x88]. 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. '-vv' and '-vvv' are also accepted  yielding
             greater  verbosity.  For  ATA disks the identity response (256 16 bit words) is output when this option is
             given.
 
      -V     print out version string
 
      -x     decodes the Extended INQUIRY data Vital Product Data (VPD) [0x86] page.  If '-h' is given then prints  out
             VPD page in hex which is similar to using '-p=86 -h'.
 
      -36    only  requests  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. This is a paranoid  setting.
 
      -?     output usage message and exit. Ignore all other parameters.
 
      Some  devices 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 an initial 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. That second command may lock up faulty devices.
 
      In  the INQUIRY standard response there is a 'MultiP' flag which is set when the device has 2 or more ports. Some
      vendors use the preceding vendor specific ('VS') bit to indicate which port is being accessed by the INQUIRY com-
      mand  (0 -> relative port 1 (port "a"), 1 -> relative port 2 (port "b")). When the 'MultiP' flag is set, the pre-
      ceding vendor specific bit is shown in parentheses. SPC-3 compliant devices should use the device  identification
      VPD page (0x83) to show which port is being used for access and the SCSI ports VPD page (0x88) to show all avail-
      able ports on the device.
 
      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  ATAPI 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").

ATA DEVICES

      There are two major types of ATA devices: non-packet devices (e.g. ATA disks) and  packet  devices  (ATAPI).  The
      majority  of  ATAPI devices are CD/DVD drives in which the ATAPI transport carries the MMC set (i.e.  a SCSI com-
      mand set). Further, both types of ATA devices can be connected to a host computer via a "SCSI"  (or  some  other)
      transport.  When  an  ATA  disk  is controlled via a SCSI (or non-ATA) transport then two approaches are commonly
      used: tunnelling (e.g. STP in Serial Attached SCSI (SAS)) or by emulating a SCSI device (typically via a SCSI  to
      ATA  translation  layer,  see  SAT at www.t10.org ). Even when the physical transport to the host computer is ATA
      (especially in the case of SATA) the linux operating system may choose to put a SAT layer in the  driver  "stack"
      (e.g. libata).
 
      The  main  identifying command for any SCSI device is an INQUIRY. The corresponding command for an ATA non-packet
      device is IDENTIFY DEVICE while for an ATA packet device it is IDENTIFY PACKET DEVICE.
 
      When this utility is invoked for an ATAPI device (e.g. a CD/DVD drive with "sg_inq /dev/hdc") then a SCSI INQUIRY
      is  sent  to the device and if it responds then the response to decoded and output and this utility exits. To see
      the response for an ATA IDENTIFY PACKET DEVICE command add the '-A' option (e.g. "sg_inq -A /dev/hdc) and to  see
      the response in hex add the "-H" option as well (e.g. "sg_inq -A -H /dev/hdc").
 
      This  utility  doesn't  decode the response to an ATA IDENTIFY (PACKET) DEVICE command, hdparm does a good job at
      that. The '-rr' option has been added to use with either the '-A' or '-a' option to produce a  format  acceptable
      to "hdparm --Istdin". See hdparm.

EXIT STATUS

      The exit status of sg_inq is 0 when it is successful. Otherwise see the sg3_utils(8) man page.

REPORTING BUGS

      Report bugs to <dgilbert at interlog dot com>.

COPYRIGHT

      Copyright ? 2001-2006 Douglas Gilbert
      This  software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FIT-
      NESS FOR A PARTICULAR PURPOSE.

RELATED

      sgdiag(scsirastools),    sg_opcodes(sg3_utils),    sg_modes(sg3_utils),    sg_logs(sg3_utils),    hdparm(hdparm),
      sg_vpd(sg_vpd)



Reply via email to