1SG_MODES(8) SG3_UTILS SG_MODES(8)
2
3
4
6 sg_modes - reads mode pages with SCSI MODE SENSE command
7
9 sg_modes [--all] [--control=PC] [--dbd] [--dbout] [--examine] [--flexi‐
10 ble] [--help] [--hex] [--list] [--llbaa] [--maxlen=LEN]
11 [--page=PG[,SPG]] [--raw] [-R] [--readwrite] [--six] [--verbose]
12 [--version] [DEVICE]
13
14 sg_modes [-6] [-a] [-A] [-c=PC] [-d] [-D] [-e] [-f] [-h] [-H] [-l] [-L]
15 [-m=LEN] [-p=PG[,SPG]] [-r] [-subp=SPG] [-v] [-V] [-w] [-?] [DEVICE]
16
18 This utility sends a MODE SENSE SCSI command to the DEVICE and outputs
19 the response. There is a 6 byte and 10 byte (cdb) variant of the MODE
20 SENSE command, this utility defaults to the 10 byte variant. The SPC-4
21 standard (and SPC-5 drafts) include a note stating that implementers
22 should migrate away from the SCSI MODE SELECT(6) and MODE SENSE(6) com‐
23 mands in favour of the 10 byte variants (e.g. MODE SENSE(10)).
24
25 This utility decodes mode page headers and block descriptors but out‐
26 puts the contents of each mode page in hex. It also has no facility to
27 change the mode page contents or block descriptor data. Mode page con‐
28 tents are decoded and can be changed by the sdparm utility.
29
30 This utility supports two command line syntaxes, the preferred one is
31 shown first in the synopsis and explained in this section. A later sec‐
32 tion on the old command line syntax outlines the second group of
33 options.
34
35 If no page is given (and --list is not selected) then --all is assumed.
36 The --all option requests all mode pages (but not subpages) in a single
37 response.
38
40 Arguments to long options are mandatory for short options as well.
41
42 -a, --all
43 output all the mode pages reported by the DEVICE. This is what
44 the page code 63 (0x3f) is defined to do. When used once, mode
45 subpages are not fetched. When used twice (e.g. '-aa'), all mode
46 pages and subpages are requested which is equivalent to
47 '--page=63,255'.
48
49 -c, --control=PC
50 PC is the page control value. Up to four different versions of
51 each page are held by the device:
52 0 : current values (i.e. those active at present)
53 1 : changeable values
54 2 : default values (i.e. the manufacturer's settings)
55 3 : saved values
56 The changeable values are bit masks showing which fields could
57 be changed with a MODE SELECT. The saved values will be
58 re-instated the next time the device is power cycled or reset.
59 If this option is not given then current values [0] are assumed.
60
61 -d, --dbd
62 disable block descriptors. By default, block descriptors (usu‐
63 ally one (for disks) or none) are returned in a MODE SENSE
64 response. This option sets the "disable block descriptors" (DBD)
65 bit in the cdb which instructs the device not to return any
66 block descriptors in its response. Older devices may not support
67 this setting and may return an "illegal request" sense key;
68 alternatively they may ignore it. Oddly the Reduced Block Com‐
69 mand set (RBC) requires this bit set.
70
71 -D, --dbout
72 disable outputting block descriptors. Irrespective of whether
73 block descriptors are present in the response or not, they are
74 not output.
75
76 -e, --examine
77 examine each mode page in the range 0 through to 62 (inclusive).
78 If some response is given then print out the mode page name or
79 number (in hex) if the name is not known.
80 The sdparm utility which lists mode and VPD pages also has a
81 --examine option will similar functionility.
82
83 -f, --flexible
84 Some devices, bridges and/or drivers attempt crude translations
85 between MODE SENSE 6 and 10 byte commands without correcting the
86 response. This will cause the response to be mis-interpreted
87 (usually with an error saying the response is malformed). With
88 this option, the length of the response is checked, and if it
89 looks wrong, the response is then decoded as if the other mode
90 sense (cdb length) was sent.
91
92 -h, --help
93 print out the usage message then exit.
94
95 -H, --hex
96 The default action is to decode known mode page numbers (and
97 subpage numbers) into text. When this option is used once, the
98 response is output in hexadecimal to stdout. When this option is
99 used twice, mode page numbers and page control values are output
100 in hex.
101 When this option is used three times, the full response to the
102 MODE SENSE command is output in hex to stdout without any decod‐
103 ing. This form can be redirected to a file (or piped) and then
104 used 'sdparm --inhex=' to decode.
105
106 -l, --list
107 lists all common page and subpage codes and their names that are
108 found in the command set that matches the peripheral type of the
109 given DEVICE. If no DEVICE and no --page=PG is given then the
110 common page and subpage codes and their names are listed for SBC
111 (e.g. a disk). If no DEVICE is given and a --page=PG is given
112 then the common page and subpage codes and their names are
113 listed for the command set whose peripheral device type matches
114 the value given to PG. For example 'sg_mode --list --page=1'
115 lists the command mode pages and subpages for tape devices.
116 Additionally if a sub_page_code is given then it is interpreted
117 as a transport identifier and command transport specific mode
118 page codes and their names are listed following the main mode
119 page list. Other options are ignored.
120
121 -L, --llbaa
122 set the Long LBA Accepted (LLBAA) bit in the MODE SENSE (10)
123 cdb. This bit is not defined in the MODE SENSE (6) cdb so set‐
124 ting the '-L' and '--six' options is reported as an error. When
125 set the DEVICE may respond with 16 byte block descriptors as
126 indicated by the 'LongLBA' field in the response. In most cases
127 setting this option is not needed.
128
129 -m, --maxlen=LEN
130 The LEN argument is the maximum response length in bytes. It is
131 the 'allocation length' field in the cdb. When not given (or LEN
132 is zero) then the allocation length field is set to 4096 for
133 MODE SENSE (10) or 252 for MODE SENSE (6). The LEN argument must
134 be non-negative and no greater than 65535 for MODE SENSE (10)
135 and not greater than 255 for MODE SENSE (6).
136
137 -O, --old
138 Switch to older style options. Please use as first option.
139
140 -p, --page=PG
141 page code to fetch. The PG is assumed to be a decimal value
142 unless prefixed by '0x' or has a trailing 'h'. It should be a
143 value between 0 and 63 (inclusive). When not given and a default
144 is required then a value of 63 (0x3f), which fetches all mode
145 pages, is used.
146 Alternatively an acronym for the mode page can be given. The
147 available acronyms can be listed out with the --page=xxx option.
148 They are almost the same as the acronyms used for mode pages in
149 the sdparm utility.
150
151 -p, --page=PG,SPG
152 page code and subpage code values to fetch. Both arguments are
153 assumed to be decimal unless flagged as hexadecimal. The page
154 code should be between 0 and 63 inclusive. The subpage code
155 should be between 0 and 255 inclusive. The default value for the
156 subpage code is 0.
157
158 -r, --raw
159 output the response in binary to stdout. Error messages and
160 warnings, if any, are sent to stderr. When this option is used
161 twice (e.g. '-rr') then has the same action as '-R'
162
163 -R output the selected mode page to stdout a byte per line. Each
164 line contains two hexadecimal digits (e.g. "3e"). Useful as
165 input (after editing) to the sg_wr_mode(8) utility.
166
167 -w, --readwrite
168 open DEVICE in "read-write" mode. Default is to open it in
169 read-only mode.
170
171 -6, --six
172 by default this utility sends a 10 byte MODE SENSE command to
173 the DEVICE. However some SCSI devices only support 6 byte MODE
174 SENSE commands (e.g. SCSI-2 tape drives). This parameter forces
175 the use of 6 byte MODE SENSE commands.
176
177 -v, --verbose
178 increase level of verbosity. Can be used multiple times.
179
180 -V, --version
181 print out version string then exit.
182
184 If the normal sg_modes utility fails with "illegal command operation
185 code" then try the '--six' (or '-6') option.
186
187 This utility performs a SCSI INQUIRY command to determine the periph‐
188 eral type of the device (e.g. 0 -> Direct Access Device (disk)) prior
189 to sending a MODE SENSE command. This helps in decoding the block
190 descriptor and mode pages.
191
192 This utility opens DEVICE in read-only mode (e.g. in Unix, with the
193 O_RDONLY flag) by default. It will open DEVICE in read-write mode if
194 the --readwrite option is given.
195
196 In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic
197 (sg) device. In the 2.6 series block devices (e.g. SCSI disks and DVD
198 drives) can also be specified. For example "sg_modes -a /dev/sda" will
199 work in the 2.6 series kernels.
200
202 The exit status of sg_modes is 0 when it is successful. Otherwise see
203 the sg3_utils(8) man page.
204
206 The options in this section were the only ones available prior to
207 sg3_utils version 1.23 . Since then this utility defaults to the newer
208 command line options which can be overridden by using --old (or -O) as
209 the first option. See the ENVIRONMENT VARIABLES section for another way
210 to force the use of these older command line options.
211
212 -6 by default this utility sends a 10 byte MODE SENSE command to
213 the DEVICE. This parameter forces the use of 6 byte MODE SENSE
214 commands. See --six in the main description.
215
216 -a see --all in the main description.
217
218 -A output all the mode pages and subpages supported by the DEVICE.
219 Same as '--all --all' in the new syntax.
220
221 -c=PC PC is the page control value. See --control=PC in the main
222 description.
223
224 -d see --dbd in the main description.
225
226 -D see --dbout in the main description.
227
228 -e see --examine in the main description.
229
230 -f see --flexible in the main description.
231
232 -h The default action is to decode known mode page numbers (and
233 subpage numbers) into text. With this option mode page numbers
234 (and subpage numbers) are output in hexadecimal.
235
236 -H same action as the '-h' option.
237
238 -l see --list in the main description.
239
240 -L see --llbaa in the main description.
241
242 -N, --new
243 Switch to the newer style options.
244
245 -m=LEN see --maxlen=LEN in the main description.
246
247 -p=PG PG is page code to fetch. Should be a hexadecimal number between
248 0 and 3f inclusive (0 to 63 decimal). The default value when
249 required is 3f (fetch all mode pages). Note that an acronym for
250 the page and/or subpage values is not accepted in this older
251 format (because any acronym starting with the letters 'a' to 'f'
252 is ambiguous; it could either be a hex number or an acronym).
253
254 -p=PG,SPG
255 page code and subpage code values to fetch. The page code should
256 be a hexadecimal number between 0 and 3f inclusive. The subpage
257 code should be a hexadecimal number between 0 and ff inclusive.
258 The default value for the subpage code is 0.
259
260 -r output the selected mode page to stdout a byte per line. Each
261 line contains two hexadecimal digits (e.g. "3e"). Useful as
262 input (after editing) to the sg_wr_mode(8) utility.
263
264 -subp=SPG
265 sub page code to fetch. Should be a hexadecimal number between 0
266 and 0xff inclusive. The default value is 0.
267
268 -v increase verbosity of output.
269
270 -V print out version string then exit.
271
272 -w see --readwrite in the main description.
273
274 -? output usage message then exit. Ignore all other parameters.
275
277 Since sg3_utils version 1.23 the environment variable
278 SG3_UTILS_OLD_OPTS can be given. When it is present this utility will
279 expect the older command line options. So the presence of this environ‐
280 ment variable is equivalent to using --old (or -O) as the first command
281 line option.
282
284 Written by Douglas Gilbert
285
287 Report bugs to <dgilbert at interlog dot com>.
288
290 Copyright © 2000-2020 Douglas Gilbert
291 This software is distributed under the GPL version 2. There is NO war‐
292 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
293 POSE.
294
296 sdparm(8), sg_wr_mode(8), sginfo(8), sgmode(scsirastools), scsi‐
297 info(net), scu(net), seatools(seagate)
298
299 All these utilities offer some facility to change mode page (or block
300 descriptor) parameters.
301
302
303
304sg3_utils-1.45 January 2020 SG_MODES(8)