# phpman > man > SG_VERIFY(8)

[SG_VERIFY(8)](https://www.chedong.com/phpMan.php/man/SGVERIFY/8/markdown)                                  SG3_UTILS                                 [SG_VERIFY(8)](https://www.chedong.com/phpMan.php/man/SGVERIFY/8/markdown)



## NAME
       sg_verify - 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
       Sends  one or more SCSI VERIFY (10 or 16) commands to _DEVICE_. These SCSI commands are defined
       in the SBC-2 and SBC-3 standards at <http://www.t10.org> and SBC-4 drafts.

       When _--ndo=NDO_ is not given then the verify starts at the logical block address given by  the
       _--lba=LBA_  option  and  continues for _--count=COUNT_ blocks. No more than _--bpc=BPC_ blocks are
       verified by each VERIFY command so if necessary multiple VERIFY  commands  are  sent.  Medium
       verification operations are performed by the _DEVICE_ (e.g.  assuming each block has additional
       EEC data, check this against the logical block contents). No news is good news (i.e. if there
       are no verify errors detected then no messages are sent to stderr and the Unix exit status is
       0).

       When _--ndo=NDO_ is given then the _--bpc=BPC_ option is ignored. A single VERIFY command is  is‐
       sued  and  a comparison starts at the logical block address given by the _--lba=LBA_ option and
       continues for _--count=COUNT_ blocks. The VERIFY command has an associated data-out buffer that
       is  _NDO_  bytes  long.  The  contents of the data-out buffer are obtained from the _FN_ file (if
       _--in=FN_ is given) or from stdin.  A comparison takes place between data-out  buffer  and  the
       logical  blocks  on the _DEVICE_. If the comparison is good then no messages are sent to stderr
       and the Unix exit status is 0. If the comparison fails then a sense buffer with a  sense  key
       of  MISCOMPARE  is  returned;  in this case the Unix exit status will be 14. Messages will be
       sent to stderr associated with MISCOMPARE sense buffer unless the _--quiet_ option is given.

       In SBC-3 revision 34 the BYTCHK field in all SCSI VERIFY commands was expanded  from  one  to
       two bits. That required some changes in the options of this utility, see 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
              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.

### -S --16
              uses  a  [VERIFY(16)](https://www.chedong.com/phpMan.php/man/VERIFY/16/markdown)  command  (default [VERIFY(10)](https://www.chedong.com/phpMan.php/man/VERIFY/10/markdown)). Even without this option, using an
              _--lba=LBA_ which is too large, will cause the utility to issue a [VERIFY(16)](https://www.chedong.com/phpMan.php/man/VERIFY/16/markdown) command.

### -b --bpc
              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)](https://www.chedong.com/phpMan.php/man/VERIFY/10/markdown) _BPC_ cannot exceed 0xffff (65,535) while for [VERIFY(16)](https://www.chedong.com/phpMan.php/man/VERIFY/16/markdown)  _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.

### -c --count
              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 **sg**___**readcap** utility can be used to find the maximum number of blocks that  a  block
              device (e.g. a disk) has.

### -d --dpo
              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.

### -E --ebytchk
              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).

### -f --ff
              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.

### -g --group
              where _GN_ becomes the contents of the group number field in the  SCSI  [VERIFY(16)](https://www.chedong.com/phpMan.php/man/VERIFY/16/markdown)  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)](https://www.chedong.com/phpMan.php/man/VERIFY/10/markdown) command.

### -h --help
              output the usage message then exit.

### -i --in
              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.

### -l --lba
              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).

### -n --ndo
              _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.

### -q --quiet
              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 .

### -r --readonly
              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.

### -v --verbose
              increase the level of verbosity, (i.e. debug output).

### -V --version
              print the version string and then exit.

### -P --vrprotect
              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.

## BYTCHK
       BYTCHK is the name of a field (two bits wide) in the [VERIFY(10)](https://www.chedong.com/phpMan.php/man/VERIFY/10/markdown) and [VERIFY(16)](https://www.chedong.com/phpMan.php/man/VERIFY/16/markdown) commands. When
       set to 1 or 3 (sbc3r34 reserves the value 2) it indicates that associated with the SCSI  VER‐
       IFY  command,  a  data-out  buffer  will  be  sent  for the device (disk) to check. Using the
       _--ndo=NDO_ option sets the BYTCHK field to 1 and _NDO_ is the number  of  bytes  placed  in  the
       data-out  buffer.  Those  bytes  are obtained from stdin or _IF_ (from the _--in=FN_ option). The
       _--ebytchk=BCH_ option may be used to override the BYTCHK field value of 1 with _BCH_.

       The calculation of _NDO_ is left up to the user. Its value depends on the  logical  block  size
       (which can be found with the sg_readcap utility), the _COUNT_ and the _VRP_ values. If the _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 then the verification process done by the device (disk) is vendor
       specific. It typically involves checking each block on the disk against its error  correction
       codes (ECC) which is additional data also held on the disk.

       Many  Operating  Systems put limits on the maximum size of the data-out (and data-in) buffer.
       For Linux at one time the limit was less than 1 MB but has been increased somewhat.

## OPTION CHANGES
       Earlier versions of this utility had a _--bytchk=NDO_ option which 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 present but not documented. In its place  is  the
       _--ndo=NDO_  whose shorter form of _-n_ _NDO_.  _--ndo=NDO_ sets the BYTCHK field to 1 unless that is
       overridden by the _--ebytchk=BCH_.

## NOTES
       Various numeric arguments (e.g. _LBA_) may include multiplicative suffixes or be given in hexa‐
       decimal. See the "NUMERIC ARGUMENTS" section in the [sg3_utils(8)](https://www.chedong.com/phpMan.php/man/sg3utils/8/markdown) man page.

       The  amount of error correction and the number of retries attempted before a block is consid‐
       ered defective are controlled in part 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) advises that to
       minimize the number of checks (and hence have the most "sensitive" verify check) do the  fol‐
       lowing  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. Mode pages can
       be modified with the **sdparm** utility.

       The SCSI [VERIFY(6)](https://www.chedong.com/phpMan.php/man/VERIFY/6/markdown) command defined in the SSC-2 standard and later (i.e.  for tape drive sys‐
       tems) is not supported by this utility.

## EXIT STATUS
       The exit status of sg_verify is 0 when it is successful. When _BCH_ is other than 0 then a com‐
       parison  takes place and if it fails then the exit status is 14 which happens to be the sense
       key value of MISCOMPARE.  Otherwise see the EXIT STATUS section in the [sg3_utils(8)](https://www.chedong.com/phpMan.php/man/sg3utils/8/markdown) man page.

       Earlier versions of this utility set an exit status of 98 when there was a MISCOMPARE.

## AUTHORS
       Written by Douglas Gilbert.

## REPORTING BUGS
       Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
       Copyright © 2004-2019 Douglas Gilbert
       This software is distributed under a FreeBSD license. There is NO warranty; not even for MER‐
       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
       **sdparm(sdparm),** **sg**___**modes(sg3**___**utils),** **sg**___**readcap(sg3**___**utils),** **sg**___**inq(sg3**___**utils)**



sg3_utils-1.45                              December 2019                               [SG_VERIFY(8)](https://www.chedong.com/phpMan.php/man/SGVERIFY/8/markdown)
