SG_TEST_RWBUF(8)

πŸ“¦
version 1.49 Β· 2 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

πŸ’– 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 --quick option πŸ’… 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 © 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