In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
The purpose of this article is to share with you about the role of the badblocks instruction in CentOS. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
Command parameters
The format of badblocks is:
Quote
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 meaning of parameters is:
Quote
-b blocksize
Specifies the chunk size of the disk in bytes, with a default value of "block 4K" (4K/block)
-c blocksize
The number of checks per block. The default is 16.
-f
Force a read-write or non-destructive write test operation on a mounted device
We recommend that you umount the equipment first, and then do bad track detection. This option can be used only if / etc/mtab misreports a device mount error)
-I file
Skip the bad paths that are already displayed in the file file without detection (duplicate detection can be avoided)
-o file
Output the test results to a file file
-p number
The search device is repeated until no new bad block location is found within the specified number of passes. The default number is 0.
S
Show progress during inspection
-t pattern
Blocks are detected by reading and writing in the specified mode. You can specify a decimal positive value from 0 to ULONG_MAX-1, or use random (random).
If you specify multiple modes, badblocks will use the first mode to detect all blocks, and then use the next mode to detect all blocks.
The Read-only mode accepts only one mode, and it cannot accept the random mode.
-v
Display detailed information at execution time
-w
Write to each block and then read information from it
[device]
Specify the disk device to check.
[last-block]
Specifies the total number of blocks for the disk device.
[start-block]
Specify the block from which to start the check
2. Examples
Badblocks checks each block 16 times with a block of 4096, and outputs the results to the "hda-badblocks-list" file.
# badblocks- b 4096-c 16 / dev/hda1-o hda-badblocks-list
"hda-badblocks-list" is a text file with the following contents:
Quote
# cat hda-badblocks-list
51249
51250
51251
51253
51254
……
61245
……
You can do a few more operations on suspicious blocks. Next, badblocks takes 4096 bytes as a "block", checks each "block" once, and outputs the result to the "hda-badblocks-list.1" file, starting at 51000 block and ending at 63000 block.
# badblocks- b 4096-c 1 / dev/hda1-o hda-badblocks-list.1 63000 51000
This time it takes a short time, and the hard drive produces a "quack" sound in a very short time under specified circumstances. Due to the different inspection conditions, the output results are not exactly the same. Repeat the same operation several times, and the results are different because the conditions are somewhat different. After several operations, until the final hda-badblock-list.final file is generated.
III. Other
1. Information on fsck's use of badblocks
Badblocks will only mark bad information in the log file, but if you want to skip these bad blocks when detecting the disk, you can use the-l parameter of fsck:
# fsck.ext3-l / tmp/hda-badblock-list.final / dev/hda1
2. Detect bad channels before creating a file system
Badblocks can be run with the-c deletion of e2fsck and mke2fs (as well as for ext3 file systems) to detect bad information before creating a file system:
# mkfs.ext3-c / dev/hda1
The code indicates that you use-c to check for bad hard drives before creating a file system.
This operation has clearly told 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 formatting it and marks the wrong hard drive "block". It takes a lot of patience to format the hard drive in this way, because after the command is run, the hard drive will be checked one by one in a read way.
These are the functions of the badblocks instruction in CentOS. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.