1SG_INQ(8)                          SG3_UTILS                         SG_INQ(8)
2
3
4

NAME

6       sg_inq - issue SCSI INQUIRY command, output and decode response
7

SYNOPSIS

9       sg_inq   [--ata]   [--cmddt]  [--descriptors]  [--export]  [--extended]
10       [--help] [--hex] [--id] [--len=LEN] [--maxlen=LEN] [--page=PG]  [--raw]
11       [--vendor] [--verbose] [--version] [--vpd] DEVICE
12
13       sg_inq  [-36]  [-a]  [-A]  [-b]  [-c]  [-cl]  [-d]  [-e] [-h] [-H] [-i]
14       [-l=LEN] [-m] [-M] [-o=OPCODE_PG] [-p=VPD_PG] [-P] [-r] [-s] [-u]  [-v]
15       [-V] [-x] [-36] [-?] DEVICE
16

DESCRIPTION

18       This  utility  by  default  sends  a  SCSI INQUIRY command to the given
19       device and then outputs the response. All SCSI  devices  are  meant  to
20       respond  to  a  "standard"  INQUIRY  command  with  at  least a 36 byte
21       response (in SCSI 2 and higher). An INQUIRY  is  termed  as  "standard"
22       when both the EVPD and CmdDt (now obsolete) bits are clear.
23
24       This  utility  supports two command line syntaxes, the preferred one is
25       shown first in the synopsis and explained in this section. A later sec‐
26       tion  on  the  old  command  line  syntax  outlines the second group of
27       options.
28
29       An important "non-standard" INQUIRY page is the  Device  Identification
30       Vital  Product  Data  (VPD)  page [0x83]. Since SPC-3, support for this
31       page is mandatory. The --id option decodes  this  page.  New  VPD  page
32       information  is  no longer being added to this utility. To get informa‐
33       tion on new VPD pages see the sg_vpd(8) or sdparm(8) utilities.
34
35       If the DEVICE exists and the SCSI  INQUIRY  fails  (because  the  SG_IO
36       ioctl  is not supported) then an ATA IDENTIFY (PACKET) DEVICE is tried.
37       If it succeeds then device identification strings are output. The --raw
38       and  --hex  options  can be used to manipulate the output. If the --ata
39       option is given then the SCSI INQUIRY is not performed and  the  DEVICE
40       is assumed to be ATA (or ATAPI).
41
42       The  reference  document used for interpreting an INQUIRY is T10/1713-D
43       Revision 36e (SPC-4, 24 August  2012)  found  at  http://www.t10.org  .
44       Obsolete and reserved items in the standard INQUIRY response output are
45       displayed in brackets. The reference  document  for  the  ATA  IDENTIFY
46       (PACKET) DEVICE command is ATA8-ACS found at http://www.t13.org .
47

OPTIONS

