SG_REQUESTS(8)
π sg_requests π
okay bestie, this is the SG3_UTILS manual page for sg_requests π§ it's part of the sg3_utils toolkit and it's giving SCSI REQUEST SENSE vibes β¨
β¨ NAME β¨
sg_requests - send one or more SCSI REQUEST SENSE commands π
β¨ SYNOPSIS β¨
sg_requests [--desc] [--error] [--help] [--hex] [--maxlen=LEN]
[--num=NUM] [--number=NUM] [--progress] [--raw] [--status] [--time]
[--timeout=SE] [--verbose] [--version] DEVICE
β¨ DESCRIPTION β¨
okay so this tool sends a SCSI REQUEST SENSE command to your DEVICE and spits back the parameter data it gets in return π that data is supposed to be sense data, and it can be either fixed or descriptor format. both are supported, so no drama π«Ά
you can also fire off a bunch of REQUEST SENSE commands in one go with --num=NUM. this is lowkey perfect for timing stuff or keeping an eye on the progress indication π₯
β¨ OPTIONS β¨
Arguments to long options are mandatory for short options as well. no skipping, periodt π
-d,--descβ sets the DESC bit in the REQUEST SENSE SCSI cdb πΈ this asks the DEVICE to send sense data in descriptor format instead of fixed. it only works if the device knows descriptor format (SPC-3 and later). if the device is pre SPC-3, then flipping that bit in a reserved field might give you a check condition status with an illegal request sense key π but most likely it just gets ignored-e,--errorβ when you use it once, it swaps the REQUEST SENSE opcode from 0x3 to 0xff, which the DEVICE should reject π there's a tiny chance the vendor has a vendor specific command sitting at 0xff, so keep that in mind. use it twice and the pass-through call that sends the SCSI command gets bypassed entirely π the whole point is to measure how much user space overhead this package's library eats up to set up and process a SCSI command response. this one is usually paired with--num=NUMand--timewhere NUM is a big number (e.g. 1000000) β¨-h,--helpβ shows the usage message, then exits π§-H,--hexβ outputs the response in ASCII hexadecimal π-m,--maxlen=LENβ LEN is the (maximum) response length in bytes π it gets placed in the cdb's "allocation length" field. if you don't give it (or LEN is zero), it defaults to 252. the max LEN is 255, but SPC-4 recommends 252, so stick with that bestie π«Ά-n,--num=NUMβ runs NUM SCSI REQUEST SENSE commands, stopping early if an error happens π₯ the default NUM is 1 .--number=NUMβ same energy as--num=NUMπ it's here for compatibility with sg_turs.-p,--progressβ shows a progress indication (a percentage) if the device has one π if you use--num=NUMwith NUM greater than 1 and an initial progress indication was detected, this tool waits 30 seconds before checking again π it exits when NUM is reached or when there are no more progress indications. it ignores the--hex,--rawand--timeoptions, so don't be confused. see the NOTES section below π-r,--rawβ outputs the response in binary, straight to stdout π¦-s,--statusβ okay this one is the real deal β if the REQUEST SENSE command finished without error (as shown by its SCSI status), then the parameter data gets analysed as sense data and the exit status is set to match π₯ by default, when you don't use this option, the parameter data is ignored for exit status purposes. some errors set a sense key of "NO SENSE" with non-zero information in the additional sense code (e.g. the FAILURE PREDICTION THRESHOLD EXCEEDED group of codes). that gives an exit status value of 10 π if the sense key is "NO SENSE" and both asc and ascq are zero, the exit status is set to 0 . see the sg3_utils(8) man page for exit status values π-t,--timeβ times the SCSI REQUEST SENSE command(s) and works out the average number of operations per second β±οΈβ¨-T,--timeout=SEβ SE is the command timeout of each TEST UNIT READY command π°οΈ the unit is seconds. if you give 0, it gets mapped to 60 seconds, which is the default. an alternate long option form is--tmo=SEπ-v,--verboseβ turns up the verbosity (i.e. debug output) π on top of that, the response (if one was received) gets printed in ASCII-HEX. use this flag multiple times for even more tea β-V,--versionβ prints the version string, then exits π§
β¨ NOTES β¨
okay real talk, in SCSI 1 and 2 the REQUEST SENSE command was super important for error and warning processing π then autosense came along and made it kinda superfluous π
BUT recent SCSI drafts (e.g. SPC-4 rev 14 and SBC-3 rev 14) bring the utility of REQUEST SENSE back. idle and standby (low) power conditions can be detected with this command π
The REQUEST SENSE command is not marked as mandatory in SPC-3 (i.e. for all SCSI devices), but it is marked as mandatory in SBC-2 (i.e. for disks), SSC-3 (i.e. for tapes) and MMC-4 (i.e. for CD/DVD/HD-DVD/BD drives) π
The progress indication is optionally part of the sense data π when a prior command that takes forever to finish (and usually blocks other media access commands) is still going, the progress indication can tell you how long until the device is back to its normal state π«Ά
The SCSI FORMAT command for disks used with the IMMED bit set is a great example of an operation that takes a significant amount of time and blocks other media access during that time π the IMMED bit set tells FORMAT to hand control back to the application client once the format has started (see SBC-3). several long duration SCSI commands for tape drives also use the progress indication (see SSC-3) π¬
Early standards suggested that the SCSI TEST UNIT READY command be used for polling the progress indication (see the sg_turs utility). since SPC-3, the standards suggest the SCSI REQUEST SENSE command be used instead π
The DEVICE is opened with a read-only flag (e.g. in Unix with the O_RDONLY flag) π
β¨ EXIT STATUS β¨
the exit status of sg_requests is 0 when it's successful π₯³ otherwise, check out the sg3_utils(8) man page π
β¨ AUTHORS β¨
Written by Douglas Gilbert π
β¨ REPORTING BUGS β¨
Report bugs to <dgilbert at interlog dot com> π
β¨ COPYRIGHT β¨
Copyright Β© 2004-2023 Douglas Gilbert π This software is distributed under a BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE π
β¨ SEE ALSO β¨
sg_turs (sg3_utils) π¦
bestie, that's the whole thing π this sg_requests page from sg3_utils 1.48 (May 2023) is all yours now π§β¨
π¦ where this page comes from
- alpine 3.24: sg3_utils-doc 1.48-r0 Β· BSD-2-Clause AND GPL-2.0-or-later
- arch rolling: sg3_utils 1.49-1 Β· GPL-2.0-or-later AND BSD-2-Clause
- centos-stream 10: sg3_utils 1.48-11.el10 Β· GPL-2.0-or-later AND BSD-2-Clause
- debian trixie: sg3-utils 1.48-3~deb13u1
- fedora 43: sg3_utils 1.48-10.fc43 Β· GPL-2.0-or-later AND BSD-2-Clause
- fedora 43: sg3_utils 1.48-6.fc43 Β· GPL-2.0-or-later AND BSD-2-Clause
- fedora 44: sg3_utils 1.48-10.fc44 Β· GPL-2.0-or-later AND BSD-2-Clause
- fedora 44: sg3_utils 1.48-8.fc44 Β· GPL-2.0-or-later AND BSD-2-Clause
- nixos 26.05: sg3_utils 1.48
- nixpkgs unstable: sg3_utils 1.49
- ubuntu questing: sg3-utils 1.48-2ubuntu1
- ubuntu resolute: sg3-utils 1.48-3ubuntu3
- ubuntu resolute: sg3-utils 1.48-3ubuntu3.2
- ubuntu stonking: sg3-utils 1.48-3ubuntu5
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms