SGINFO(8)

πŸ“¦
version 1.49 Β· 3 versions
, in alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

Okay bestie, meet sginfo πŸ’– It's part of the sg3_utils crew and lives in manual section 8, so you know it's serious business πŸ’…

✨ NAME ✨

sginfo is the girl who gets you into a SCSI (or ATAPI) device's mode page information πŸŽ€

✨ SYNOPSIS ✨

sginfo [OPTIONS] [DEVICE] [REPLACEMENT_PARAMETERS]

✨ DESCRIPTION ✨

okay so sginfo is a port of the Linux scsiinfo program, made by Eric Youngdale 🧚 It talks through SCSI generic (sg) devices, but highkey it can also take the high level device names (sd, sr, st, osst, or hd) in some cases πŸ¦‹ Its main job is reading mode page info, and if you're allowed, it can change that info too πŸ”₯ It also shows you stuff from the INQUIRY and READ DEFECTS commands ✨

ngl this utility is in legacy mode, so it only gets fixes for obvious bugs πŸ’€ Options like -l (to list devices) are broken in newer Linux versions (the 2.6 series and later), so use the lsscsi(8) utility instead πŸ™ˆ Also, the mode pages aren't kept up to date as https://www.t10.org adds and changes mode page fields. If you're into SCSI mode pages, the sdparm utility is more up to date and way easier to use, especially for changing parameters πŸ’œ

A SCSI device keeps four sets of values for each mode page πŸ‘‘ There's the current (active) values, the default (the ones the manufacturer supplied), the saved values (the ones kept when the SCSI device is powered down), and the changeable values (a mask showing which values can actually be changed) 🌈 By default, when you display a mode page you get the current values. You can switch that up with -M (defaults), -S (saved), or -m (modifiable, aka changeable) πŸ“

Lots of mode pages are decoded for you πŸŽ€ Disks follow SBC-2, CD/DVDs follow MMC-2/3/4/5, tapes follow SSC-2, and enclosures follow SES-2 ✨ Some mode pages that every SCSI peripheral device type shares are defined in SPC-4 (the primary commands) πŸ’… A decoded mode page puts its field names in the first column and the matching value in the second column πŸ¦‹ A hex mode page (or subpage) puts its byte position in the first column (in hex, starting at 0x2) and the matching hex value in the second column 😭 You can view decoded pages with the -t option, or with a specific option (like c for the caching mode page) πŸ’– Just remember decoded pages have to be supplied by the DEVICE and recognised by this program, obviously πŸ™ˆ If the device supports it, decoded pages can be modified too πŸ”₯ And every mode page (and subpage) the device supports can be viewed in hex (and potentially modified) with the -u option 🫢

If you don't give any options that would print mode page(s) or INQUIRY data, you'll get a brief INQUIRY response instead 🌸 That includes the vendor, product, and revision level of the device ✨


