A detailed explanation of badblocks instructions under CentOS
First, command parameters
Badblocks uses the format:
Reference
badblocks [-SVWNF] [-B block-size] [-C blocks_at_once] [-I
Input_file] [-O output_file] [-P num_passes] [-t Test_pattern]
device [Last-block] [Start-block]
The parameter meaning is:
Reference
-B blocksize
Specifies the chunk size, in bytes, of the disk, and the default value is Block 4K (4k/block)
-C blocksize
Number of checks per block, default is 16 times
-F
To force a read or write test operation to be performed on a device that is already mounted
(We recommend umount the equipment before the bad track detection.) You can use this option only if/etc/mtab has a false positives device mount error.
-I. File
Skip the bad track already displayed in the file, without detection (you can avoid duplicate detection)
-O File
Output test results to file files
-P Number
Repeat the search device until no new bad block location is found in the specified number of passes, the default number is 0
-S
Show progress while checking
-T pattern
Blocks are detected by reading and writing in the specified mode. You can specify a decimal positive value of 0 to ulong_max-1, or use random (random).
If you specify more than one pattern, Badblocks will use the first mode to detect all blocks and then use the next mode to detect all the blocks.
The read-only mode accepts only one pattern, and it cannot accept random mode.
-V
Display detailed information at execution time
-W
Write to each block before reading the information from it
[Device]
Specifies the disk appliance to check.
[Last-block]
Specifies the total number of blocks for the disk appliance.
[Start-block]
Specify which block to start checking
Second, the example
Badblocks the result to the "hda-badblocks-list" file with a block of 4096, each block checking 16 times.
?
1 |
# badblocks-b 4096-c 16/dev/hda1-o hda-badblocks-list |
Hda-badblocks-list "is a text file that reads as follows:
Reference
# Cat Hda-badblocks-list
51249
51250
51251
51253
51254
......
61245
......
You can do several more operations on suspicious blocks. Below, badblocks to 4096 bytes for a "block", each "block" Check 1 times, the result output to the "Hda-badblocks-list.1" file, starting from No. 51000 block, to 63000 block end
?
1 |
# badblocks-b 4096-c 1/dev/hda1-o hda-badblocks-list.1 63000 51000 |
The time spent is relatively short, the hard drive in a given situation in a very short period of time to produce a "quack quack" sound. Because of the different check conditions, the results of their output are not exactly the same. Repeat the same operation several times, because the conditions are somewhat different, so the results are also different. After several operations, until the final hda-badblock-list.final file is generated.
Third, other
1, fsck use badblocks information
Badblocks will only mark bad information in the log file, but if you want to skip these bad blocks when detecting disks, you can use the-l parameter of fsck:
?
1 |
# fsck.ext3-l/TMP/HDA-BADBLOCK-LIST.FINAL/DEV/HDA1 |
2. Detect bad path before creating file system
Badblocks can be run with e2fsck and MKE2FS-C deletions (same as for ext3 file systems), detecting bad information before creating a filesystem:
?
The code represents using-C to check the hard drive of the bad path before creating the file system.
This operation has clearly informed us that we can use the "mkfs.ext3-c" option to check the hard drive in "read-only" mode. This command checks the hard drive when the hard drive is formatted and marks the wrong hard drive "block". It takes a lot of patience to format the hard drive in this way, because once the command runs, it checks the hard drive in a read way.