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] [--help] [--hex] [--id] [--inhex=FN] [--len=LEN]
11 [--maxlen=LEN] [--page=PG] [--raw] [--vendor] [--verbose] [--version]
12 [--vpd] DEVICE
13
14 sg_inq [-36] [-a] [-A] [-b] [--B=0|1] [-c] [-cl] [-d] [-e] [-h] [-H]
15 [-i] [-I=FN] [-l=LEN] [-m] [-M] [-o=OPCODE_PG] [-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).
46
47 The reference document used for interpreting an INQUIRY is T10/BSR
48 INCITS 502 Revision 07 which is draft SPC-5 revision 07, 26 November
49 2015). It can be found at http://www.t10.org . Obsolete and reserved
50 items in the standard INQUIRY response output are displayed in brack‐
51 ets. The reference document for the ATA IDENTIFY (PACKET) DEVICE com‐
52 mand is ATA8-ACS found at http://www.t13.org .
53
55 Arguments to long options are mandatory for short options as well. The
56 options are arranged in alphabetical order based on the long option
57 name.
58
59 -a, --ata
60 Assume given DEVICE is an ATA or ATAPI device which can receive
61 ATA commands from the host operating system. Skip the SCSI
62 INQUIRY command and use either the ATA IDENTIFY DEVICE command
63 (for non-packet devices) or the ATA IDENTIFY PACKET DEVICE com‐
64 mand. To show the response in hex, add a '--verbose' option.
65 This option is only available in Linux.
66
67 -B, --block=0|1
68 this option controls how the file handle to the DEVICE is
69 opened. If this argument is 0 then the open is non-blocking. If
70 the argument is 1 then the open is blocking. In Unix a
71 non-blocking open is indicated by a O_NONBLOCK flag while a
72 blocking open is indicated by the absence of that flag. The
73 default value depends on the operating system and the type of
74 DEVICE node. For Linux pass-throughs (i.e. the sg and bsg driv‐
75 ers) the default is 0.
76
77 -c, --cmddt
78 set the Command Support Data (CmdDt) bit (defaults to clear(0)).
79 Used in conjunction with the --page=PG option where PG specifies
80 the SCSI command opcode to query. When used twice (e.g. '-cc')
81 this utility forms a list by looping over all 256 opcodes (0 to
82 255 inclusive) only outputting a line for found commands. The
83 CmdDt bit is now obsolete. It has been replaced by the REPORT
84 SUPPORTED OPERATION CODES command, see the sg_opcodes(8) util‐
85 ity.
86
87 -d, --descriptors
88 decodes and prints the version descriptors found in a standard
89 INQUIRY response. There are up to 8 of them. Version descriptors
90 indicate which versions of standards and/or drafts the DEVICE
91 complies with. The normal components of a standard INQUIRY are
92 output (typically from the first 36 bytes of the response) fol‐
93 lowed by the version descriptors if any.
94
95 -e see entry below for --vpd.
96
97 -u, --export
98 prints out information obtained from the device. The output can
99 be modified by selecting a VPD page with PG (from --page=PG). If
100 the device identification VPD page 0x83 is given it prints out
101 information in the form: "SCSI_IDENT_<assoc>_<type>=<ident>" to
102 stdout. If the device serial number VPD page 0x80 is given it
103 prints out information in the form: "SCSI_SERIAL=<ident>". Other
104 VPD pages are not supported. If no VPD page is given it prints
105 out information in the form: "SCSI_VENDOR=<vendor>",
106 "SCSI_MODEL=<model>", and "SCSI_REVISION=<rev>", taken from the
107 standard inquiry. This may be useful for tools like udev(7) in
108 Linux.
109
110 -E, -x, --extended
111 prints the extended INQUIRY VPD page [0x86].
112
113 -h, --help
114 print out the usage message then exit. When used twice, after
115 the usage message, there is a list of available abbreviations
116 than can be given to the --page=PG option.
117
118 -H, --hex
119 rather than decode a standard INQUIRY response, a VPD page or
120 command support data; print out the response in hex to stdout.
121 Error messages and warnings are typically output to stderr. When
122 used twice with the ATA Information VPD page [0x89] decodes the
123 start of the response then outputs the ATA IDENTIFY (PACKET)
124 DEVICE response in hexadecimal bytes (not 16 bit words). When
125 used three times with the ATA Information VPD page [0x89] or the
126 --ata option, this utility outputs the ATA IDENTIFY (PACKET)
127 DEVICE response in hexadecimal words suitable for input to
128 'hdparm --Istdin'. See note below.
129 To generate output suitable for placing in a file that can be
130 used by a later invocation with the --inhex=FN option, use the
131 '-HHHH' option (e.g. 'sg_inq -p di -HHHH /dev/sg3 >
132 dev_id.hex').
133
134 -i, --id
135 prints the device identification VPD page [0x83].
136
137 -I, --inhex=FN
138 FN is expected to be a file name (or '-' for stdin) which con‐
139 tains ASCII hexadecimal or binary representing an INQUIRY
140 (including VPD page) response. This utility will then decode
141 that response. It is preferable to also supply the --page=PG
142 option, if not this utility will attempt to guess which VPD page
143 (or standard INQUIRY) the response is associated with. The hexa‐
144 decimal should be arranged as 1 or 2 digits representing a byte
145 each of which is whitespace or comma separated. Anything from
146 and including a hash mark to the end of line is ignored. If the
147 --raw option is also given then FN is treated as binary.
148
149 -l, --len=LEN
150 the number LEN is the "allocation length" field in the INQUIRY
151 cdb. This is the (maximum) length of the response to be sent by
152 the device. The default value of LEN is 0 which is interpreted
153 as: first request is for 36 bytes and if necessary execute
154 another INQUIRY if the "additional length" field in the response
155 indicates that more than 36 bytes is available. If LEN is
156 greater than 0 then only one INQUIRY command is performed. See
157 paragraph below about "36 byte INQUIRYs".
158
159 -m, --maxlen=LEN
160 this option has the same action as the --len=LEN option. It has
161 been added for compatibility with the sg_vpd, sg_modes and
162 sg_logs utilities.
163
164 -O, --old
165 switch to older style options.
166
167 -p, --page=PG
168 the PG argument can be either a number of an abbreviation for a
169 VPD page. To enumerate the available abbreviations for VPD pages
170 use '-hh' or a bad abbreviation (e.g, '--page=xxx'). When the
171 --cmddt option is given (once) then PG is interpreted as an
172 opcode number (so VPD page abbreviations make little sense).
173 If PG is a negative number, then a standard INQUIRY is per‐
174 formed. This can be used to override some guessing logic associ‐
175 ated with the --inhex=FN option.
176
177 -r, --raw
178 in the absence of --inhex=FN then output response in binary.
179 The output should be piped to a file or another utility when
180 this option is used. The binary is sent to stdout, and errors
181 are sent to stderr.
182 if used with --inhex=FN then the contents of FN is treated as
183 binary.
184
185 -s, --vendor
186 output a standard INQUIRY response's vendor specific field from
187 offset 36 to 55 in ASCII. When used twice (i.e. '-ss') also out‐
188 put the vendor specific field from offset 96 in ASCII. This is
189 only done if the data passes some simple sanity checks.
190
191 -v, --verbose
192 increase level of verbosity. Can be used multiple times.
193
194 -V, --version
195 print out version string then exit.
196
197 -e, --vpd
198 set the Enable Vital Product Data (EVPD) bit (defaults to
199 clear(0)). Used in conjunction with the --page=PG option where
200 PG specifies the VPD page number to query. If the --page=PG is
201 not given then PG defaults to zero which is the "Supported VPD
202 pages" VPD page.
203
205 Some devices with weak SCSI command set implementations lock up when
206 they receive commands they don't understand (or even response lengths
207 that they don't expect). Such devices need to be treated carefully, use
208 the '--len=36' option. Without this option this utility will issue an
209 initial standard INQUIRY requesting 36 bytes of response data. If the
210 device indicates it could have supplied more data then a second INQUIRY
211 is issued to fetch the longer response. That second command may lock up
212 faulty devices.
213
214 ATA or ATAPI devices that use a SCSI to ATA Translation layer (see SAT
215 at www.t10.org) may support the ATA Information VPD page. This returns
216 the IDENTIFY (PACKET) DEVICE response amongst other things. The ATA
217 Information VPD page can be fetched with '--page=ai'.
218
219 In the INQUIRY standard response there is a 'MultiP' flag which is set
220 when the device has 2 or more ports. Some vendors use the preceding
221 vendor specific ('VS') bit to indicate which port is being accessed by
222 the INQUIRY command (0 -> relative port 1 (port "a"), 1 -> relative
223 port 2 (port "b")). When the 'MultiP' flag is set, the preceding vendor
224 specific bit is shown in parentheses. SPC-3 compliant devices should
225 use the device identification VPD page (0x83) to show which port is
226 being used for access and the SCSI ports VPD page (0x88) to show all
227 available ports on the device.
228
229 In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic
230 (sg) device. In the 2.6 series block devices (e.g. disks and ATAPI
231 DVDs) can also be specified. For example "sg_inq /dev/sda" will work in
232 the 2.6 series kernels. From lk 2.6.6 other SCSI "char" device names
233 may be used as well (e.g. "/dev/st0m").
234
235 The number of bytes output by --hex and --raw is 36 bytes or the number
236 given to --len=LEN (or --maxlen=LEN). That number is reduced if the
237 "resid" returned by the HBA indicates less bytes were sent back from
238 DEVICE.
239
240 The DEVICE is opened with a read-only flag (e.g. in Unix with the
241 O_RDONLY flag).
242
244 There are two major types of ATA devices: non-packet devices (e.g. ATA
245 disks) and packet devices (ATAPI). The majority of ATAPI devices are
246 CD/DVD/BD drives in which the ATAPI transport carries the MMC set (i.e.
247 a SCSI command set). Further, both types of ATA devices can be con‐
248 nected to a host computer via a "SCSI" (or some other) transport. When
249 an ATA disk is controlled via a SCSI (or non-ATA) transport then two
250 approaches are commonly used: tunnelling (e.g. STP in Serial Attached
251 SCSI (SAS)) or by emulating a SCSI device (e.g. with a SCSI to ATA
252 translation layer, see SAT at www.t10.org ). Even when the physical
253 transport to the host computer is ATA (especially in the case of SATA)
254 the operating system may choose to put a SAT layer in the driver
255 "stack" (e.g. libata in Linux).
256
257 The main identifying command for any SCSI device is an INQUIRY. The
258 corresponding command for an ATA non-packet device is IDENTIFY DEVICE
259 while for an ATA packet device it is IDENTIFY PACKET DEVICE.
260
261 When this utility is invoked for an ATAPI device (e.g. a CD/DVD/BD
262 drive with "sg_inq /dev/hdc") then a SCSI INQUIRY is sent to the device
263 and if it responds then the response to decoded and output and this
264 utility exits. To see the response for an ATA IDENTIFY PACKET DEVICE
265 command add the --ata option (e.g. "sg_inq --ata /dev/hdc).
266
267 This utility doesn't decode the response to an ATA IDENTIFY (PACKET)
268 DEVICE command, hdparm does a good job at that. The '-HHH' option has
269 been added for use with either the '--ata' or '--page=ai' option to
270 produce a format acceptable to "hdparm --Istdin". An example: 'sg_inq
271 --ata -HHH /dev/hdc | hdparm --Istdin'. See hdparm.
272
274 The exit status of sg_inq is 0 when it is successful. Otherwise see the
275 sg3_utils(8) man page.
276
278 The options in this section were the only ones available prior to
279 sg3_utils version 1.23 . In sg3_utils version 1.23 and later these
280 older options can be selected by either setting the SG3_UTILS_OLD_OPTS
281 environment variable or using --old (or -O) as the first option.
282
283 -36 only requests 36 bytes of response data for an INQUIRY. Further‐
284 more even if the device indicates in its response it can supply
285 more data, a second (longer) INQUIRY is not performed. This is a
286 paranoid setting. Equivalent to '--len=36' in the OPTIONS sec‐
287 tion.
288
289 -a fetch the ATA Information VPD page [0x89]. Equivalent to
290 '--page=ai' in the OPTIONS section. This page is defined in SAT
291 (see at www.t10.org).
292
293 -A Assume given DEVICE is an ATA or ATAPI device. Equivalent to
294 --ata in the OPTIONS section.
295
296 -b decodes the Block Limits VPD page [0xb0]. Equivalent to
297 '--page=bl' in the OPTIONS section. This page is defined in
298 SBC-2 (see www.t10.org).
299
300 -B=0|1 equivalent to --block=0|1 in OPTIONS section.
301
302 -c set the Command Support Data (CmdDt) bit (defaults to clear(0)).
303 Used in
304 conjunction with the -o=OPCODE_PG option to specify the SCSI
305 command opcode to query. Equivalent to --cmddt in the OPTIONS
306 section.
307
308 -cl lists the command data for all supported commands (followed by
309 the command name) by looping through all 256 opcodes. This
310 option uses the CmdDt bit which is now obsolete. See the
311 sg_opcodes(8) utility. Equivalent to '--cmddt --cmddt' in the
312 OPTIONS section.
313
314 -d decodes depending on context. If -e option is given, or any
315 option that implies -e (e.g. '-i' or '-p=80'), then this utility
316 attempts to decode the indicated VPD page. Otherwise the ver‐
317 sion descriptors (if any) are listed following a standard
318 INQUIRY response. In the version descriptors sense, equivalent
319 to --descriptors in the OPTIONS section.
320
321 -e enable (i.e. sets) the Vital Product Data (EVPD) bit (defaults
322 to clear(0)). Used in conjunction with the -p=VPD_PG option to
323 specify the VPD page to fetch. If -p=VPD_PG is not given then
324 VPD page 0 (list supported VPD pages) is assumed.
325
326 -h outputs INQUIRY response in hex rather than trying to decode it.
327 Equivalent to --hex in the OPTIONS section.
328
329 -H same action as -h. Equivalent to --hex in the OPTIONS section.
330
331 -i decodes the Device Identification VPD page [0x83]. Equivalent to
332 --id in the OPTIONS section. This page is made up of several
333 "designation descriptors". If -h is given then each descriptor
334 header is decoded and the identifier itself is output in hex. To
335 see the whole VPD 0x83 page response in hex use '-p=83 -h'.
336
337 -I=FN equivalent to --inhex=FN in the OPTIONS section.
338
339 -m decodes the Management network addresses VPD page [0x85]. Equiv‐
340 alent to '--page=mna' in the OPTIONS section.
341
342 -M decodes the Mode page policy VPD page [0x87]. Equivalent to
343 '--page=mpp' in the OPTIONS section.
344
345 -N switch to the newer style options.
346
347 -o=OPCODE_PG
348 used in conjunction with the -e or -c option. If neither given
349 then the -e option assumed. When the -e option is also given (or
350 assumed) then the argument to this option is the VPD page num‐
351 ber. The argument is interpreted as hexadecimal and is expected
352 to be in the range 0 to ff inclusive. Only VPD page 0 is decoded
353 and it lists supported VPD pages and their names (if known). To
354 decode the mandatory device identification page (0x83) use the
355 -i option. A now obsolete usage is when the -c option is given
356 in which case the argument to this option is assumed to be a
357 command opcode number. Recent SCSI draft standards have moved
358 this facility to a separate command (see sg_opcodes(8)).
359 Defaults to 0 so if -e is given without this option then VPD
360 page 0 is output.
361
362 -p=VPD_PG
363 same action as -o=OPCODE_PG option described in the previous
364 entry. Since the opcode value with the CmdDt is now obsolete,
365 the main use of this option is to specify the VPD page number.
366 The argument is interpreted as hexadecimal and is expected to be
367 in the range 0 to ff inclusive. Defaults to 0 so if -e is given
368 without this option then VPD page 0 is output.
369
370 -P decodes the Unit Path Report VPD page [0xc0] which is EMC spe‐
371 cific. Equivalent to '--page=upr' in the OPTIONS section.
372
373 -r outputs the response in binary to stdout. Equivalent to --raw
374 in the OPTIONS section. Can be used twice (i.e. '-rr' (and
375 '-HHH' has same effect)) and if used with the -A or -a option
376 yields output with the same format as "cat /proc/ide/hd<x>/iden‐
377 tify" so that it can then be piped to "hdparm --Istdin".
378
379 -s decodes the SCSI Ports VPD page [0x88]. Equivalent to
380 '--page=sp' in the OPTIONS section.
381
382 -u equivalent to '--export' in the OPTIONS section.
383
384 -v increase level of verbosity. Can be used multiple times.
385
386 -V print out version string then exit.
387
388 -x decodes the Extended INQUIRY data VPD [0x86] page. Equivalent
389 to '--page=ei' in the OPTIONS section.
390
391 -? output usage message and exit. Ignore all other parameters.
392
394 The examples in this page use Linux device names. For suitable device
395 names in other supported Operating Systems see the sg3_utils(8) man
396 page.
397
398 To view the standard inquiry response use without options:
399
400 sg_inq /dev/sda
401
402 Some SCSI devices include version descriptors indicating the various
403 SCSI standards and drafts they support. They can be viewed with:
404
405 sg_inq -d /dev/sda
406
407 Modern SCSI devices include Vital Product Data (VPD)pages which can be
408 viewed with the SCSI INQUIRY command. To list the supported VPD pages
409 (but not their contents) try:
410
411 sg_inq -e /dev/sda
412
413 Some VPD pages can be read with the sg_inq utility but a newer utility
414 called sg_vpd specializes in showing their contents. The sdparm utility
415 can also be used to show the contents of VPD pages.
416
417 Further examples of sg_inq together with some typical output can be
418 found on http://sg.danny.cz/sg/sg3_utils.html web page.
419
421 Written by Douglas Gilbert
422
424 Report bugs to <dgilbert at interlog dot com>.
425
427 Copyright © 2001-2016 Douglas Gilbert
428 This software is distributed under the GPL version 2. There is NO war‐
429 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
430 POSE.
431
433 sg_opcodes(8), sg_vpd(8), sdparm(8), hdparm(8), sgdiag(scsirastools)
434
435
436
437sg3_utils-1.42 January 2016 SG_INQ(8)