- Search a disk for bad blocks by using a non-destructive read-only test:sudo badblocks [/dev/sda]- Search an unmounted disk for bad blocks with a non-destructive read-write test:sudo badblocks -n [/dev/sda]- Search an unmounted disk for bad blocks with a destructive write test:sudo badblocks -w [/dev/sda]
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 ]
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. first_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.
Important note: If the output of badblocks is going to be fed to the e2fsck or mke2fs programs, it is important that the block size is properly specified, since the block numbers which are generated are very dependent on the block size in use by the filesystem. For this reason, it is strongly recommended that users not run badblocks directly, but rather use the -c option of the e2fsck and mke2fs programs.
Never use the -w option on a device containing an existing file system. This option erases data! If you want to do write-mode testing on an existing file system, use the -n option instead. It is slower, but it will preserve your data.
The -e option will cause badblocks to output a possibly incomplete list of bad blocks. Therefore it is recommended to use it only when one wants to know if there are any bad blocks at all on the device, and not when the list of bad blocks is wanted.
badblocks was written by Remy Card <Remy.Card@linux.org>. Current maintainer is Theodore Ts'o <email@example.com>. Non-destructive read/write test implemented by David Beattie <firstname.lastname@example.org>.
badblocks is part of the e2fsprogs package and is available from http://e2fsprogs.sourceforge.net.