49       Arguments to long options are mandatory for short options as well.  The
50       options are arranged in alphabetical order based  on  the  long  option
51       name.
52
53       -a, --ata
54              Assume  given DEVICE is an ATA or ATAPI device which can receive
55              ATA commands from the  host  operating  system.  Skip  the  SCSI
56              INQUIRY  command  and use either the ATA IDENTIFY DEVICE command
57              (for non-packet devices) or the ATA IDENTIFY PACKET DEVICE  com‐
58              mand.  To  show  the  response in hex, add a '--verbose' option.
59              This option is only available in Linux.
60
61       -c, --cmddt
62              set the Command Support Data (CmdDt) bit (defaults to clear(0)).
63              Used in conjunction with the --page=PG option where PG specifies
64              the SCSI command opcode to query. When used twice  (e.g.  '-cc')
65              this  utility forms a list by looping over all 256 opcodes (0 to
66              255 inclusive) only outputting a line for  found  commands.  The
67              CmdDt  bit  is now obsolete.  It has been replaced by the REPORT
68              SUPPORTED OPERATION CODES command, see the  sg_opcodes(8)  util‐
69              ity.
70
71       -d, --descriptors
72              decodes  and  prints the version descriptors found in a standard
73              INQUIRY response. There are up to 8 of them. Version descriptors
74              indicate  which  versions  of standards and/or drafts the DEVICE
75              complies with. The normal components of a standard  INQUIRY  are
76              output  (typically from the first 36 bytes of the response) fol‐
77              lowed by the version descriptors if any.
78
79       -e     see entry below for --vpd.
80
81       -u, --export
82              prints out information obtained from the device. The output  can
83              be modified by selecting a VPD page with PG (from --page=PG). If
84              the device identification VPD page 0x83 is given it  prints  out
85              information  in the form: "SCSI_IDENT_<assoc>_<type>=<ident>" to
86              stdout. If the device serial number VPD page 0x80  is  given  it
87              prints out information in the form: "SCSI_SERIAL=<ident>". Other
88              VPD pages are not supported. If no VPD page is given  it  prints
89              out    information    in   the   form:   "SCSI_VENDOR=<vendor>",
90              "SCSI_MODEL=<model>", and "SCSI_REVISION=<rev>", taken from  the
91              standard  inquiry.  This may be useful for tools like udev(7) in
92              Linux.
93
94       -E, -x, --extended
95              prints the extended INQUIRY VPD page [0x86].
96
97       -h, --help
98              print out the usage message then exit. When  used  twice,  after
99              the  usage  message,  there is a list of available abbreviations
100              than can be given to the --page=PG option.
101
102       -H, --hex
103              rather than decode a standard INQUIRY response, a  VPD  page  or
104              command  support  data; print out the response in hex to stdout.
105              Error messages and warnings are typically output to stderr. When
106              used  twice with the ATA Information VPD page [0x89] decodes the
107              start of the response then outputs  the  ATA  IDENTIFY  (PACKET)
108              DEVICE  response  in  hexadecimal bytes (not 16 bit words). When
109              used three times with the ATA Information VPD page [0x89] or the
110              --ata  option,  this  utility  outputs the ATA IDENTIFY (PACKET)
111              DEVICE response in  hexadecimal  words  suitable  for  input  to
112              'hdparm --Istdin'.  See note below.
113
114       -i, --id
115              prints the device identification VPD page [0x83].
116
117       -l, --len=LEN
118              the  number  LEN is the "allocation length" field in the INQUIRY
119              cdb.  This is the (maximum) length of the response to be sent by
120              the  device.  The default value of LEN is 0 which is interpreted
121              as: first request is for  36  bytes  and  if  necessary  execute
122              another INQUIRY if the "additional length" field in the response
123              indicates that more than 36  bytes  is  available.   If  LEN  is
124              greater  than 0 then only one INQUIRY command is performed.  See
125              paragraph below about "36 byte INQUIRYs".
126
127       -m, --maxlen=LEN
128              this option has the same action as the --len=LEN option. It  has
129              been  added  for  compatibility  with  the  sg_vpd, sg_modes and
130              sg_logs utilities.
131
132       -O, --old
133              Switch to older style options. Please use as first option.
134
135       -p, --page=PG
136              the PG argument can be either a number of an abbreviation for  a
137              VPD page. To enumerate the available abbreviations for VPD pages
138              use '-hh' or a bad abbreviation (e.g,  '--page=xxx').  When  the
139              --cmddt  option  is  given  (once)  then PG is interpreted as an
140              opcode number (so VPD page abbreviations make little sense).
141
142       -r, --raw
143              output the response in binary  to  stdout.  Error  messages  and
144              warnings, if any, are sent to stderr.
145
146       -s, --vendor
147              output  a standard INQUIRY response's vendor specific field from
148              offset 36 to 55 in ASCII. When used twice (i.e. '-ss') also out‐
149              put  the  vendor specific field from offset 96 in ASCII. This is
150              only done if the data passes some simple sanity checks.
151
152       -v, --verbose
153              increase level of verbosity. Can be used multiple times.
154
155       -V, --version
156              print out version string then exit.
157
158       -e, --vpd
159              set the Enable  Vital  Product  Data  (EVPD)  bit  (defaults  to
160              clear(0)).  Used  in conjunction with the --page=PG option where
161              PG specifies the VPD page number to query. If the  --page=PG  is
162              not  given  then PG defaults to zero which is the "Supported VPD
163              pages" VPD page.
164