✨ OPTIONS ✨

  • -6 β€” Uses 6 byte MODE SENSE and MODE SELECT commands πŸŽ€ By default, the 10 byte versions are used instead.
  • -a β€” Shows some INQUIRY data and the unit serial number, then every mode page the device reports πŸ’… It's kinda like -t 0x3f. Known pages come out decoded, and anything else comes out in hexadecimal.
  • -A β€” Shows some INQUIRY data and the unit serial number, then every mode page and every mode subpage the device reports πŸ‘‘ It's kinda like -t 0x3f,0xff. Known (sub)pages come out decoded, everything else comes out in hexadecimal.
  • -c β€” Gets you the info in the Caching mode page 🧚
  • -C β€” Gets you the info in the Control mode page πŸ¦‹
  • -d β€” Displays defect lists (default format: index) πŸ’œ
  • -D β€” Gets you the info in the Disconnect-Reconnect mode page πŸ“
  • -e β€” Gets you the info in the Error Recovery mode page ✨
  • -E β€” Gets you the info in the Control Extension mode page 🌈
  • -f β€” Gets you the info in the Format Device mode page πŸŽ€
  • -Farg β€” Picks the format for defect lists πŸ”₯ Use it with -d or -G. If you don't give a format, index is assumed.
    • -Flogical β€” logical block addresses (32 bit) πŸ’–
    • -Flba64 β€” logical block addresses (64 bit) πŸ’–
    • -Fphysical β€” physical blocks πŸ’–
    • -Findex β€” defect bytes from index πŸ’–
    • -Fhead β€” sort by head πŸ’–
  • -g β€” Gets you the info in the Rigid Disk Drive Geometry mode page 🫢
  • -G β€” Displays the grown defect list (default format: index) 🌸
  • -i β€” Displays the response to a standard INQUIRY command πŸ’…
  • -I β€” Gets you the Informational Exceptions mode page 😭
  • -l β€” Deprecated πŸ’€ Only use it on old versions of Linux (like 2.4 and earlier). For the Linux 2.6 series and later, please use lsscsi(8) instead. It lists the known SCSI devices on the system.
  • -n β€” Gets you the info in the Notch and Partition mode page πŸ™ˆ
  • -N β€” Stops mode page changes from going into the "saved" page πŸ›‘ By default, changes go to both the current and the saved page. This only works when you use it together with -R.
  • -P β€” Gets you the info in the Power Condition mode page ⭐
  • -r β€” Displays all the raw (or primary) SCSI device names in the /dev directory 🫢 Examples are /dev/sda, /dev/st1, and /dev/scd2. It doesn't list sg device names, so devices like a SCSI enclosure that only have an sg device name won't show up πŸ™ˆ
  • -s β€” Displays info from the unit serial number page, which is a variant of the INQUIRY command πŸ¦‹
  • -t PN[,SPN] β€” Displays info from mode page number PN (and optionally subpage number SPN) in decoded format if it's known, or in hex otherwise πŸ’– PN is a decimal mode page number from 0 to 63 inclusive. SPN is the mode subpage number, and it's assumed to be 0 if you don't give one. SPN is a decimal number from 1 to 255 inclusive. Page number 63 returns every page the device supports, in ascending order, except page 0, which (if it's there) goes last πŸ‘‘ Page 0 is vendor specific and isn't necessarily in mode page format πŸ’€ You can also give hex values for both PN and SPN, as long as you prefix them with 0x 🌈
  • -T β€” Traces commands for more verbose output (great for debugging) πŸ”₯ Use it once and you'll see the SCSI commands (in hex), plus any errors from them spelled out with a decoded and raw sense buffer 🧚 Use it twice and you'll also see the extra data sent with mode select and the response from mode sense (in hex) 😭
  • -u PN[,SPN] β€” Displays info from mode page number PN (and optionally SPN) in hex form 🫢 PN is a decimal mode page number from 0 to 63 inclusive. SPN is the mode subpage number, and it's assumed to be 0 if you don't give one. SPN is a decimal number from 1 to 255 inclusive. Page number 63 returns every page the device supports, in ascending order, except page 0, which (if it's there) goes last 🌸 Page 0 is vendor specific and isn't necessarily in mode page format ✨ You can give hex values for both PN and SPN too, as long as they're prefixed with 0x. For example, 63 and 0x3f are equivalent πŸ’œ
  • -v β€” Displays the version string and then exits πŸŽ€ [N.B. This option makes most other utilities in this package more verbose, as outlined in man 8 sg3_utils. This odd usage is there for backward compatibility with the scsiinfo utility.]
  • -V β€” Gets you the info in the Verify Error Recovery mode page πŸ“ [N.B. In most other utilities in this package this option prints the version string and then exits, as outlined in man 8 sg3_utils. This odd usage is there for backward compatibility with the scsiinfo utility.]
  • -z β€” Does a single fetch for mode pages, which over-estimates the length of the response you'll get back 🧚 The default is a double fetch: the first fetch finds the response length that could come back. Devices that stick closely to SCSI standards shouldn't need this option, but some real world devices do need it πŸ₯Ί

✨ GENERATING SCRIPT FILES AND HEX PAGES ✨

okay so if you want a script file πŸ“œ, use -aX or -AX. it spits out your mode pages as a list (after the INQUIRY and serial number), one page per line πŸŽ€

the cute part: every line gets prefixed with sginfo -t PN[,SPN] -XR . so when you run the script, it basically re-asserts the mode page values back to whatever they were when -aX made the output. main character energy for your device settings πŸ’…

all the mode pages (and subpages) your device supports can be reached with -t and -u. wanna see every mode page? -u 63 🌸 and if you want every mode page AND every subpage, go with -u 63,255 ✨

to peek at the control mode page in hex πŸ¦‹, use -u 0xa. you get the mode page index in the first column and the matching byte value in the second. mode pages (subpage code == 0) start at index position 2, and subpages start at index position 4 🧚

if you add -Xu ..., you get a list of hex values, and each one is prefixed with @ πŸ”₯. then you can edit (sub)page values with -RXu ... πŸ’œ

πŸ™ˆ RESTRICTIONS πŸ™ˆ

ngl this part is a little dramatic. the SCSI MODE SENSE command gives you block descriptors and mode page(s). sginfo ignores the block descriptors and doesn't display them, so don't go looking for them 🫢

the "disable block descriptor" switch (DBD) in the MODE SENSE command is not set, because some devices throw errors when it is set 😭

when you're changing mode page values (the -R option), the same block descriptor you got from reading the mode page (aka via a MODE SENSE command) gets sent back when the page is written (aka via a MODE SENSE... er, a MODE SELECT command) πŸ’€

⚠️ bestie, don't skip this bit: that block descriptor has to ride along with the write. it's how the device knows what it's getting.

🌐 REFERENCES 🌐

SCSI (draft) standards live at https://www.t10.org πŸ”— the ones you want are:

  • SPC-4 β€” mode pages common to all device types 🌈
  • SBC-2 β€” direct access devices [e.g. disks] πŸ’Ώ
  • MMC-4 β€” CDs and DVDs πŸ“€
  • SSC-2 β€” tapes πŸ“Ό

πŸ‘‘ AUTHORS πŸ‘‘

written by Eric Youngdale, Michael Weller, Douglas Gilbert, Kurt Garloff, and Thomas Steudten 🫢

πŸ“œ HISTORY πŸ“œ

okay storytime πŸŽ€ scsiinfo version 1.0 was released by Eric Youngdale on 1st November 1993. the most recent 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, which cramped the display of defect lists especially 😭 sginfo was written by Douglas Gilbert with patches from Kurt Garloff πŸ’œ and 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 πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

  • lsscsi(lsscsi), scsiinfo(internet) πŸ“
  • sg_modes, sg_inq, sg_vpd (sg3_utils) 🧚
  • sdparm(sdparm) ⭐

bestie, that's the whole thing πŸ₯Ή this page was from sg3_utils-1.38 (January 2014), and it's all about SGINFO(8) πŸ’– go forth and reassert those mode pages like the legend you are πŸ‘‘βœ¨

πŸ“¦ where this page comes from