1SG_INQ(8) SG3_UTILS SG_INQ(8)
2
3
4
6 sg_inq - sends a SCSI INQUIRY or ATA IDENTIFY (PACKET) DEVICE command
7 and outputs the response
8
10 sg_inq [--ata] [--cmddt] [--descriptors] [--extended] [--help] [--hex]
11 [--id] [--len=LEN] [--maxlen=LEN] [--page=PG] [--raw] [--verbose]
12 [--version] [--vpd] DEVICE
13
14 sg_inq [-36] [-a] [-A] [-b] [-c] [-cl] [-d] [-e] [-h] [-H] [-i]
15 [-l=LEN] [-m] [-M] [-o=OPCODE_PG] [-p=VPD_PG] [-P] [-r] [-s] [-v] [-V]
16 [-x] [-36] [-?] DEVICE
17
19 This utility by default sends a SCSI INQUIRY command to the given
20 device and then outputs the response. All SCSI devices are meant to
21 respond to a "standard" INQUIRY command with at least a 36 byte
22 response (in SCSI 2 and higher). An INQUIRY is termed as "standard"
23 when both the EVPD and CmdDt (obsolete) bits are clear.
24
25 This utility supports two command line syntaxes, the preferred one is
26 shown first in the synopsis and explained in this section. A later sec‐
27 tion on the old command line syntax outlines the second group of
28 options.
29
30 An important "non-standard" INQUIRY page is the Device Identification
31 Vital Product Data (VPD) page [0x83]. Since SPC-3, support for this
32 page is mandatory. The --id option decodes this page. To get fine
33 grained decoding of device identification VPD page and recently added
34 VPD pages, plus some vendor specific VPD pages, see the sg_vpd(8) util‐
35 ity.
36
37 If the DEVICE exists and the SCSI INQUIRY fails (because the SG_IO
38 ioctl is not supported) then an ATA IDENTIFY (PACKET) DEVICE is tried.
39 If it succeeds then device identification strings are output. The --raw
40 and --hex options can be used to manipulate the output. If the --ata
41 option is given then the SCSI INQUIRY is not performed and the DEVICE
42 is assumed to be ATA (or ATAPI).
43
44 The reference document used for interpreting an INQUIRY is T10/1713-D
45 Revision 11 (SPC-4, 14 May 2007) found at http://www.t10.org . Obso‐
46 lete items in the standard INQUIRY response are displayed in brackets.
47 The reference document for the ATA IDENTIFY (PACKET) DEVICE command is
48 ATA8-ACS found at http://www.t13.org .
49
51 Arguments to long options are mandatory for short options as well. The
52 options are arranged in alphabetical order based on the long option
53 name.
54
55 -a, --ata
56 Assume given DEVICE is an ATA or ATAPI device which can receive
57 ATA commands from the host operating system. Skip the SCSI
58 INQUIRY command and use either the ATA IDENTIFY DEVICE command
59 (for nonpacket devices) or the ATA IDENTIFY PACKET DEVICE com‐
60 mand. To show the response in hex, add a '--verbose' option.
61 This option is only available in Linux.
62
63 -c, --cmddt
64 set the Command Support Data (CmdDt) bit (defaults to clear(0)).
65 Used in conjunction with the --page=PG option where PG specifies
66 the SCSI command opcode to query. When used twice (e.g. '-cc')
67 this utility forms a list by looping over all 256 opcodes (0 to
68 255 inclusive) only outputting a line for found commands. The
69 CmdDt bit is now obsolete. It has been replaced by the REPORT
70 SUPPORTED OPERATION CODES command, see the sg_opcodes(8) util‐
71 ity.
72
73 -d, --descriptors
74 decodes and prints the version descriptors found in a standard
75 INQUIRY response. There are up to 8 of them. Version descriptors
76 indicate which versions of standards and/or drafts the DEVICE
77 complies with. The normal components of a standard INQUIRY are
78 output (typically from the first 36 bytes of the response) fol‐
79 lowed by the version descriptors if any.
80
81 -e see entry below for --vpd.
82
83 -E, -x, --extended
84 prints the extended INQUIRY VPD page [0x86].
85
86 -h, --help
87 print out the usage message then exit. When used twice, after
88 the usage message, there is a list of available abbreviations
89 than can be given to the --page=PG option.
90
91 -H, --hex
92 rather than decode a standard INQUIRY response, a VPD page or
93 command support data; print out the response in hex to stdout.
94 Error messages and warnings are typically output to stderr. When
95 used twice with the ATA Information VPD page [0x89] decodes the
96 start of the response then output the ATA IDENTIFY (PACKET)
97 DEVICE response in hexadecimal bytes (not 16 bit words). When
98 used three times with the ATA Information VPD page [0x89] or the
99 --ata option, this utility outputs the ATA IDENTIFY (PACKET)
100 DEVICE response in hexadecimal words suitable for input to
101 'hdparm --Istdin'. See note below.
102
103 -i, --id
104 prints the device identification VPD page [0x83].
105
106 -l, --len=LEN
107 the number LEN is the "allocation length" field in the INQUIRY
108 cdb. This is the (maximum) length of the response to be sent by
109 the device. The default value of LEN is 0 which is interpreted
110 as: first request is for 36 bytes and if necessary execute
111 another INQUIRY if the "additional length" field in the response
112 indicates that more than 36 bytes is available. If LEN is
113 greater than 0 then only one INQUIRY command is performed. See
114 paragraph below about "36 byte INQUIRYs".
115
116 -m, --maxlen=LEN
117 this option has the same action as the --len=LEN option. It has
118 been added for compatibility with the sg_vpd, sg_modes and
119 sg_logs utilities.
120
121 -O, --old
122 switch to older style options.
123
124 -p, --page=PG
125 the PG argument can be either a number of an abbreviation for a
126 VPD page. To enumerate the available abbreviations for VPD pages
127 use '-hh' or a bad abbreviation (e.g, '--page=xxx'). When the
128 --cmddt option is given (once) then PG is interpreted as an
129 opcode number (so VPD page abbreviations make little sense).
130
131 -r, --raw
132 output the response in binary to stdout. Error messages and
133 warnings, if any, are sent to stderr.
134
135 -v, --verbose
136 increase level of verbosity. Can be used multiple times.
137
138 -V, --version
139 print out version string then exit.
140
141 -e, --vpd
142 set the Enable Vital Product Data (EVPD) bit (defaults to
143 clear(0)). Used in conjunction with the --page=PG option where
144 PG specifies the VPD page number to query. If the --page=PG is
145 not given then PG defaults to zero which is the "Supported VPD
146 pages" VPD page.
147
149 Some devices with weak SCSI command set implementations lock up when
150 they receive commands they don't understand (or even response lengths
151 that they don't expect). Such devices need to be treated carefully, use
152 the '--len=36' option. Without this option this utility will issue an
153 initial standard INQUIRY requesting 36 bytes of response data. If the
154 device indicates it could have supplied more data then a second INQUIRY
155 is issued to fetch the longer response. That second command may lock up
156 faulty devices.
157
158 ATA or ATAPI devices that use a SCSI to ATA Translation layer (see SAT
159 at www.t10.org) may support the ATA Information VPD page. This returns
160 the IDENTIFY (PACKET) DEVICE response amongst other things. The ATA
161 Information VPD page can be fetched with '--page=ai'.
162
163 In the INQUIRY standard response there is a 'MultiP' flag which is set
164 when the device has 2 or more ports. Some vendors use the preceding
165 vendor specific ('VS') bit to indicate which port is being accessed by
166 the INQUIRY command (0 -> relative port 1 (port "a"), 1 -> relative
167 port 2 (port "b")). When the 'MultiP' flag is set, the preceding vendor
168 specific bit is shown in parentheses. SPC-3 compliant devices should
169 use the device identification VPD page (0x83) to show which port is
170 being used for access and the SCSI ports VPD page (0x88) to show all
171 available ports on the device.
172
173 In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic
174 (sg) device. In the 2.6 series block devices (e.g. disks and ATAPI
175 DVDs) can also be specified. For example "sg_inq /dev/sda" will work in
176 the 2.6 series kernels. From lk 2.6.6 other SCSI "char" device names
177 may be used as well (e.g. "/dev/st0m").
178
180 There are two major types of ATA devices: non-packet devices (e.g. ATA
181 disks) and packet devices (ATAPI). The majority of ATAPI devices are
182 CD/DVD/BD drives in which the ATAPI transport carries the MMC set (i.e.
183 a SCSI command set). Further, both types of ATA devices can be con‐
184 nected to a host computer via a "SCSI" (or some other) transport. When
185 an ATA disk is controlled via a SCSI (or non-ATA) transport then two
186 approaches are commonly used: tunnelling (e.g. STP in Serial Attached
187 SCSI (SAS)) or by emulating a SCSI device (e.g. with a SCSI to ATA
188 translation layer, see SAT at www.t10.org ). Even when the physical
189 transport to the host computer is ATA (especially in the case of SATA)
190 the operating system may choose to put a SAT layer in the driver
191 "stack" (e.g. libata in Linux).
192
193 The main identifying command for any SCSI device is an INQUIRY. The
194 corresponding command for an ATA non-packet device is IDENTIFY DEVICE
195 while for an ATA packet device it is IDENTIFY PACKET DEVICE.
196
197 When this utility is invoked for an ATAPI device (e.g. a CD/DVD/BD
198 drive with "sg_inq /dev/hdc") then a SCSI INQUIRY is sent to the device
199 and if it responds then the response to decoded and output and this
200 utility exits. To see the response for an ATA IDENTIFY PACKET DEVICE
201 command add the --ata option (e.g. "sg_inq --ata /dev/hdc).
202
203 This utility doesn't decode the response to an ATA IDENTIFY (PACKET)
204 DEVICE command, hdparm does a good job at that. The '-HHH' option has
205 been added for use with either the '--ata' or '--page=ai' option to
206 produce a format acceptable to "hdparm --Istdin". An example: 'sg_inq
207 --ata -HHH /dev/hdc | hdparm --Istdin'. See hdparm.
208
210 The exit status of sg_inq is 0 when it is successful. Otherwise see the
211 sg3_utils(8) man page.
212
214 The options in this section were the only ones available prior to
215 sg3_utils version 1.23 . In sg3_utils version 1.23 and later these
216 older options can be selected by either setting the SG3_UTILS_OLD_OPTS
217 environment variable or using --old (or -O) as the first option.
218
219 -36 only requests 36 bytes of response data for an INQUIRY. Further‐
220 more even if the device indicates in its response it can supply
221 more data, a second (longer) INQUIRY is not performed. This is a
222 paranoid setting. Equivalent to '--len=36' in the main descrip‐
223 tion.
224
225 -a fetch the ATA Information VPD page [0x89]. Equivalent to
226 '--page=ai' in the main description. This page is defined in SAT
227 (see at www.t10.org).
228
229 -A Assume given DEVICE is an ATA or ATAPI device. Equivalent to
230 --ata in the main description.
231
232 -b decodes the Block Limits VPD page [0xb0]. Equivalent to
233 '--page=bl' in the main description. This page is defined in
234 SBC-2 (see www.t10.org).
235
236 -c set the Command Support Data (CmdDt) bit (defaults to clear(0)).
237 Used in
238 conjunction with the -o=OPCODE_PG option to specify the SCSI
239 command opcode to query. Equivalent to --cmddt in the main
240 description.
241
242 -cl lists the command data for all supported commands (followed by
243 the command name) by looping through all 256 opcodes. This
244 option uses the CmdDt bit which is now obsolete. See the
245 sg_opcodes(8) utility. Equivalent to '--cmddt --cmddt' in the
246 main description.
247
248 -d decodes depending on context. If -e option is given, or any
249 option that implies -e (e.g. '-i' or '-p=80'), then this utility
250 attempts to decode the indicated VPD page. Otherwise the ver‐
251 sion descriptors (if any) are listed following a standard
252 INQUIRY response. In the version descriptors sense, equivalent
253 to --descriptors in the main description.
254
255 -e enable (i.e. sets) the Vital Product Data (EVPD) bit (defaults
256 to clear(0)). Used in conjunction with the -p=VPD_PG option to
257 specify the VPD page to fetch. If -p=VPD_PG is not given then
258 VPD page 0 (list supported VPD pages) is assumed.
259
260 -h outputs INQUIRY response in hex rather than trying to decode it.
261 Equivalent to --hex in the main description.
262
263 -H same action as -h. Equivalent to --hex in the main description.
264
265 -i decodes the Device Identification VPD page [0x83]. Equivalent to
266 --id in the main description. This page is made up of several
267 "designation descriptors". If -h is given then each descriptor
268 header is decoded and the identifier itself is output in hex.
269 To see the whole VPD 0x83 page response in hex use '-p=83 -h'.
270
271 -m decodes the Management network addresses VPD page [0x85]. Equiv‐
272 alent to '--page=mna' in the main description.
273
274 -M decodes the Mode page policy VPD page [0x87]. Equivalent to
275 '--page=mpp' in the main description.
276
277 -N switch to the newer style options.
278
279 -o=OPCODE_PG
280 used in conjunction with the -e or -c option. If neither given
281 then the -e option assumed. When the -e option is also given (or
282 assumed) then the argument to this option is the VPD page num‐
283 ber. The argument is interpreted as hexadecimal and is expected
284 to be in the range 0 to ff inclusive. Only VPD page 0 is decoded
285 and it lists supported VPD pages and their names (if known). To
286 decode the mandatory device identification page (0x83) use the
287 -i option. A now obsolete usage is when the -c option is given
288 in which case the argument to this option is assumed to be a
289 command opcode number. Recent SCSI draft standards have moved
290 this facility to a separate command (see sg_opcodes(8)).
291 Defaults to 0 so if -e is given without this option then VPD
292 page 0 is output.
293
294 -p=VPD_PG
295 same action as -o=OPCODE_PG option described in the previous
296 entry. Since the opcode value with the CmdDt is now obsolete,
297 the main use of this option is to specify the VPD page number.
298 The argument is interpreted as hexadecimal and is expected to be
299 in the range 0 to ff inclusive. Defaults to 0 so if -e is given
300 without this option then VPD page 0 is output.
301
302 -P decodes the Unit Path Report VPD page [0xc0] which is EMC spe‐
303 cific. Equivalent to '--page=upr' in the main description.
304
305 -r outputs the response in binary to stdout. Equivalent to --raw
306 in the main description. Can be used twice (i.e. '-rr' (and
307 '-HHH' has same effect)) and if used with the -A or -a option
308 yields output with the same format as "cat /proc/ide/hd<x>/iden‐
309 tify" so that it can then be piped to "hdparm --Istdin".
310
311 -s decodes the SCSI Ports VPD page [0x88]. Equivalent to
312 '--page=sp' in the main description.
313
314 -v increase level of verbosity. Can be used multiple times.
315
316 -V print out version string then exit.
317
318 -x decodes the Extended INQUIRY data VPD [0x86] page. Equivalent
319 to '--page=ei' in the main description.
320
321 -? output usage message and exit. Ignore all other parameters.
322
324 Written by Doug Gilbert
325
327 Report bugs to <dgilbert at interlog dot com>.
328
330 Copyright © 2001-2009 Douglas Gilbert
331 This software is distributed under the GPL version 2. There is NO war‐
332 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
333 POSE.
334
336 sg_opcodes(8), sg_vpd(8), hdparm(8), sgdiag(scsirastools)
337
338
339
340sg3_utils-1.28 September 2009 SG_INQ(8)