NOTES

166       Some devices with weak SCSI command set implementations  lock  up  when
167       they  receive  commands they don't understand (or even response lengths
168       that they don't expect). Such devices need to be treated carefully, use
169       the  '--len=36'  option. Without this option this utility will issue an
170       initial standard INQUIRY requesting 36 bytes of response data.  If  the
171       device indicates it could have supplied more data then a second INQUIRY
172       is issued to fetch the longer response. That second command may lock up
173       faulty devices.
174
175       ATA  or ATAPI devices that use a SCSI to ATA Translation layer (see SAT
176       at www.t10.org) may support the ATA Information VPD page. This  returns
177       the  IDENTIFY  (PACKET)  DEVICE response amongst other things.  The ATA
178       Information VPD page can be fetched with '--page=ai'.
179
180       In the INQUIRY standard response there is a 'MultiP' flag which is  set
181       when  the  device  has  2 or more ports. Some vendors use the preceding
182       vendor specific ('VS') bit to indicate which port is being accessed  by
183       the  INQUIRY  command  (0  -> relative port 1 (port "a"), 1 -> relative
184       port 2 (port "b")). When the 'MultiP' flag is set, the preceding vendor
185       specific  bit  is  shown in parentheses. SPC-3 compliant devices should
186       use the device identification VPD page (0x83) to  show  which  port  is
187       being  used  for  access and the SCSI ports VPD page (0x88) to show all
188       available ports on the device.
189
190       In the 2.4 series of Linux kernels the DEVICE must be  a  SCSI  generic
191       (sg)  device.  In  the  2.6  series block devices (e.g. disks and ATAPI
192       DVDs) can also be specified. For example "sg_inq /dev/sda" will work in
193       the  2.6  series  kernels. From lk 2.6.6 other SCSI "char" device names
194       may be used as well (e.g. "/dev/st0m").
195
196       The number of bytes output by --hex and --raw is 36 bytes or the number
197       given  to  --len=LEN  (or  --maxlen=LEN). That number is reduced if the
198       "resid" returned by the HBA indicates less bytes were  sent  back  from
199       DEVICE.
200

ATA DEVICES

