Detection and repair of Disk Bad Sectors in CentOS

Source: Internet
Author: User

Detection and repair of Disk Bad Sectors in CentOS
Using badblocks to detect bad sectors of a hard disk is a consumable device. When used for a period of time, physical faults such as bad sectors may occur. If a bad track occurs on the hard disk of a computer, if it is not replaced or processed in time, the number of bad tracks will increase and cause frequent crashes and data loss. The best solution is to change the disk, but in the case of temporary, block sectors of Bad Sectors in time, do not touch them. Badblocks is a tool for checking bad track locations. 1. Use the command parameter badblocks in the following format: reference badblocks [-svwnf] [-B block-size] [-c blocks_at_once] [-I input_file] [-o output_file] [-p num_passes] [-t test_pattern] device [the meaning of the last-block] [start-block] parameter is: reference-B blocksize specifies the disk block size, in bytes. The default value is "block 4 K" (4 K/block)-c blocksize. the number of times each block is checked, the default value is 16 times-f enforces read/write or non-destructive write tests on a mounted device (we recommend that you first umount the device and then perform bad track detection. This option can be used only when a device Mount error occurs in the/etc/mtab file.-I file skips the bad track that has been displayed in the file and does not detect it (repeated detection can be avoided) -o file outputs the detection result to the file-p number to repeatedly search for the device until no new bad block location is found within the specified number of passes, the default number of times is 0-S. During the check, the progress-t pattern is displayed to check the block 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 detects all blocks in the first mode, and then uses the next mode to detect all blocks. The Read-only method only accepts one mode. It cannot accept the random mode. -V displays detailed information during execution-w writes data to each block first, and then reads information from it [device] specifying the disk device to be checked. [Last-block] specifies the total number of blocks of the disk device. [Start-block] specifies the block from which to check. 2. The badblocks sample uses a block of 4096. Each block is checked 16 times, output the result to the "hda-badblocks-list" file. # badblocks-B 4096-c 16/dev/hda1-o hda-badblocks-listhda-badblocks-list "is a text. file, reference # cat hda-badblocks-list5124951250512515125351254 ...... 61245 ...... You can perform several operations on suspicious blocks. Below, badblocks takes 4096 bytes as a "block", each "block" is checked once, and the result is output to the "hda-badblocks-list.1" file, starting from the 51,000th block, by the end of the 63000 block # badblocks-B 4096-c 1/dev/hda1-o hda-badblocks-list.1 63000 51000 the time spent this time is relatively short, in a specified situation, the hard disk will generate a burst of noise in a very short time. Because of the different check conditions, the output results are not exactly the same. When you repeat the same operation several times, the results vary depending on the number of conditions. After multiple operations, until the final hda-badblock-list.final file is generated. Iii. Miscellaneous 1. fsck uses badblocks information. badblocks only marks bad track information in the log file. However, if you want to skip these bad blocks during disk detection, you can use the-l parameter of fsck: # fsck. ext3-l/tmp/hda-badblock-list.final/dev/hda12, detect Bad Sectors before creating a file system badblocks can run with e2fsck and mke2fs-c Delete (same for ext3 file systems ), check the bad track information before creating a file system: # mkfs. the ext3-c/dev/hda1 code indicates to use-c to check bad track hard disks before creating a file system. This operation clearly tells us that we can use the "mkfs. ext3-c" option to check the hard disk in the "read-only" mode. This command will check the hard disk when formatting the hard disk and mark the wrong hard disk "block ". It takes a lot of patience to format the hard disk using this method, because after the command is run, the hard disk will be checked one by one in Read mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.