Badblocks: Difference between revisions
No edit summary |
|||
| Line 24: | Line 24: | ||
== Test Patterns == | == Test Patterns == | ||
The test that is done by default is to write to the disk in 4 passes, each with the following pattern: | The test that is done by default is to write to the disk in 4 passes, each with the following pattern: | ||
# 0xAA | # 0xAA - 10101010 | ||
# 0x55 | # 0x55 - 01010101 | ||
# 0xff | # 0xff - 11111111 | ||
# 0x00 | # 0x00 - 00000000 | ||
You may override this using the {{code|-t}} flag. | You may override this using the {{code|-t}} flag. | ||
== See Also == | == See Also == | ||
* https://wiki.archlinux.org/index.php/Badblocks | * https://wiki.archlinux.org/index.php/Badblocks | ||
Revision as of 22:19, 6 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. It's also useful for testing new hard drives (before the warranty expires) or checking if a older drive is reliable. Be forewarned - larger disks takes a very long time to test.
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 - 10101010
- 0x55 - 01010101
- 0xff - 11111111
- 0x00 - 00000000
You may override this using the -t flag.