Badblocks: Difference between revisions
more info, formatting |
m Leo moved page Bad Blocks to Badblocks: utility name |
||
(No difference)
| |||
Revision as of 05:11, 2 June 2017
badblocks is a utility that checks for bad blocks on a storage device.
This is useful for testing new or questionable media including fake USB drives that show as a larger drive than it can actually store.
Basic Usage
The destructive test can be done by running:
## Warning! This will wipe your data!
# badblocks -wsv -o /root/badblocks.txt /dev/sda
Use the -n flag for a non-destructive test. A non-destructive test will store the sector value, test the sector, then restore the original sector value.
There are 3 numbers that will be returned as 1/2/3 in this order:
- number of read errors
- number of write errors
- number of corruption errors
The badblocks.txt file that gets created can then be used by mkfs so that the filesystem can skip over known bad sectors like so:
# mkfs.ext4 -l /tmp/badblocks.txt /dev/sda
Test Patterns
The test that is done by default is to write to the disk in 4 passes, each with the following pattern:
- 0xAA
- 0x55
- 0xff
- 0x00
You may override this using the -t flag.