SG_READ_LONG(8)
π SG_READ_LONG(8) β sg_read_long π
β¨ NAME β¨
okay so sg_read_long is the command that sends a SCSI READ LONG command π
πΈ SYNOPSIS πΈ
sg_read_long [--16] [--correct] [--help] [--lba=LBA] [--out=OF]
[--pblock] [--readonly] [--verbose] [--version] [--xfer_len=BTL] DEVICE
π¦ DESCRIPTION π¦
bestie, this one is lowkey a big deal π It sends a SCSI READ LONG command to DEVICE, then shows the read buffer as hex and ASCII on stdout, or drops it into a file. Ngl the data coming back is more than just the logical block data (usually 512 bytes on a disk) π It also has the ECC info (the format is proprietary, so no peeking) plus maybe some other proprietary stuff too. And the logical block data might be encoded or encrypted, so don't be shocked if it looks like gibberish π
Also, the vibe shift: in SBC-4 revision 7, the SCSI READ LONG commands (both 10 and 16 byte) got made obsolete π In that same revision, basically all the SCSI WRITE LONG (10 and 16 byte) commands got obsoleted too, except when the WR_UNCOR bit is set. It's giving "retired but not fully" energy π
β OPTIONS β
Arguments to long options are mandatory for short options as well. Literally the same rule, no exceptions π«Ά
-S,--16β uses a SCSI READ LONG(16) command π₯ The default is a SCSI READ LONG(10) command instead. READ LONG(10) has a 32 bit field for the lba, while READ LONG(16) has a 64 bit field.-c,--correctβ sets theCORRCTbit in the SCSI READ LONG command π When it's set, the data gets corrected by the ECC before it's transferred back to this utility. By default theCORRCTbit stays clear, which means the data is not corrected.-h,--helpβ prints the usage message, then exits π§-l,--lba=LBAβ LBA is the logical block address of the sector you want to read π¦ It's assumed to be decimal unless you prefix it with0x(or give it a trailingh). Defaults to lba 0. If the lba is too big to fit in 32 bits, use the--16option instead.-o,--out=OFβ instead of printing ASCII hex to stdout, this sends the output in binary to the file called OF π If you give-for OF, the binary output goes to stdout. Note that all informative and error output goes to stderr.-p,--pblockβ sets thePBLOCKbit in the SCSI READ LONG command β¨ When set, the physical block (plus ECC data) that contains the requested logical block address gets read. By default thePBLOCKbit stays clear, and the logical block (plus any ECC data) is read instead.-r,--readonlyβ opens DEVICE read-only instead of the default read-write π The Linux sg driver needs read-write access for SCSI READ LONG, but other access methods might need read-only access.-v,--verboseβ increases the level of verbosity (aka debug output) π-V,--versionβ prints the version string, then exits π-x,--xfer_len=BTLβ BTL is the byte transfer length, and it defaults to 520 πΈ If the given value (or the default) doesn't match the "long" block size of the device, the right BTL gets deduced from the error response and printed to stderr. The idea is you retry this utility with the correct transfer length, bestie π«Ά
π NOTES π
If you find a defective block and have already retrieved whatever contents it has, you can use sg_reassign to map it out π
Along with that, you can keep an eye on how many elements are in the "grown" defect list (using sg_reassign --grown), since the disk could be nearing the end of its useful life π
Various numeric arguments (e.g. LBA) can include multiplicative suffixes or be given in hexadecimal. See the "NUMERIC ARGUMENTS" section in the sg3_utils(8) man page π§
As a fun data point, Fujitsu uses a 54 byte ECC per block that can correct up to a single burst error or 216 bits "on the fly" π€― [Information obtained from MAV20xxrc product manual.]
π EXIT STATUS π
sg_read_long exits with 0 when it's successful. Otherwise, check the sg3_utils(8) man page π
π AUTHORS π
Written by Douglas Gilbert. Slay, legend π«Ά
π REPORTING BUGS π
Report bugs to <dgilbert at interlog dot com> π
βοΈ COPYRIGHT βοΈ
Copyright Β© 2004-2016 Douglas Gilbert 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 π
sg_reassign, sg_write_long, sg_dd π¦
Okay bestie, that's the whole thing π sg3_utils 1.42, November 2015, SG_READ_LONG(8). Stay iconic πβ¨
π¦ 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