{
    "mode": "man",
    "parameter": "SG_VERIFY",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/SG_VERIFY/8/json",
    "generated": "2026-06-14T06:09:57Z",
    "synopsis": "sgverify   [--0]   [--16]   [--bpc=BPC]   [--count=COUNT]   [--dpo]  [--ff]  [--ebytchk=BCH]\n[--group=GN] [--help] [--in=IF] [--lba=LBA] [--ndo=NDO]  [--quiet]  [--readonly]  [--verbose]\n[--version] [--vrprotect=VRP] DEVICE",
    "sections": {
        "NAME": {
            "content": "sgverify - invoke SCSI VERIFY command(s) on a block device\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sgverify   [--0]   [--16]   [--bpc=BPC]   [--count=COUNT]   [--dpo]  [--ff]  [--ebytchk=BCH]\n[--group=GN] [--help] [--in=IF] [--lba=LBA] [--ndo=NDO]  [--quiet]  [--readonly]  [--verbose]\n[--version] [--vrprotect=VRP] DEVICE\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Sends  one or more SCSI VERIFY (10 or 16) commands to DEVICE. These SCSI commands are defined\nin the SBC-2 and SBC-3 standards at http://www.t10.org and SBC-4 drafts.\n\nWhen --ndo=NDO is not given then the verify starts at the logical block address given by  the\n--lba=LBA  option  and  continues for --count=COUNT blocks. No more than --bpc=BPC blocks are\nverified by each VERIFY command so if necessary multiple VERIFY  commands  are  sent.  Medium\nverification operations are performed by the DEVICE (e.g.  assuming each block has additional\nEEC data, check this against the logical block contents). No news is good news (i.e. if there\nare no verify errors detected then no messages are sent to stderr and the Unix exit status is\n0).\n\nWhen --ndo=NDO is given then the --bpc=BPC option is ignored. A single VERIFY command is  is‐\nsued  and  a comparison starts at the logical block address given by the --lba=LBA option and\ncontinues for --count=COUNT blocks. The VERIFY command has an associated data-out buffer that\nis  NDO  bytes  long.  The  contents of the data-out buffer are obtained from the FN file (if\n--in=FN is given) or from stdin.  A comparison takes place between data-out  buffer  and  the\nlogical  blocks  on the DEVICE. If the comparison is good then no messages are sent to stderr\nand the Unix exit status is 0. If the comparison fails then a sense buffer with a  sense  key\nof  MISCOMPARE  is  returned;  in this case the Unix exit status will be 14. Messages will be\nsent to stderr associated with MISCOMPARE sense buffer unless the --quiet option is given.\n\nIn SBC-3 revision 34 the BYTCHK field in all SCSI VERIFY commands was expanded  from  one  to\ntwo bits. That required some changes in the options of this utility, see the section below on\nOPTION CHANGES.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Arguments to long options are mandatory for short options as well.  The options are  arranged\nin alphabetical order based on the long option name.\n",
            "subsections": [
                {
                    "name": "-0 --0",
                    "content": "a  buffer  NDO  bytes long full of zeros is sent as the data-out part of a VERIFY com‐\nmand. So stdin is not read and if --in=IF is given, an error is generated. Useful when\nBCH is 3 to check if some or all of DEVICE (e.g. a disk) is zero filled blocks.\n",
                    "flag": "-0",
                    "long": "--0"
                },
                {
                    "name": "-S --16",
                    "content": "uses  a  VERIFY(16)  command  (default VERIFY(10)). Even without this option, using an\n--lba=LBA which is too large, will cause the utility to issue a VERIFY(16) command.\n",
                    "flag": "-S",
                    "long": "--16"
                },
                {
                    "name": "-b --bpc",
                    "content": "this option is ignored if --ndo=NDO is given. Otherwise BPC specifies the maximum num‐\nber of blocks that will be verified by a single SCSI VERIFY command. The default value\nis 128 blocks which equates to 64 KB for a disk with 512 byte blocks. If BPC  is  less\nthan  COUNT then multiple SCSI VERIFY commands are sent to the DEVICE. For the default\nVERIFY(10) BPC cannot exceed 0xffff (65,535) while for VERIFY(16)  BPC  cannot  exceed\n0x7fffffff  (2,147,483,647).  For  recent block devices (disks) this value may be con‐\nstrained by the maximum transfer length field in the block limits VPD page.\n",
                    "flag": "-b",
                    "long": "--bpc"
                },
                {
                    "name": "-c --count",
                    "content": "where COUNT specifies the number of blocks to verify. The default  value  is  1  .  If\nCOUNT  is  greater  than  BPC (or its default value of 128) and NDO is not given, 0 or\nless than multiple SCSI VERIFY commands are sent to the device.  Otherwise  COUNT  be‐\ncomes the contents of the verification length field of the SCSI VERIFY command issued.\nThe sgreadcap utility can be used to find the maximum number of blocks that  a  block\ndevice (e.g. a disk) has.\n",
                    "flag": "-c",
                    "long": "--count"
                },
                {
                    "name": "-d --dpo",
                    "content": "disable  page  out changes the cache retention priority of blocks read on the device's\ncache to the lowest priority. This means that blocks read by other commands  are  more\nlikely to remain in the device's cache.\n",
                    "flag": "-d",
                    "long": "--dpo"
                },
                {
                    "name": "-E --ebytchk",
                    "content": "sets  the  BYTCHK  field  to BCH overriding the value (1) set by the --ndo=NDO option.\nValues of 1, 2 or 3 are accepted for BCH however sbc3r34 reserves the value 2. If this\noption  is given then --ndo=NDO must also be given. If BCH is 3 then NDO should be the\nsize of one logical block (plus the size of some or all of the protection  information\nif VRP is greater than 0).\n",
                    "flag": "-E",
                    "long": "--ebytchk"
                },
                {
                    "name": "-f --ff",
                    "content": "a  buffer  NDO  bytes long full of 0xff bytes is sent as the data-out part of a VERIFY\ncommand. So stdin is not read and if --in=IF is given, an error is  generated.  Useful\nwhen  BCH  is  3  to  check if some or all of DEVICE (e.g. a disk) is 0xff byte filled\nblocks.\n",
                    "flag": "-f",
                    "long": "--ff"
                },
                {
                    "name": "-g --group",
                    "content": "where GN becomes the contents of the group number field in the  SCSI  VERIFY(16)  com‐\nmand.  It can be from 0 to 63 inclusive. The default value for GN is 0. Note that this\noption is ignored for the SCSI VERIFY(10) command.\n",
                    "flag": "-g",
                    "long": "--group"
                },
                {
                    "name": "-h --help",
                    "content": "output the usage message then exit.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-i --in",
                    "content": "where IF is the name of a file from which NDO bytes will be read  and  placed  in  the\ndata-out  buffer. This is only done when the --ndo=NDO option is given. If this option\nis not given then stdin is read. If IF is \"-\" then stdin is also used.\n",
                    "flag": "-i",
                    "long": "--in"
                },
                {
                    "name": "-l --lba",
                    "content": "where LBA specifies the logical block address of the first block to start  the  verify\noperation. LBA is assumed to be decimal unless prefixed by '0x' or a trailing 'h' (see\nbelow). The default value is 0 (i.e. the start of the device).\n",
                    "flag": "-l",
                    "long": "--lba"
                },
                {
                    "name": "-n --ndo",
                    "content": "NDO is the number of bytes to obtain from the FN file (if --in=FN is  given)  or  from\nstdin.  Those  bytes are placed in the data-out buffer associated with the SCSI VERIFY\ncommand and NDO is placed in the verification length field in  the  cdb.  The  default\nvalue  for NDO is 0 and the maximum value is dependent on the OS. If the --ebytchk=BCH\noption is not given then the BYTCHK field in the cdb is set to 1.\n",
                    "flag": "-n",
                    "long": "--ndo"
                },
                {
                    "name": "-q --quiet",
                    "content": "suppress the sense buffer messages associated with a MISCOMPARE sense key  that  would\notherwise  be  sent  to stderr. Still set the exit status to 14 which is the sense key\nvalue indicating a MISCOMPARE .\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-r --readonly",
                    "content": "opens the DEVICE read-only rather than read-write which is the default. The  Linux  sg\ndriver  needs  read-write  access for the SCSI VERIFY command but other access methods\nmay require read-only access.\n",
                    "flag": "-r",
                    "long": "--readonly"
                },
                {
                    "name": "-v --verbose",
                    "content": "increase the level of verbosity, (i.e. debug output).\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-V --version",
                    "content": "print the version string and then exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-P --vrprotect",
                    "content": "where VRP is the value in the vrprotect field in the VERIFY command cdb. It must be  a\nvalue between 0 and 7 inclusive. The default value is zero.\n",
                    "flag": "-P",
                    "long": "--vrprotect"
                }
            ]
        },
        "BYTCHK": {
            "content": "BYTCHK is the name of a field (two bits wide) in the VERIFY(10) and VERIFY(16) commands. When\nset to 1 or 3 (sbc3r34 reserves the value 2) it indicates that associated with the SCSI  VER‐\nIFY  command,  a  data-out  buffer  will  be  sent  for the device (disk) to check. Using the\n--ndo=NDO option sets the BYTCHK field to 1 and NDO is the number  of  bytes  placed  in  the\ndata-out  buffer.  Those  bytes  are obtained from stdin or IF (from the --in=FN option). The\n--ebytchk=BCH option may be used to override the BYTCHK field value of 1 with BCH.\n\nThe calculation of NDO is left up to the user. Its value depends on the  logical  block  size\n(which can be found with the sgreadcap utility), the COUNT and the VRP values. If the VRP is\ngreater than 0 then each logical block will contain an extra 8 bytes (at least) of protection\ninformation.\n\nWhen  the BYTCHK field is 0 then the verification process done by the device (disk) is vendor\nspecific. It typically involves checking each block on the disk against its error  correction\ncodes (ECC) which is additional data also held on the disk.\n\nMany  Operating  Systems put limits on the maximum size of the data-out (and data-in) buffer.\nFor Linux at one time the limit was less than 1 MB but has been increased somewhat.\n",
            "subsections": []
        },
        "OPTION CHANGES": {
            "content": "Earlier versions of this utility had a --bytchk=NDO option which set the BYTCHK bit  and  set\nthe  cdb  verification  length field to NDO.  The shorter form of that option was -B NDO. For\nbackward compatibility that option is still present but not documented. In its place  is  the\n--ndo=NDO  whose shorter form of -n NDO.  --ndo=NDO sets the BYTCHK field to 1 unless that is\noverridden by the --ebytchk=BCH.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Various numeric arguments (e.g. LBA) may include multiplicative suffixes or be given in hexa‐\ndecimal. See the \"NUMERIC ARGUMENTS\" section in the sg3utils(8) man page.\n\nThe  amount of error correction and the number of retries attempted before a block is consid‐\nered defective are controlled in part by the Verify Error Recovery mode page. A note  in  the\nSBC-3  draft  (rev  29  section 6.4.9 on the Verify Error Recovery mode page) advises that to\nminimize the number of checks (and hence have the most \"sensitive\" verify check) do the  fol‐\nlowing  in  that mode page: set the EER bit to 0, the PER bit to 1, the DTE bit to 1, the DCR\nbit to 1, the verify retry count to 0 and the verify recovery time limit to 0. Mode pages can\nbe modified with the sdparm utility.\n\nThe SCSI VERIFY(6) command defined in the SSC-2 standard and later (i.e.  for tape drive sys‐\ntems) is not supported by this utility.\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "The exit status of sgverify is 0 when it is successful. When BCH is other than 0 then a com‐\nparison  takes place and if it fails then the exit status is 14 which happens to be the sense\nkey value of MISCOMPARE.  Otherwise see the EXIT STATUS section in the sg3utils(8) man page.\n\nEarlier versions of this utility set an exit status of 98 when there was a MISCOMPARE.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Written by Douglas Gilbert.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Report bugs to <dgilbert at interlog dot com>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2004-2019 Douglas Gilbert\nThis software is distributed under a FreeBSD license. There is NO warranty; not even for MER‐\nCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sdparm(sdparm), sgmodes(sg3utils), sgreadcap(sg3utils), sginq(sg3utils)\n\n\n\nsg3utils-1.45                              December 2019                               SGVERIFY(8)",
            "subsections": []
        }
    },
    "summary": "sgverify - invoke SCSI VERIFY command(s) on a block device",
    "flags": [
        {
            "flag": "-0",
            "long": "--0",
            "arg": null,
            "description": "a buffer NDO bytes long full of zeros is sent as the data-out part of a VERIFY com‐ mand. So stdin is not read and if --in=IF is given, an error is generated. Useful when BCH is 3 to check if some or all of DEVICE (e.g. a disk) is zero filled blocks."
        },
        {
            "flag": "-S",
            "long": "--16",
            "arg": null,
            "description": "uses a VERIFY(16) command (default VERIFY(10)). Even without this option, using an --lba=LBA which is too large, will cause the utility to issue a VERIFY(16) command."
        },
        {
            "flag": "-b",
            "long": "--bpc",
            "arg": null,
            "description": "this option is ignored if --ndo=NDO is given. Otherwise BPC specifies the maximum num‐ ber of blocks that will be verified by a single SCSI VERIFY command. The default value is 128 blocks which equates to 64 KB for a disk with 512 byte blocks. If BPC is less than COUNT then multiple SCSI VERIFY commands are sent to the DEVICE. For the default VERIFY(10) BPC cannot exceed 0xffff (65,535) while for VERIFY(16) BPC cannot exceed 0x7fffffff (2,147,483,647). For recent block devices (disks) this value may be con‐ strained by the maximum transfer length field in the block limits VPD page."
        },
        {
            "flag": "-c",
            "long": "--count",
            "arg": null,
            "description": "where COUNT specifies the number of blocks to verify. The default value is 1 . If COUNT is greater than BPC (or its default value of 128) and NDO is not given, 0 or less than multiple SCSI VERIFY commands are sent to the device. Otherwise COUNT be‐ comes the contents of the verification length field of the SCSI VERIFY command issued. The sgreadcap utility can be used to find the maximum number of blocks that a block device (e.g. a disk) has."
        },
        {
            "flag": "-d",
            "long": "--dpo",
            "arg": null,
            "description": "disable page out changes the cache retention priority of blocks read on the device's cache to the lowest priority. This means that blocks read by other commands are more likely to remain in the device's cache."
        },
        {
            "flag": "-E",
            "long": "--ebytchk",
            "arg": null,
            "description": "sets the BYTCHK field to BCH overriding the value (1) set by the --ndo=NDO option. Values of 1, 2 or 3 are accepted for BCH however sbc3r34 reserves the value 2. If this option is given then --ndo=NDO must also be given. If BCH is 3 then NDO should be the size of one logical block (plus the size of some or all of the protection information if VRP is greater than 0)."
        },
        {
            "flag": "-f",
            "long": "--ff",
            "arg": null,
            "description": "a buffer NDO bytes long full of 0xff bytes is sent as the data-out part of a VERIFY command. So stdin is not read and if --in=IF is given, an error is generated. Useful when BCH is 3 to check if some or all of DEVICE (e.g. a disk) is 0xff byte filled blocks."
        },
        {
            "flag": "-g",
            "long": "--group",
            "arg": null,
            "description": "where GN becomes the contents of the group number field in the SCSI VERIFY(16) com‐ mand. It can be from 0 to 63 inclusive. The default value for GN is 0. Note that this option is ignored for the SCSI VERIFY(10) command."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "output the usage message then exit."
        },
        {
            "flag": "-i",
            "long": "--in",
            "arg": null,
            "description": "where IF is the name of a file from which NDO bytes will be read and placed in the data-out buffer. This is only done when the --ndo=NDO option is given. If this option is not given then stdin is read. If IF is \"-\" then stdin is also used."
        },
        {
            "flag": "-l",
            "long": "--lba",
            "arg": null,
            "description": "where LBA specifies the logical block address of the first block to start the verify operation. LBA is assumed to be decimal unless prefixed by '0x' or a trailing 'h' (see below). The default value is 0 (i.e. the start of the device)."
        },
        {
            "flag": "-n",
            "long": "--ndo",
            "arg": null,
            "description": "NDO is the number of bytes to obtain from the FN file (if --in=FN is given) or from stdin. Those bytes are placed in the data-out buffer associated with the SCSI VERIFY command and NDO is placed in the verification length field in the cdb. The default value for NDO is 0 and the maximum value is dependent on the OS. If the --ebytchk=BCH option is not given then the BYTCHK field in the cdb is set to 1."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "suppress the sense buffer messages associated with a MISCOMPARE sense key that would otherwise be sent to stderr. Still set the exit status to 14 which is the sense key value indicating a MISCOMPARE ."
        },
        {
            "flag": "-r",
            "long": "--readonly",
            "arg": null,
            "description": "opens the DEVICE read-only rather than read-write which is the default. The Linux sg driver needs read-write access for the SCSI VERIFY command but other access methods may require read-only access."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "increase the level of verbosity, (i.e. debug output)."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "print the version string and then exit."
        },
        {
            "flag": "-P",
            "long": "--vrprotect",
            "arg": null,
            "description": "where VRP is the value in the vrprotect field in the VERIFY command cdb. It must be a value between 0 and 7 inclusive. The default value is zero."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "sdparm",
            "section": "sdparm",
            "url": "https://www.chedong.com/phpMan.php/man/sdparm/sdparm/json"
        },
        {
            "name": "sgmodes",
            "section": "sg3utils",
            "url": "https://www.chedong.com/phpMan.php/man/sgmodes/sg3utils/json"
        },
        {
            "name": "sgreadcap",
            "section": "sg3utils",
            "url": "https://www.chedong.com/phpMan.php/man/sgreadcap/sg3utils/json"
        },
        {
            "name": "sginq",
            "section": "sg3utils",
            "url": "https://www.chedong.com/phpMan.php/man/sginq/sg3utils/json"
        }
    ]
}