202       There  are two major types of ATA devices: non-packet devices (e.g. ATA
203       disks) and packet devices (ATAPI). The majority of  ATAPI  devices  are
204       CD/DVD/BD drives in which the ATAPI transport carries the MMC set (i.e.
205       a SCSI command set). Further, both types of ATA  devices  can  be  con‐
206       nected  to a host computer via a "SCSI" (or some other) transport. When
207       an ATA disk is controlled via a SCSI (or non-ATA)  transport  then  two
208       approaches  are  commonly used: tunnelling (e.g. STP in Serial Attached
209       SCSI (SAS)) or by emulating a SCSI device (e.g.  with  a  SCSI  to  ATA
210       translation  layer,  see  SAT  at www.t10.org ). Even when the physical
211       transport to the host computer is ATA (especially in the case of  SATA)
212       the  operating  system  may  choose  to  put  a SAT layer in the driver
213       "stack" (e.g. libata in Linux).
214
215       The main identifying command for any SCSI device  is  an  INQUIRY.  The
216       corresponding  command  for an ATA non-packet device is IDENTIFY DEVICE
217       while for an ATA packet device it is IDENTIFY PACKET DEVICE.
218
219       When this utility is invoked for an  ATAPI  device  (e.g.  a  CD/DVD/BD
220       drive with "sg_inq /dev/hdc") then a SCSI INQUIRY is sent to the device
221       and if it responds then the response to decoded  and  output  and  this
222       utility  exits.  To  see the response for an ATA IDENTIFY PACKET DEVICE
223       command add the --ata option (e.g. "sg_inq --ata /dev/hdc).
224
225       This utility doesn't decode the response to an  ATA  IDENTIFY  (PACKET)
226       DEVICE  command,  hdparm does a good job at that. The '-HHH' option has
227       been added for use with either the '--ata'  or  '--page=ai'  option  to
228       produce  a format acceptable to "hdparm --Istdin".  An example: 'sg_inq
229       --ata -HHH /dev/hdc | hdparm --Istdin'. See hdparm.
230

EXIT STATUS

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

OLDER COMMAND LINE OPTIONS

236       The  options  in  this  section  were  the only ones available prior to
237       sg3_utils version 1.23 . In sg3_utils  version  1.23  and  later  these
238       older  options can be selected by either setting the SG3_UTILS_OLD_OPTS
239       environment variable or using --old (or -O) as the first option.
240
241       -36    only requests 36 bytes of response data for an INQUIRY. Further‐
242              more  even if the device indicates in its response it can supply
243              more data, a second (longer) INQUIRY is not performed. This is a
244              paranoid setting.  Equivalent to '--len=36' in the main descrip‐
245              tion.
246
247       -a     fetch  the  ATA  Information  VPD  page  [0x89].  Equivalent  to
248              '--page=ai' in the main description. This page is defined in SAT
249              (see at www.t10.org).
250
251       -A     Assume given DEVICE is an ATA or ATAPI  device.   Equivalent  to
252              --ata in the main description.
253
254       -b     decodes  the  Block  Limits  VPD  page  [0xb0].   Equivalent  to
255              '--page=bl' in the main description. This  page  is  defined  in
256              SBC-2 (see www.t10.org).
257
258       -c     set the Command Support Data (CmdDt) bit (defaults to clear(0)).
259              Used in
260               conjunction with the -o=OPCODE_PG option to  specify  the  SCSI
261              command  opcode  to  query.  Equivalent  to  --cmddt in the main
262              description.
263
264       -cl    lists the command data for all supported commands  (followed  by
265              the  command  name)  by  looping  through  all 256 opcodes. This
266              option uses the  CmdDt  bit  which  is  now  obsolete.  See  the
267              sg_opcodes(8)  utility.   Equivalent to '--cmddt --cmddt' in the
268              main description.
269
270       -d     decodes depending on context. If -e  option  is  given,  or  any
271              option that implies -e (e.g. '-i' or '-p=80'), then this utility
272              attempts to decode the indicated VPD page.  Otherwise  the  ver‐
273              sion  descriptors  (if  any)  are  listed  following  a standard
274              INQUIRY response. In the version descriptors  sense,  equivalent
275              to --descriptors in the main description.
276
277       -e     enable  (i.e.  sets) the Vital Product Data (EVPD) bit (defaults
278              to clear(0)).  Used in conjunction with the -p=VPD_PG option  to
279              specify  the  VPD  page to fetch. If -p=VPD_PG is not given then
280              VPD page 0 (list supported VPD pages) is assumed.
281
282       -h     outputs INQUIRY response in hex rather than trying to decode it.
283              Equivalent to --hex in the main description.
284
285       -H     same action as -h.  Equivalent to --hex in the main description.
286
287       -i     decodes the Device Identification VPD page [0x83]. Equivalent to
288              --id in the main description. This page is made  up  of  several
289              "designation  descriptors".  If -h is given then each descriptor
290              header is decoded and the identifier itself is  output  in  hex.
291              To see the whole VPD 0x83 page response in hex use '-p=83 -h'.
292
293       -m     decodes the Management network addresses VPD page [0x85]. Equiv‐
294              alent to '--page=mna' in the main description.
295
296       -M     decodes the Mode page policy VPD  page  [0x87].   Equivalent  to
297              '--page=mpp' in the main description.
298
299       -N, --new
300              Switch to the newer style options.
301
302       -o=OPCODE_PG
303              used  in  conjunction with the -e or -c option. If neither given
304              then the -e option assumed. When the -e option is also given (or
305              assumed)  then  the argument to this option is the VPD page num‐
306              ber.  The argument is interpreted as hexadecimal and is expected
307              to be in the range 0 to ff inclusive. Only VPD page 0 is decoded
308              and it lists supported VPD pages and their names (if known).  To
309              decode  the  mandatory device identification page (0x83) use the
310              -i option. A now obsolete usage is when the -c option  is  given
311              in  which  case  the  argument to this option is assumed to be a
312              command opcode number. Recent SCSI draft  standards  have  moved
313              this   facility  to  a  separate  command  (see  sg_opcodes(8)).
314              Defaults to 0 so if -e is given without  this  option  then  VPD
315              page 0 is output.
316
317       -p=VPD_PG
318              same  action  as  -o=OPCODE_PG  option described in the previous
319              entry.  Since the opcode value with the CmdDt is  now  obsolete,
320              the  main  use of this option is to specify the VPD page number.
321              The argument is interpreted as hexadecimal and is expected to be
322              in the range 0 to ff inclusive.  Defaults to 0 so if -e is given
323              without this option then VPD page 0 is output.
324
325       -P     decodes the Unit Path Report VPD page [0xc0] which is  EMC  spe‐
326              cific.  Equivalent to '--page=upr' in the main description.
327
328       -r     outputs  the  response in binary to stdout.  Equivalent to --raw
329              in the main description.  Can be used  twice  (i.e.  '-rr'  (and
330              '-HHH'  has  same  effect)) and if used with the -A or -a option
331              yields output with the same format as "cat /proc/ide/hd<x>/iden‐
332              tify" so that it can then be piped to "hdparm --Istdin".
333
334       -s     decodes   the   SCSI  Ports  VPD  page  [0x88].   Equivalent  to
335              '--page=sp' in the main description.
336
337       -u     equivalent to '--export' in the main description.
338
339       -v     increase level of verbosity. Can be used multiple times.
340
341       -V     print out version string then exit.
342
343       -x     decodes the Extended INQUIRY data VPD [0x86]  page.   Equivalent
344              to '--page=ei' in the main description.
345
346       -?     output usage message and exit. Ignore all other parameters.
347

EXAMPLES

349       The  examples  in this page use Linux device names. For suitable device
350       names in other supported Operating Systems  see  the  sg3_utils(8)  man
351       page.
352
353       To view the standard inquiry response use without options:
354
355          sg_inq /dev/sda
356
357       Some  SCSI  devices  include version descriptors indicating the various
358       SCSI standards and drafts they support. They can be viewed with:
359
360          sg_inq -d /dev/sda
361
362       Modern SCSI devices include Vital Product Data (VPD)pages which can  be
363       viewed  with  the SCSI INQUIRY command. To list the supported VPD pages
364       (but not their contents) try:
365
366          sg_inq -e /dev/sda
367
368       Some VPD pages can be read with the sg_inq utility but a newer  utility
369       called sg_vpd specializes in showing their contents. The sdparm utility
370       can also be used to show the contents of VPD pages.
371
372       Further examples of sg_inq together with some  typical  output  can  be
373       found on http://sg.danny.cz/sg/sg3_utils.html web page.
374

AUTHOR

376       Written by Douglas Gilbert
377

REPORTING BUGS

379       Report bugs to <dgilbert at interlog dot com>.
380
382       Copyright © 2001-2013 Douglas Gilbert
383       This  software is distributed under the GPL version 2. There is NO war‐
384       ranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PUR‐
385       POSE.
386

SEE ALSO

388       sg_opcodes(8), sg_vpd(8), sdparm(8), hdparm(8), sgdiag(scsirastools)
389
390
391
392sg3_utils-1.36                     May 2013                          SG_INQ(8)
Impressum