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