Linux "badblocks" Command Line Options and Examples
search a device for bad blocks

badblocks is used to search for bad blocks on a device (usually a disk partition). device is the special file corresponding to the device (e.g /dev/hdc1).


Usage:

badblocks [ -svwnfBX ] [ -b block_size ] [ -c blocks_at_once ] [ -d read_delay_factor ] [ -e max_bad_blocks ] [ -i input_file ] [ -o
output_file ] [ -p num_passes ] [ -t test_pattern ] device [ last_block ] [ first_block ]






Command Line Options:

-b
Specify the size of blocks in bytes. The default is 1024.
badblocks -b ...
-c
is the number of blocks which are tested at a time. The default is 64.
badblocks -c ...
-d
This parameter, if passed and non-zero, will cause bad blocks to sleep between reads if there were no errors encountered inthe read operation; the delay will be calculated as a percentage of the time it took for the read operation to be performed.In other words, a value of 100 will cause each read to be delayed by the amount the previous read took, and a value of 200 bytwice the amount.
badblocks -d ...
-e
Specify a maximum number of bad blocks before aborting the test. The default is 0, meaning the test will continue until theend of the test range is reached.
badblocks -e ...
-i
Read a list of already existing known bad blocks. Badblocks will skip testing these blocks since they are known to be bad.If input_file is specified as "-", the list will be read from the standard input. Blocks listed in this list will be omittedfrom the list of new bad blocks produced on the standard output or in the output file. The -b option of dumpe2fs(8) can beused to retrieve the list of blocks currently marked bad on an existing filesystem, in a format suitable for use with thisoption.
badblocks -i ...
-o
Write the list of bad blocks to the specified file. Without this option, badblocks displays the list on its standard output.The format of this file is suitable for use by the -l option in e2fsck(8) or mke2fs(8).
badblocks -o ...
-p
Repeat scanning the disk until there are no new blocks discovered in num_passes consecutive scans of the disk. Default is 0,meaning badblocks will exit after the first pass.
badblocks -p ...
-t
Specify a test pattern to be read (and written) to disk blocks. The test_pattern may either be a numeric value between 0 andULONG_MAX-1 inclusive, or the word "random", which specifies that the block should be filled with a random bit pattern. Forread/write (-w) and non-destructive (-n) modes, one or more test patterns may be specified by specifying the -t option foreach test pattern desired. For read-only mode only a single pattern may be specified and it may not be "random". Read-onlytesting with a pattern assumes that the specified pattern has previously been written to the disk - if not, large numbers ofblocks will fail verification. If multiple patterns are specified then all blocks will be tested with one pattern before pro‐ceeding to the next pattern.
badblocks -t ...
-v
Verbose mode. Will write the number of read errors, write errors and data- corruptions to stderr.
badblocks -v ...
-B
Use buffered I/O and do not use Direct I/O, even if it is available.
badblocks -B ...