Badblocks: Difference between revisions

From David's Wiki
 
Line 6: Line 6:
ETA is approximately 1 day per 4 terabytes.
ETA is approximately 1 day per 4 terabytes.
<pre>
<pre>
badblocks -wsv -b 4096 /dev/sdg
badblocks -wsv -b 4096 -t 0x55 -o badblocks.txt /dev/sdg
</pre>
</pre>
* <code>-w</code> do a destructive write test
* <code>-w</code> do a destructive write test
Line 13: Line 13:
* <code>-b ''num''</code> block size. Use 4096 typically.
* <code>-b ''num''</code> block size. Use 4096 typically.
* <code>-p ''num''</code> do ''num'' iterations. Typically 1 is sufficient.
* <code>-p ''num''</code> do ''num'' iterations. Typically 1 is sufficient.
* <code>-t ''test_pattern''</code> Test pattern. Select from [random,
* <code>-t ''test_pattern''</code> Test pattern. Can be random. E.g. 0x55
* <code>-o ''file''</code> output badblocks to a file


To save the list of bad blocks, you need to run <code>e2fsck</code> or <code>mkfs.ext4</code>:
To save the list of bad blocks, you need to run <code>e2fsck</code> or <code>mkfs.ext4</code>:

Latest revision as of 20:44, 3 October 2020

Badblocks is a tool for detecting bad blocks in your hard disk.

Usage

The following will write to every block and read back to identify the number of bad blocks.

This is a destructive test. ETA is approximately 1 day per 4 terabytes.

badblocks -wsv -b 4096 -t 0x55 -o badblocks.txt /dev/sdg
  • -w do a destructive write test
  • -s show progress
  • -v verbose
  • -b num block size. Use 4096 typically.
  • -p num do num iterations. Typically 1 is sufficient.
  • -t test_pattern Test pattern. Can be random. E.g. 0x55
  • -o file output badblocks to a file

To save the list of bad blocks, you need to run e2fsck or mkfs.ext4:

sudo e2fsck -fcck /dev/device
  • -f force check
  • -cc non-destructive write test
  • -k add bad blocks to bad blocks list
mkfs.ext4 -cc /dev/device

Resources