Badblocks: Difference between revisions
Created page with " badblocks -wsv -o /root/<badblocks.txt> /dev/<device> <number of read errors>/<number of write errors>/<number of corruption errors>. mkfs.<filesystem-type> -l /root/<ba..." |
more info, formatting |
||
| Line 1: | Line 1: | ||
{{code|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: | |||
{{highlight|lang=terminal|code= | |||
## Warning! This will wipe your data! | |||
# badblocks -wsv -o /root/badblocks.txt /dev/sda | |||
}} | |||
Use the {{code|-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 {{code|mkfs}} so that the filesystem can skip over known bad sectors like so: | |||
{{highlight|lang=terminal|code= | |||
# 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 {{code|-t}} flag. | |||
== See Also == | == See Also == | ||
* https://wiki.archlinux.org/index.php/Badblocks | * https://wiki.archlinux.org/index.php/Badblocks | ||
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.