Badblocks: Difference between revisions
m Leo moved page Bad Blocks to Badblocks: utility name |
No edit summary |
||
| Line 1: | Line 1: | ||
{{code|badblocks}} is a utility that checks for bad blocks on a storage device. | {{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. | 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 == | == Basic Usage == | ||
Revision as of 05:13, 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. 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
- 0x55
- 0xff
- 0x00
You may override this using the -t flag.