badblocks

From RaySoft

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). last-block is the last block to be checked; if it is not specified, the last block on the device is used as a default. start-block is an optional parameter specifying the starting block number for the test, which allows the testing to start in the middle of the disk. If it is not specified the first block on the disk is used as a default.[1]

Documentation

Syntax

badblocks [PARAMETER ...] DEVICE [LAST-BLOCK] [START-BLOCK]

Parameters

-f
Normally, badblocks will refuse to do a read/write or a non-destructive test on a device which is mounted, since either can cause the system to potentially crash and/or damage the filesystem even if it is mounted read-only. This can be overridden using the -f flag, but should almost never be used - if you think you're smarter than the badblocks program, you almost certainly aren't. The only time when this option might be safe to use is if the /etc/mtab file is incorrect, and the device really isn't mounted.
-i FILE
Read a list of already existing known bad blocks. badblocks will skip testing these blocks since they are known to be bad. If iFILE is specified as -, the list will be read from the standard input. Blocks listed in this list will be omitted from the list of new bad blocks produced on the standard output or in the output file. The -b option of dumpe2fs can be used to retrieve the list of blocks currently marked bad on an existing filesystem, in a format suitable for use with this option.
-n
Use non-destructive read-write mode. By default only a non-destructive read-only test is done. This option must not be combined with the -w option, as they are mutually exclusive.
-o FILE
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 or mke2fs.
-p NUMBER
Repeat scanning the disk until there are no new blocks discovered in NUMBER consecutive scans of the disk. Default is 0, meaning badblocks will exit after the first pass.
-s
Show the progress of the scan by writing out the block numbers as they are checked.
-w
Use write-mode test. With this option, badblocks scans for bad blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on every block of the device, reading every block and comparing the contents. This option may not be combined with the -n option, as they are mutually exclusive.

References

  1. man 8 'badblocks'