SG_VERIFY(8)
β¨ NAME β¨
Okay bestie, the manual name is sg_verify and it's giving: invoke SCSI VERIFY command(s) on a block device π
π¦
π SYNOPSIS π
sg_verify [--0] [--16] [--bpc=BPC] [--count=COUNT] [--dpo] [--ff]
[--ebytchk=BCH] [--group=GN] [--help] [--in=IF] [--lba=LBA] [--ndo=NDO]
[--quiet] [--readonly] [--verbose] [--version] [--vrprotect=VRP] DEVICE
πΈ DESCRIPTION πΈ
Okay so sg_verify sends one or more SCSI VERIFY (10 or 16) commands to DEVICE. These commands are defined in the SBC-2 and SBC-3 standards at https://www.t10.org and in SBC-4 drafts, so it's very official and very serious β¨
When --ndo=NDO is not given, the verify starts at the logical block address from --lba=LBA and keeps going for --count=COUNT blocks. No more than --bpc=BPC blocks get verified by each VERIFY command, so if needed, multiple VERIFY commands get sent. The medium verification is done by the DEVICE itself (for example, assuming each block has extra EEC data, it checks that against the logical block contents) π§ And honestly? No news is good news. If no verify errors are detected, nothing gets sent to stderr and the Unix exit status is 0 π«Ά
When --ndo=NDO is given, the --bpc=BPC option gets ignored. A single VERIFY command is issued and a comparison starts at the logical block address from --lba=LBA and continues for --count=COUNT blocks. The VERIFY command has a data-out buffer that is NDO bytes long. That buffer gets its contents from the FN file (if --in=FN is given) or from stdin. Then a comparison happens between the data-out buffer and the logical blocks on the DEVICE. If the comparison is good, no messages go to stderr and the exit status is 0 β¨ If it fails, a sense buffer with a sense key of MISCOMPARE comes back, and in that case the exit status will be 14 π Messages get sent to stderr for that MISCOMPARE sense buffer unless --quiet is given.
β οΈ Heads up: In SBC-3 revision 34, the BYTCHK field in all SCSI VERIFY commands got expanded from one bit to two bits. That meant some options in this utility had to change, so check the section below on OPTION CHANGES π
π OPTIONS π
Arguments to long options are mandatory for short options as well. The options are arranged in alphabetical order based on the long option name π
-0,--0β This sends a bufferNDObytes long, completely full of zeros, as the data-out part of a VERIFY command. Stdin doesn't get read, and if--in=IFis given, you'll get an error. It's super handy when BCH is 3, for checking whether some or all ofDEVICE(like a disk) is zero-filled blocks π-S,--16β Uses a VERIFY(16) command instead of the default VERIFY(10). Even without this option, if you pass an--lba=LBAthat's too large, the utility will issue a VERIFY(16) command on its own π-b,--bpc=BPCβ This gets ignored if--ndo=NDOis given. Otherwise,BPCis the max number of blocks a single SCSI VERIFY command will verify. The default is 128 blocks, which works out to 64 KB for a disk with 512 byte blocks. IfBPCis less thanCOUNT, multiple SCSI VERIFY commands get sent to theDEVICE. For the default VERIFY(10),BPCcan't go past0xffff(65,535), while for VERIFY(16) it can't go past0x7fffffff(2,147,483,647). For recent block devices (disks), this might be limited by the maximum transfer length field in the block limits VPD page π₯-c,--count=COUNTβCOUNTis how many blocks to verify. The default is1. IfCOUNTis bigger thanBPC(or its default of 128) andNDOisn't given, then 0 or less than multiple SCSI VERIFY commands get sent to the device. Otherwise,COUNTbecomes the contents of the verification length field in the SCSI VERIFY command that gets issued. If you need to find out the maximum number of blocks a block device (like a disk) has, thesg_readcaputility can help you with that π-d,--dpoβ Disable page out. This changes the cache retention priority of blocks read on the device's cache down to the lowest priority. Translation: blocks read by other commands are more likely to stick around in the device's cache π§-E,--ebytchk=BCHβ This sets the BYTCHK field toBCH, overriding the value of 1 that--ndo=NDOsets. Values of 1, 2 or 3 are accepted forBCH, but sbc3r34 reserves the value 2, so no 2 for you π ββοΈ If this option is given, then--ndo=NDOmust also be given. IfBCHis 3, thenNDOshould be the size of one logical block (plus the size of some or all of the protection information ifVRPis greater than 0) π¦-f,--ffβ This sends a bufferNDObytes long, full of0xffbytes, as the data-out part of a VERIFY command. Stdin doesn't get read, and if--in=IFis given, you'll get an error. Super useful when BCH is 3 for checking whether some or all ofDEVICE(like a disk) is0xffbyte-filled blocks β¨-g,--group=GNβGNbecomes the contents of the group number field in the SCSI VERIFY(16) command. It can be anywhere from 0 to 63 inclusive, and the default is 0. Just a heads up, this option is ignored for the SCSI VERIFY(10) command π-h,--helpβ Outputs the usage message, then exits π«Ά-i,--in=IFβIFis the name of a file to readNDObytes from, which then get placed in the data-out buffer. This only happens when--ndo=NDOis given. If this option isn't given, stdin gets read instead. IfIFis"-", stdin gets used too π₯-l,--lba=LBAβLBAis the logical block address of the first block to start the verify operation.LBAis assumed to be decimal unless you prefix it with'0x'or give it a trailing'h'(more on that below). The default is 0, which is the start of the device πΈ-n,--ndo=NDOβNDOis the number of bytes to grab from theFNfile (if--in=FNis given) or from stdin. Those bytes go into the data-out buffer tied to the SCSI VERIFY command, andNDOgets placed in the verification length field in the CDB. The default forNDOis 0, and the max value depends on the OS π If--ebytchk=BCHisn't given, the BYTCHK field in the CDB gets set to 1.-q,--quietβ Suppresses the sense buffer messages for a MISCOMPARE sense key that would otherwise be sent to stderr. The exit status still gets set to 14, which is the sense key value for a MISCOMPARE π-r,--readonlyβ Opens theDEVICEread-only instead of read-write, which is the default. The Linux sg driver needs read-write access for the SCSI VERIFY command, but other access methods might need read-only access π-v,--verboseβ Increases the level of verbosity, which means more debug output π-V,--versionβ Prints the version string, then exits π-P,--vrprotect=VRPβVRPis the value in the vrprotect field of the VERIFY command CDB. It has to be between 0 and 7 inclusive. The default is zero π§
π¦ BYTCHK π¦
BYTCHK is the name of a field (two bits wide) in the VERIFY(10) and VERIFY(16) commands. When it's set to 1 or 3 (sbc3r34 reserves the value 2), it means a data-out buffer will be sent to the device (disk) to check along with the SCSI VERIFY command. Using --ndo=NDO sets the BYTCHK field to 1, and NDO is the number of bytes placed in the data-out buffer. Those bytes come from stdin or from IF (via the --in=FN option). You can use --ebytchk=BCH to override the BYTCHK value of 1 with BCH π
The calculation of NDO is up to you, bestie π
Its value depends on the logical block size (which you can find with the sg_readcap utility), the COUNT and the VRP values. If VRP is greater than 0, then each logical block will contain an extra 8 bytes (at least) of protection information.
When the BYTCHK field is 0, the verification process done by the device (disk) is vendor specific. It usually involves checking each block on the disk against its error correction codes (ECC), which is extra data also stored on the disk πΈ
Many operating systems put limits on the maximum size of the data-out (and data-in) buffer. For Linux, the limit used to be less than 1 MB, but it has gotten a bit bigger since then β¨
π OPTION CHANGES π
Earlier versions of this utility had a --bytchk=NDO option that set the BYTCHK bit and set the cdb verification length field to NDO. The shorter form of that option was -B NDO. For backward compatibility, that option is still around, but it's not documented anymore. In its place is --ndo=NDO, whose shorter form is -n NDO. --ndo=NDO sets the BYTCHK field to 1, unless that gets overridden by --ebytchk=BCH π¦
π§ NOTES π§
Various numeric arguments (like LBA) can include multiplicative suffixes or be given in hexadecimal. Check out the "NUMERIC ARGUMENTS" section in the sg3_utils(8) man page for the deets π₯
The amount of error correction and the number of retries attempted before a block is considered defective are controlled partly by the Verify Error Recovery mode page. A note in the SBC-3 draft (rev 29, section 6.4.9 on the Verify Error Recovery mode page) says that if you want to minimize the number of checks (and therefore have the most "sensitive" verify check), do the following in that mode page: set the EER bit to 0, the PER bit to 1, the DTE bit to 1, the DCR bit to 1, the verify retry count to 0 and the verify recovery time limit to 0. You can change mode pages with the sdparm utility π
The SCSI VERIFY(6) command defined in the SSC-2 standard and later (which is for tape drive systems) is not supported by this utility. Sorry, tape fans π
π EXIT STATUS π
The exit status of sg_verify is 0 when it succeeds. When BCH is anything other than 0, a comparison happens, and if it fails, the exit status is 14, which just so happens to be the sense key value of MISCOMPARE π Otherwise, check the EXIT STATUS section in the sg3_utils(8) man page.
Earlier versions of this utility set an exit status of 98 when there was a MISCOMPARE. Old news, bestie π
π«Ά AUTHORS π«Ά
Written by Douglas Gilbert. Iconic β¨
π REPORTING BUGS π
Report bugs to <dgilbert at interlog dot com>. Be nice about it π₯Ί
π COPYRIGHT π
Copyright Β© 2004-2019 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 π
sdparm(sdparm), sg_modes(sg3_utils), sg_readcap(sg3_utils), sg_inq(sg3_utils)
Okay that's the tea! β¨ This was sg3_utils-1.45, last updated December 2019. Stay iconic, bestie ππ¦π
π¦ 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