1SG_INQ(8) SG3_UTILS SG_INQ(8)
2
3
4
6 sg_inq - issue SCSI INQUIRY command and/or decode its response
7
9 sg_inq [--ata] [--block=0|1] [--cmddt] [--descriptors] [--export]
10 [--extended] [--force] [--help] [--hex] [--id] [--inhex=FN] [--len=LEN]
11 [--long] [--maxlen=LEN] [--only] [--page=PG] [--raw] [--vendor] [--ver‐
12 bose] [--version] [--vpd] DEVICE
13
14 sg_inq [-36] [-a] [-A] [-b] [--B=0|1] [-c] [-cl] [-d] [-e] [-f] [-h]
15 [-H] [-i] [-I=FN] [-l=LEN] [-L] [-m] [-M] [-o] [-p=VPD_PG] [-P] [-r]
16 [-s] [-u] [-v] [-V] [-x] [-36] [-?] DEVICE
17
19 This utility, when DEVICE is given, sends a SCSI INQUIRY command to it
20 then outputs the response. All SCSI devices are meant to respond to a
21 "standard" INQUIRY command with at least a 36 byte response (in SCSI 2
22 and higher). An INQUIRY is termed as "standard" when both the EVPD and
23 CmdDt (now obsolete) bits are clear.
24
25 Alternatively the --inhex=FN option can be given. In this case FN is
26 assumed to be a file name ('-' for stdin) containing ASCII hexadecimal
27 representing an INQUIRY response.
28
29 This utility supports two command line syntaxes. The preferred one is
30 shown first in the synopsis and is described in the main OPTIONS sec‐
31 tion. A later section titled OLDER COMMAND LINE OPTIONS describes the
32 second group of options.
33
34 An important "non-standard" INQUIRY page is the Device Identification
35 Vital Product Data (VPD) page [0x83]. Since SPC-3, support for this
36 page is mandatory. The --id option decodes this page. New VPD page
37 information is no longer being added to this utility. To get informa‐
38 tion on new VPD pages see the sg_vpd(8) or sdparm(8) utilities.
39
40 In Linux, if the DEVICE exists and the SCSI INQUIRY fails (e.g. because
41 the SG_IO ioctl is not supported) then an ATA IDENTIFY (PACKET) DEVICE
42 is tried. If it succeeds then device identification strings are output.
43 The --raw and --hex options can be used to manipulate the output. If
44 the --ata option is given then the SCSI INQUIRY is not performed and
45 the DEVICE is assumed to be ATA (or ATAPI). For more information see
46 the ATA DEVICES section below.
47
48 In some operating systems a NVMe device (e.g. SSD) may be given as the
49 DEVICE. For more information see the NVME DEVICES section below.
50
51 The reference document used for interpreting an INQUIRY is T10/BSR
52 INCITS 502 Revision 19 which is draft SPC-5 revision 19, 14 February
53 2018). It can be found at http://www.t10.org . Obsolete and reserved
54 items in the standard INQUIRY response output are displayed in square
55 brackets.
56
58 Arguments to long options are mandatory for short options as well. The
59 options are arranged in alphabetical order based on the long option
60 name.
61
62 -a, --ata
63 Assume given DEVICE is an ATA or ATAPI device which can receive
64 ATA commands from the host operating system. Skip the SCSI
65 INQUIRY command and use either the ATA IDENTIFY DEVICE command
66 (for non-packet devices) or the ATA IDENTIFY PACKET DEVICE com‐
67 mand. To show the response in hex, add a '--verbose' option.
68 This option is only available in Linux.
69
70 -B, --block=0|1
71 this option controls how the file handle to the DEVICE is
72 opened. If this argument is 0 then the open is non-blocking. If
73 the argument is 1 then the open is blocking. In Unix a
74 non-blocking open is indicated by a O_NONBLOCK flag while a
75 blocking open is indicated by the absence of that flag. The
76 default value depends on the operating system and the type of
77 DEVICE node. For Linux pass-throughs (i.e. the sg and bsg driv‐
78 ers) the default is 0.
79
80 -c, --cmddt
81 set the Command Support Data (CmdDt) bit (defaults to clear(0)).
82 Used in conjunction with the --page=PG option where PG specifies
83 the SCSI command opcode to query. When used twice (e.g. '-cc')
84 this utility forms a list by looping over all 256 opcodes (0 to
85 255 inclusive) only outputting a line for commands that are
86 found. The CmdDt bit is now obsolete; it has been replaced by
87 the REPORT SUPPORTED OPERATION CODES command, see the
88 sg_opcodes(8) utility.
89
90 -d, --descriptors
91 decodes and prints the version descriptors found in a standard
92 INQUIRY response. There are up to 8 of them. Version descriptors
93 indicate which versions of standards and/or drafts the DEVICE
94 complies with. The normal components of a standard INQUIRY are
95 output (typically from the first 36 bytes of the response) fol‐
96 lowed by the version descriptors if any.
97
98 -e see entry below for --vpd.
99
100 -f, --force
101 As a sanity check, the normal action when fetching VPD pages
102 other than page 0x0 (the "Supported VPD pages" VPD page), is to
103 first fetch page 0x0 and only if the requested page is one of
104 the supported pages, to go ahead and fetch the requested page.
105 When this option is given, skip checking of VPD page 0x0 before
106 accessing the requested VPD page. The prior check of VPD page
107 0x0 is known to crash certain USB devices, so use with care.
108
109 -u, --export
110 prints out information obtained from the device. The output can
111 be modified by selecting a VPD page with PG (from --page=PG). If
112 the device identification VPD page 0x83 is given it prints out
113 information in the form: "SCSI_IDENT_<assoc>_<type>=<ident>" to
114 stdout. If the device serial number VPD page 0x80 is given it
115 prints out information in the form: "SCSI_SERIAL=<ident>". Other
116 VPD pages are not supported. If no VPD page is given it prints
117 out information in the form: "SCSI_VENDOR=<vendor>",
118 "SCSI_MODEL=<model>", and "SCSI_REVISION=<rev>", taken from the
119 standard inquiry. This may be useful for tools like udev(7) in
120 Linux.
121
122 -E, -x, --extended
123 prints the extended INQUIRY VPD page [0x86].
124
125 -h, --help
126 print out the usage message then exit. When used twice, after
127 the usage message, there is a list of available abbreviations
128 than can be given to the --page=PG option.
129
130 -H, --hex
131 rather than decode a standard INQUIRY response, a VPD page or
132 command support data; print out the response in hex and send the
133 output to stdout. Error messages and warnings are typically
134 output to stderr. When used twice with the ATA Information VPD
135 page [0x89] decodes the start of the response then outputs the
136 ATA IDENTIFY (PACKET) DEVICE response in hexadecimal bytes (not
137 16 bit words). When used three times with the ATA Information
138 VPD page [0x89] or the --ata option, this utility outputs the
139 ATA IDENTIFY (PACKET) DEVICE response in hexadecimal words suit‐
140 able for input to 'hdparm --Istdin'. See note below.
141 To generate output suitable for placing in a file that can be
142 used by a later invocation with the --inhex=FN option, use the
143 '-HHHH' option (e.g. 'sg_inq -p di -HHHH /dev/sg3 >
144 dev_id.hex').
145
146 -i, --id
147 prints the device identification VPD page [0x83].
148
149 -I, --inhex=FN
150 FN is expected to be a file name (or '-' for stdin) which con‐
151 tains ASCII hexadecimal or binary representing an INQUIRY
152 (including VPD page) response. This utility will then decode
153 that response. It is preferable to also supply the --page=PG
154 option, if not this utility will attempt to guess which VPD page
155 (or standard INQUIRY) that the response is associated with. The
156 hexadecimal should be arranged as 1 or 2 digits representing a
157 byte each of which is whitespace or comma separated. Anything
158 from and including a hash mark to the end of a line is ignored.
159 If the --raw option is also given then FN is treated as binary.
160
161 -l, --len=LEN
162 the number LEN is the "allocation length" field in the INQUIRY
163 cdb. This is the (maximum) length of the response returned by
164 the device. The default value of LEN is 0 which is interpreted
165 as: first request is for 36 bytes and if necessary execute
166 another INQUIRY if the "additional length" field in the response
167 indicates that more than 36 bytes is available.
168 If LEN is greater than 0 then only one INQUIRY command is per‐
169 formed. This means that the Serial Number (obtained from the
170 Serial Number VPD pgae (0x80)) is not fetched and therefore not
171 printed. See the NOTES section below about "36 byte INQUIRYs".
172
173 -L, --long
174 this option causes more information to be decoded from the Iden‐
175 tify command sent to a NVMe DEVICE.
176
177 -m, --maxlen=LEN
178 this option has the same action as the --len=LEN option above.
179 It has been added for compatibility with the sg_vpd, sg_modes
180 and sg_logs utilities.
181
182 -O, --old
183 Switch to older style options. Please use as first option on the
184 command line.
185
186 -o, --only
187 Do not attempt to additionally retrieve the serial number VPD
188 page (0x80) to enhance the output of a standard INQUIRY. So with
189 this option given and no others, this utility will send a stan‐
190 dard INQUIRY SCSI command and decode its response. No other SCSI
191 commands will be sent to the DEVICE. Without this option an
192 additional SCSI command is sent: a (non-standard) SCSI INQUIRY
193 to fetch the Serial Number VPD page. However the Serial Number
194 VPD page is not mandatory (while the Device Identification page
195 is mandatory but a billion USB keys ignore that) and may cause
196 nuisance error reports.
197 For NVMe devices only the Identify controller is performed, even
198 if the DEVICE includes a namespace identifier. For example in
199 FreeBSD given a DEVICE named /dev/nvme0ns1 then an Identify con‐
200 troller is sent to /dev/nvme0 and nothing is sent to its "ns1"
201 (first namespace).
202
203 -p, --page=PG
204 the PG argument can be either a number of an abbreviation for a
205 VPD page. To enumerate the available abbreviations for VPD pages
206 use '-hh' or a bad abbreviation (e.g, '--page=xxx'). When the
207 --cmddt option is given (once) then PG is interpreted as an
208 opcode number (so VPD page abbreviations make little sense).
209 If PG is a negative number, then a standard INQUIRY is per‐
210 formed. This can be used to override some guessing logic associ‐
211 ated with the --inhex=FN option.
212 If PG is not found in the 'Supported VPD pages' VPD page (0x0)
213 then EDOM is returned. To bypass this check use the --force
214 option.
215
216 -r, --raw
217 in the absence of --inhex=FN then the output response is in
218 binary. The output should be piped to a file or another utility
219 when this option is used. The binary is sent to stdout, and
220 errors are sent to stderr.
221 If used with --inhex=FN then the contents of FN is treated as
222 binary.
223
224 -s, --vendor
225 output a standard INQUIRY response's vendor specific fields from
226 offset 36 to 55 in ASCII. When used twice (i.e. '-ss') also out‐
227 put the vendor specific field from offset 96 in ASCII. This is
228 only done if the data passes some simple sanity checks.
229
230 -v, --verbose
231 increase level of verbosity. Can be used multiple times.
232
233 -V, --version
234 print out version string then exit.
235
236 -e, --vpd
237 set the Enable Vital Product Data (EVPD) bit (defaults to
238 clear(0)). Used in conjunction with the --page=PG option where
239 PG specifies the VPD page number to query. If the --page=PG is
240 not given then PG defaults to zero which is the "Supported VPD
241 pages" VPD page. A more up to date decoding of VPD pages can be
242 found in the sg_vpd(8) utility.
243
245 Some devices with weak SCSI command set implementations lock up when
246 they receive commands they don't understand (and some lock up if they
247 receive response lengths that they don't expect). Such devices need to
248 be treated carefully, use the '--len=36' option. Without this option
249 this utility will issue an initial standard INQUIRY requesting 36 bytes
250 of response data. If the device indicates it could have supplied more
251 data then a second INQUIRY is issued to fetch the longer response. That
252 second command may lock up faulty devices.
253
254 ATA or ATAPI devices that use a SCSI to ATA Translation layer (see SAT
255 at www.t10.org) may support the SCSI ATA INFORMATION VPD page. This
256 returns the IDENTIFY (PACKET) DEVICE response amongst other things.
257 The ATA Information VPD page can be fetched with '--page=ai'.
258
259 In the INQUIRY standard response there is a 'MultiP' flag which is set
260 when the device has 2 or more ports. Some vendors use the preceding
261 vendor specific ('VS') bit to indicate which port is being accessed by
262 the INQUIRY command (0 -> relative port 1 (port "a"), 1 -> relative
263 port 2 (port "b")). When the 'MultiP' flag is set, the preceding vendor
264 specific bit is shown in parentheses. SPC-3 compliant devices should
265 use the device identification VPD page (0x83) to show which port is
266 being used for access and the SCSI ports VPD page (0x88) to show all
267 available ports on the device.
268
269 In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic
270 (sg) device. In the 2.6 series and later block devices (e.g. disks and
271 ATAPI DVDs) can also be specified. For example "sg_inq /dev/sda" will
272 work in the 2.6 series kernels. From lk 2.6.6 other SCSI "char" device
273 names may be used as well (e.g. "/dev/st0m").
274
275 The number of bytes output by --hex and --raw is 36 bytes or the number
276 given to --len=LEN (or --maxlen=LEN). That number is reduced if the
277 "resid" returned by the HBA indicates less bytes were sent back from
278 DEVICE.
279
280 The DEVICE is opened with a read-only flag (e.g. in Unix with the
281 O_RDONLY flag).
282
284 There are two major types of ATA devices: non-packet devices (e.g. ATA
285 disks) and packet devices (ATAPI). The majority of ATAPI devices are
286 CD/DVD/BD drives in which the ATAPI transport carries the MMC set (i.e.
287 a SCSI command set). Further, both types of ATA devices can be con‐
288 nected to a host computer via a "SCSI" (or some other) transport. When
289 an ATA disk is controlled via a SCSI (or non-ATA) transport then two
290 approaches are commonly used: tunnelling (e.g. STP in Serial Attached
291 SCSI (SAS)) or by emulating a SCSI device (e.g. with a SCSI to ATA
292 translation layer, see SAT at www.t10.org ). Even when the physical
293 transport to the host computer is ATA (especially in the case of SATA)
294 the operating system may choose to put a SAT layer in the driver
295 "stack" (e.g. libata in Linux).
296
297 The main identifying command for any SCSI device is an INQUIRY. The
298 corresponding command for an ATA non-packet device is IDENTIFY DEVICE
299 while for an ATA packet device it is IDENTIFY PACKET DEVICE.
300
301 When this utility is invoked for an ATAPI device (e.g. a CD/DVD/BD
302 drive with "sg_inq /dev/hdc") then a SCSI INQUIRY is sent to the device
303 and if it responds then the response to decoded and output and this
304 utility exits. To see the response for an ATA IDENTIFY PACKET DEVICE
305 command add the --ata option (e.g. "sg_inq --ata /dev/hdc).
306
307 This utility doesn't decode the response to an ATA IDENTIFY (PACKET)
308 DEVICE command, hdparm does a good job at that. The '-HHH' option has
309 been added for use with either the '--ata' or '--page=ai' option to
310 produce a format acceptable to "hdparm --Istdin". An example: 'sg_inq
311 --ata -HHH /dev/hdc | hdparm --Istdin'. See hdparm.
312
314 Currently these device are typically SSDs (Solid State Disks) directly
315 connected to a PCIe connector or via a specialized connector such as a
316 M2 connector. Linux and FreeBSD treat NVMe storage devices as separate
317 from SCSI storage with device names like /dev/nvme0n1 (in Linux) and
318 /dev/nvme0ns1 (in FreeBSD). The NVM Express group has a document titled
319 "NVM Express: SCSI Translation Reference" which defines a partial "SCSI
320 to NVMe Translation Layer" often known by its acronym: SNTL.
321
322 On operating systems where it is supported by this package, this util‐
323 ity will detect NVMe storage devices directly connected and send an
324 Identify controller NVMe Admin command and decode its response. A NVMe
325 controller is architecturally similar to a SCSI target device. If the
326 NVMe DEVICE indicates a namespace then an Identify namespace NVMe Admin
327 command is sent to that namespace and its response is decoded. Names‐
328 paces are numbered sequentially starting from 1. Namespaces are similar
329 to SCSI Logical Units and their identifiers (nsid_s) can be thought of
330 as SCSI LUNs. In the Linux and FreeBSD example device names above the
331 "n1" and the "ns1" parts indicate nsid 1 . If no namespace is given in
332 the DEVICE then all namespaces found in the controller are sent Iden‐
333 tify namespace commands and the responses are decoded.
334
335 To get more details in the response use the --long option. To only get
336 the controller's Identify decoded use the --only option.
337
338 It is possible that even though the DEVICE presents as a NVMe device,
339 it has a SNTL and accepts SCSI commands. In this case to send a SCSI
340 INQUIRY command (and fetch its VPD pages) use 'sg_vpd -p sinq <dev>'
341 (or to get VPD pages: 'sg_vpd -p <vpd_page> <dev>').
342
344 The exit status of sg_inq is 0 when it is successful. Otherwise see the
345 sg3_utils(8) man page.
346
348 The options in this section were the only ones available prior to
349 sg3_utils version 1.23 . Since then this utility defaults to the newer
350 command line options which can be overridden by using --old (or -O) as
351 the first option. See the ENVIRONMENT VARIABLES section for another way
352 to force the use of these older command line options.
353
354 -36 only requests 36 bytes of response data for an INQUIRY. Further‐
355 more even if the device indicates in its response it can supply
356 more data, a second (longer) INQUIRY is not performed. This is a
357 paranoid setting. Equivalent to '--len=36' in the OPTIONS sec‐
358 tion.
359
360 -a fetch the ATA Information VPD page [0x89]. Equivalent to
361 '--page=ai' in the OPTIONS section. This page is defined in SAT
362 (see at www.t10.org).
363
364 -A Assume given DEVICE is an ATA or ATAPI device. Equivalent to
365 --ata in the OPTIONS section.
366
367 -b decodes the Block Limits VPD page [0xb0]. Equivalent to
368 '--page=bl' in the OPTIONS section. This page is defined in
369 SBC-2 (see www.t10.org) and later.
370
371 -B=0|1 equivalent to --block=0|1 in OPTIONS section.
372
373 -c set the Command Support Data (CmdDt) bit (defaults to clear(0)).
374 Used in conjunction with the -p=VPD_PG option to specify the
375 SCSI command opcode to query. Equivalent to --cmddt in the
376 OPTIONS section.
377
378 -cl lists the command data for all supported commands (followed by
379 the command name) by looping through all 256 opcodes. This
380 option uses the CmdDt bit which is now obsolete. See the
381 sg_opcodes(8) utility. Equivalent to '--cmddt --cmddt' in the
382 OPTIONS section.
383
384 -d decodes depending on context. If -e option is given, or any
385 option that implies -e (e.g. '-i' or '-p=80'), then this utility
386 attempts to decode the indicated VPD page. Otherwise the ver‐
387 sion descriptors (if any) are listed following a standard
388 INQUIRY response. In the version descriptors sense, equivalent
389 to --descriptors in the OPTIONS section.
390
391 -e enable (i.e. sets) the Vital Product Data (EVPD) bit (defaults
392 to clear(0)). Used in conjunction with the -p=VPD_PG option to
393 specify the VPD page to fetch. If -p=VPD_PG is not given then
394 VPD page 0 (list supported VPD pages) is assumed.
395
396 -f Equivalent to --force in the OPTIONS section.
397
398 -h outputs INQUIRY response in hex rather than trying to decode it.
399 Equivalent to --hex in the OPTIONS section.
400
401 -H same action as -h. Equivalent to --hex in the OPTIONS section.
402
403 -i decodes the Device Identification VPD page [0x83]. Equivalent to
404 --id in the OPTIONS section. This page is made up of several
405 "designation descriptors". If -h is given then each descriptor
406 header is decoded and the identifier itself is output in hex. To
407 see the whole VPD 0x83 page response in hex use '-p=83 -h'.
408
409 -I=FN equivalent to --inhex=FN in the OPTIONS section.
410
411 -l=LEN equivalent to --len=LEN in the OPTIONS section.
412
413 -L equivalent to --long in the OPTIONS section.
414
415 -m decodes the Management network addresses VPD page [0x85]. Equiv‐
416 alent to '--page=mna' in the OPTIONS section.
417
418 -M decodes the Mode page policy VPD page [0x87]. Equivalent to
419 '--page=mpp' in the OPTIONS section.
420
421 -N, --new
422 Switch to the newer style options.
423
424 -o equivalent to --only in the OPTIONS section.
425
426 -p=VPD_PG
427 used in conjunction with the -e or -c option. If neither given
428 then the -e option assumed. When the -e option is also given (or
429 assumed) then the argument to this option is the VPD page num‐
430 ber. The argument is interpreted as hexadecimal and is expected
431 to be in the range 0 to ff inclusive. Only VPD page 0 is decoded
432 and it lists supported VPD pages and their names (if known). To
433 decode the mandatory device identification page (0x83) use the
434 -i option. A now obsolete usage is when the -c option is given
435 in which case the argument to this option is assumed to be a
436 command opcode number. Recent SCSI draft standards have moved
437 this facility to a separate command (see sg_opcodes(8)).
438 Defaults to 0 so if -e is given without this option then VPD
439 page 0 is output.
440
441 -P decodes the Unit Path Report VPD page [0xc0] which is EMC spe‐
442 cific. Equivalent to '--page=upr' in the OPTIONS section.
443
444 -r outputs the response in binary to stdout. Equivalent to --raw
445 in the OPTIONS section. Can be used twice (i.e. '-rr' (and
446 '-HHH' has same effect)) and if used with the -A or -a option
447 yields output with the same format as "cat /proc/ide/hd<x>/iden‐
448 tify" so that it can then be piped to "hdparm --Istdin".
449
450 -s decodes the SCSI Ports VPD page [0x88]. Equivalent to
451 '--page=sp' in the OPTIONS section.
452
453 -u equivalent to '--export' in the OPTIONS section.
454
455 -v increase level of verbosity. Can be used multiple times.
456
457 -V print out version string then exit.
458
459 -x decodes the Extended INQUIRY data VPD [0x86] page. Equivalent
460 to '--page=ei' in the OPTIONS section.
461
462 -? output usage message and exit. Ignore all other parameters.
463
465 The examples in this page use Linux device names. For suitable device
466 names in other supported Operating Systems see the sg3_utils(8) man
467 page.
468
469 To view the standard inquiry response use without options:
470
471 sg_inq /dev/sda
472
473 Some SCSI devices include version descriptors indicating the various
474 SCSI standards and drafts they support. They can be viewed with:
475
476 sg_inq -d /dev/sda
477
478 Modern SCSI devices include Vital Product Data (VPD)pages which can be
479 viewed with the SCSI INQUIRY command. To list the supported VPD pages
480 (but not their contents) try:
481
482 sg_inq -e /dev/sda
483
484 Some VPD pages can be read with the sg_inq utility but a newer utility
485 called sg_vpd specializes in showing their contents. The sdparm utility
486 can also be used to show the contents of VPD pages.
487
488 Further examples of sg_inq together with some typical output can be
489 found on http://sg.danny.cz/sg/sg3_utils.html web page.
490
492 Since sg3_utils version 1.23 the environment variable
493 SG3_UTILS_OLD_OPTS can be given. When it is present this utility will
494 expect the older command line options. So the presence of this environ‐
495 ment variable is equivalent to using --old (or -O) as the first command
496 line option.
497
499 Written by Douglas Gilbert
500
502 Report bugs to <dgilbert at interlog dot com>.
503
505 Copyright © 2001-2018 Douglas Gilbert
506 This software is distributed under the GPL version 2. There is NO war‐
507 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
508 POSE.
509
511 sg_opcodes(8), sg_vpd(8), sg_logs(8), sg_modes(8), sdparm(8),
512 hdparm(8), sgdiag(scsirastools)
513
514
515
516sg3_utils-1.43 August 2018 SG_INQ(8)