SGINFO(8) | SG3_UTILS | SGINFO(8) |
sginfo - access mode page information for a SCSI (or ATAPI) device
sginfo [OPTIONS] [DEVICE] [REPLACEMENT_PARAMETERS]
sginfo is a port of the Linux scsiinfo program by Eric Youngdale. It uses SCSI generic (sg) devices; however in some cases the high level device name (i.e. sd, sr, st, osst, or hd) can also be used. The primary role of this program is to access mode page information. If permitted, mode page information can be altered. In addition information from the INQUIRY and READ DEFECTS commands are also available.
This utility is in legacy mode, only obvious bugs will be fixed. Options like -l (to list devices) are broken in recent versions of Linux (e.g. 2.6 series and later); the lsscsi(8) utility can be used instead. Also mode pages are not being updated as http://www.t10.org adds and modifies mode page fields. Those interested in SCSI mode pages may find the sdparm utility more up to date and easier use, especially for changing parameters.
Four sets of values are maintained by a SCSI device for each mode page: current (active), default (manufacturer's supplied values), saved (values that are retained if the SCSI device is powered down), and changeable (mask indicating those values that can be changed). By default when a mode page is displayed the current values are shown. This can be overridden by "-M" (defaults), "-S" (saved) or "-m" (modifiable (i.e. changeable)).
Many mode pages are decoded: for disks (see SBC-2), for CD/DVDs (see MMC-2/3/4/5), for tapes (see SSC-2) and for enclosures (see SES-2). Some mode pages common to all SCSI peripheral device types are defined in SPC-4 (primary commands). A decoded mode page has its field names in the first column and the corresponding value in the second column. A "hex" mode page (and subpage) has its byte position in the first column (in hex and starting at 0x2) and the corresponding hex value in the second column. Decoded pages can be viewed with the '-t' option or with a specific option (e.g. 'c' for the caching mode page). Naturally decoded pages must be supplied by the DEVICE and recognised by this program. If supported by the device, decoded pages may be modified. All mode pages (and subpages) that the device supports can be viewed in hex (and potentially modified) via the "-u" option
If no options are given that will cause mode page(s) or INQUIRY data to be printed out, then a brief INQUIRY response is output. This includes the vendor, product and revision level of the device.
Only one of the following three options can be specified. None of these three implies the current values are returned.
The following are advanced options, not generally suited for most users:
Firstly you should know what you are doing before changing existing parameters. Taking the control page as an example, first list it out normally (e.g. "sginfo -C /dev/sda") and decide which parameter is to be changed (note its position relative to the other lines output). Then execute the same sginfo command with the "-X" option added; this will output the parameter values in a single row in the same relative positions as the previous command. Now execute "sginfo -CXR /dev/sda ..." with the "..." replaced by the single row of values output by the previous command, with the relevant parameter changed. Here is a simplified example:
$ sginfo -C /dev/sda
Control mode page (0xa)
-----------------------
TST 0
D_SENSE 0
GLTSD 1
RLEC 0
[Actually the Control page has more parameters that shown above.] Next output those parameters in single line form:
$ sginfo -CX /dev/sda
0 0 1 0
Let us assume that the GLTSD bit is to be cleared. The command that will clear it is:
$ sginfo -CXR /dev/sda 0 0 0 0
The same number of parameters output by the "-CX" command needs to be placed at the end of the "-CXR" command line (after the device name). Now check that the change took effect:
$ sginfo -C /dev/sda
Control mode page (0xa)
-----------------------
TST 0
D_SENSE 0
GLTSD 0
RLEC 0
When a mode page is "replaced" the default action is to change both the current page and the saved page. [For some reason versions of sginfo and scsiinfo prior to 2.0 did not change the "saved" page.] To change only the current mode page but not the corresponding saved page use the "-N" option.
The "-aX" or "-AX" option generates output suitable for a script file. Mode pages are output in list format (after the INQUIRY and serial number) one page per line. To facilitate running the output as (part of) a script file to assert chosen mode page values, each line is prefixed by "sginfo -t PN[,SPN] -XR ". When such a script file is run, it will have the effect of re-asserting the mode page values to what they were when the "-aX" generated the output.
All mode pages (and subpages) supported by the device can be accessed via the -t and -u options. To see all mode pages supported by the device use "-u 63". [To see all mode pages and all subpages use "-u 63,255".] To list the control mode page in hex (mode page index in the first column and the corresponding byte value in the second column) use "-u 0xa". Mode pages (subpage code == 0) start at index position 2 while subpages start at index position 4. If the "-Xu ..." option is used then a list a hex values each value prefixed by "@" is output. Mode (sub)page values can then be modified with the "-RXu ..." option.
The SCSI MODE SENSE command yields block descriptors as well as a mode page(s). This utility ignores block descriptors and does not display them. The "disable block descriptor" switch (DBD) in the MODE SENSE command is not set since some devices yield errors when it is set. When mode page values are being changed (the "-R" option), the same block descriptor obtained by reading the mode page (i.e. via a MODE SENSE command) is sent back when the mode page is written (i.e. via a MODE SELECT command).
SCSI (draft) standards can be found at http://www.t10.org . The relevant documents are SPC-4 (mode pages common to all device types), SBC-2 (direct access devices [e.g. disks]), MMC-4 (CDs and DVDs) and SSC-2 (tapes).
Written by Eric Youngdale, Michael Weller, Douglas Gilbert, Kurt Garloff, Thomas Steudten
scsiinfo version 1.0 was released by Eric Youngdale on 1st November 1993. The most recent version of scsiinfo is version 1.7 with the last patches by Michael Weller. sginfo is derived from scsiinfo and uses the sg interface to get around the 4 KB buffer limit in scsiinfo that cramped the display of defect lists especially. sginfo was written by Douglas Gilbert with patches from Kurt Garloff. This manpage corresponds with version 2.25 of sginfo.
This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
lsscsi(lsscsi), scsiinfo(internet); sg_modes, sg_inq, sg_vpd (sg3_utils), sdparm(sdparm)
January 2014 | sg3_utils-1.38 |