Badblocks
Also see smartmontools
Examples for common use cases
Testing a new drive (erases all data!):
badblocks -svw -c 4096 -b 4096 /dev/sdX
Flags:
-s Show the progress of the scan by writing out rough percentage completion of the current badblocks pass over the disk. Note that badblocks may do
multiple test passes over the disk, in particular if the -p or -w option is requested by the user.
-v Verbose mode. Will write the number of read errors, write errors and data- corruptions to stderr.
-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.
Testing a drive that has data on it:
badblocks -svn -c 4096 -b 4096 /dev/sdX
Flags:
-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.