Inspect SCSI Mode Pages Safely with sginfo

You will use sginfo to identify a SCSI or ATAPI device and read its INQUIRY data. It also inspects a selected mode page and compares current, saved, default and changeable values, all without writing to the device. The examples use the command installed by Ubuntu's sg3-utils package. This local installation reports sginfo version: 2.43 [20190913], while its manpage is for an older interface and describes the utility as legacy software.

Allow 10 to 15 minutes for a read-only inspection. You need a SCSI generic device such as /dev/sg2, or a high-level device name that the program can resolve. You may need elevated privileges to open the device, but start without sudo. Reading mode pages can expose hardware details; it does not normally change them.

1. Confirm the installed command

Check the binary and its version before relying on an option in a script. This matters because sginfo is old, and distributions may carry different builds.

$ command -v sginfo
/usr/bin/sginfo
$ sginfo -v
sginfo version: 2.43 [20190913]

The package version on the machine used for this guide is sg3-utils 1.46-3ubuntu4. The -v option prints the utility version and exits successfully. Do not use --version: this build treats the long option as unknown.

2. Find a suitable device

Prefer lsscsi when it is installed. The -l option is retained by sginfo for old Linux systems, but the manpage marks it deprecated and says it is broken on modern kernels. The -r option lists raw SCSI device names visible under /dev, which can help you match a disk, tape or optical drive.

$ lsscsi
$ sginfo -r
/dev/sda
/dev/sr0

Output depends on the host, so treat these paths as examples, not as devices to copy blindly. A SCSI generic path such as /dev/sg2 is often the clearest target. Check the device identity before reading pages:

$ sginfo -i /dev/sg2

Expected output is INQUIRY information from the target, including its vendor, product and revision. If you see A device name that understands SCSI commands is required, the path is not a usable SCSI device. If access is denied, repeat the same read-only command with sudo only if your device permissions require it:

$ sudo sginfo -i /dev/sg2

Checkpoint: Continue only when the vendor and product identify the device you intended to inspect. A mode-page read is addressed to the device path you provide, so confusing two storage devices can make later conclusions useless.

3. Read the default view of a mode page

With no value-set selector, sginfo reads the current, active values. Select a page with -t for decoded output where the program recognises the page. The page number is decimal from 0 to 63, and an optional subpage is from 1 to 255. For example, page 8 is commonly the caching page and page 10 is the control page, but the target decides whether a page exists and how it is decoded.

$ sginfo -t 8 /dev/sg2

A recognised page is printed as named fields and values. If the device or this old decoder does not recognise it, use the hexadecimal form instead:

$ sginfo -u 8 /dev/sg2

To request a subpage, append it after a comma. To ask for all supported pages in hexadecimal, use page 63. To include all subpages, use 63,255:

$ sginfo -u 63 /dev/sg2
$ sginfo -u 63,255 /dev/sg2

Hexadecimal page numbers are also accepted when prefixed with 0x, for example -u 0xa. The output for a normal page starts at byte position 2; a subpage starts at position 4. Those offsets are part of the returned mode-page format, not disk-sector offsets.

4. Compare the four value sets

SCSI devices can maintain four views of a mode page. Current values are active now. Manufacturer defaults are the values supplied by the device maker. Saved values are retained across power cycles when the device supports them. Changeable values are a mask showing which fields may be modified. These are not four independent configuration files on the Linux host.

Run the same page read with one selector at a time:

$ sginfo -t 8 /dev/sg2
$ sginfo -M -t 8 /dev/sg2
$ sginfo -S -t 8 /dev/sg2
$ sginfo -m -t 8 /dev/sg2

The options mean manufacturer defaults, saved values and modifiable fields respectively. Only one of -m, -M and -S may be used in a command. Capture the outputs if you need an audit trail, and record the device identity beside them. A field shown by the changeable view is not automatically safe to alter: it may still affect performance, error handling or data integrity.

Checkpoint: At this point you have not asked sginfo to send a MODE SELECT command. You should have the device identity, the selected page, and any current, saved, default and changeable views you need. If the page is absent or only partly decoded, stop and consult the device documentation rather than guessing field meanings.

5. Understand trace and fetch options

Use -T when a read fails and you need the SCSI command and sense data. One -T adds command and decoded error detail; two occurrences add more hexadecimal request and response data. Trace output can contain low-level identifiers, so keep it with the incident record rather than posting it unredacted.

$ sginfo -T -t 8 /dev/sg2
$ sginfo -T -T -t 8 /dev/sg2

Normally the utility performs a double fetch to discover the response length before reading the page. The -z option requests a single fetch with an over-estimated length for devices that need it. Try it only when the normal read fails and the device documentation or trace suggests a fetch-length problem:

$ sginfo -z -t 8 /dev/sg2

6. Keep write operations out of routine checks

Warning: -R writes mode-page parameters through MODE SELECT. The manpage labels it expert use only. A wrong value can change caching, error recovery or other device behaviour, and the default replacement action changes both current and saved pages. Do not paste a generated row into a production command without a maintenance plan, a device-specific rollback, and a second person checking the values.

-X changes the display to a space-separated list intended for editing and later use with -R. If you are only investigating, do not add either option. There is no universal undo command: recovery means writing back the previously captured values, if the device accepts them, or restoring the manufacturer's documented settings. The -N option can prevent saving when used with -R, but it still changes the active page and is not a substitute for testing or a rollback plan.

Done means