SG_TEST_RWBUF(8)
π sg_test_rwbuf(8) π
β¨ NAME β¨
okay so sg_test_rwbuf is the tool that tests a SCSI host adapter by issuing dummy writes and reads π
π SYNOPSIS π
sg_test_rwbuf [--addrd=AR] [--addwr=AW] [--help] [--quick] --size=SZ
[--times=NUM] [--verbose] [--version] DEVICE
or an older deprecated format sg_test_rwbuf DEVICE SZ [AW] [AR]
π¦ DESCRIPTION π¦
okay so sg_test_rwbuf writes SZ bytes to the internal buffer of DEVICE (think /dev/sda or /dev/sg0) and then reads them back π«Ά It writes a pseudo random pattern into the device's data buffer and reads it right back. If the pattern that comes back matches, it says Success β¨ If they don't match (the checksums are unequal), it tells you so and shows up to 24 bytes starting from the first point of mismatch π The first line shows what got written and the second line shows what got received. For testing purposes, you can also ask it to write AW or read AR extra bytes π§
πΈ OPTIONS πΈ
Arguments to long options are mandatory for short options as well π
-r,--addrd=ARβ read AR extra bytes (more than SZ) from the data buffer. The checksum only covers the first SZ bytes π¦-w,--addwr=AWβ write AW extra bytes (more than SZ) of zeros into the data buffer. The checksum is generated over the first SZ bytes π-h,--helpβ print a usage message and then exit π-q,--quickβ do a READ BUFFER descriptor command to find out the available data buffer length and offset, print them, then exit. No write/read sequences, just the peek π-s,--size=SZβ SZ is the number of bytes to write, read back, and check. It has to be less than or equal to the device's data buffer size, which you can see with the--quickoption π You need to give either this option or--quickβ¨-t,--times=NUMβ NUM is how many times to repeat the write/read test. The default is 1 π-v,--verboseβ turns up the verbosity of the output π’-V,--versionβ print the version number (and the date of the last change), then exit π
π«§ NOTES π«§
okay this part is important bestie π₯Ί The microcode in a SCSI device is _not_ modified by doing a WRITE BUFFER command with its mode set to "data" (0x2), which is what this utility does. So this utility is safe in that respect π«Ά Modes 0x4, 0x5, 0x6 and 0x7 are the dangerous ones :-)
β οΈ WARNING: if you access the device at the same time (say it's a hard disk with a mounted file system on it), the device's buffer may be used by the device itself for other data at the same time. Overwriting it may or may not cause data corruption! HOWEVER, the SPC-3 draft standard does state in its WRITE BUFFER command: "This command shall not alter any medium of the logical unit when data mode ... is specified". This implies that it _is_ safe to use this utility with devices that have mounted file systems on them. Following this theme further, a disk with active mounted file systems may cause the data read back to be different (due to caching activity) to what was written, and hence a checksum error π
π EXIT STATUS π
The exit status of sg_test_rwbuf is 0 when it's successful. Otherwise, check out the sg3_utils(8) man page π
π§ AUTHORS π§
Written by D. Gilbert and K. Garloff β¨
π COPYRIGHT π
Copyright Β© 2000-2018 Douglas Gilbert, Kurt Garloff This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE πΈ
bestie that's the whole thing π this page is from sg3_utils-1.43, January 2018. Go test those buffers and slay them π π«Ά
π¦ 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