Check the damaged sectors and blocks of the hard disk in linux.

Source: Internet
Author: User

Check the damaged sectors and blocks of the hard disk in linux.

BadblocksIs a command tool for linux and similar operating systems to scan and check hard disks and external devices for damaged sectors. The damaged sector or block is the space that is permanently damaged in the hard disk or cannot be read by the operating system.

The Badblocks command can detect all corrupted sectors or blocks in the hard disk and save the results in a text file. In this way, we can useE2fsckCommand to configure the operating system to not store data in these corrupt sectors.

Step: 1. Use the fdisk command to identify hard disk Information
 
 
  1. # sudo fdisk -l
Step 2. Scan the damaged sectors or blocks of the hard disk
 
 
  1. # sudo badblocks -v /dev/sdb > /tmp/bad-blocks.txt

Replace "/dev/sdb" with the hard disk/partition of your machine. After the preceding command is executed, a text file named "bad-blocks" will be created under/tmp, And it will contain all corrupted blocks.

For example:

Step 3: prompt the operating system not to use damaged Block Storage

After scanning, if the damaged block is discovered, the e2fsckcommand will be used to use “bad-blocks.txt, forcing the operating system not to use the damaged block to store data.

 
 
  1. # sudo e2fsck -l /tmp/bad-blocks.txt /dev/sdb

Note: before running the e2fsck command, ensure that the device is not mounted.

For more help on badblocks and e2fsck commands, refer to the following man page:

 
 
  1. # man badblocks
  2. # man e2fsck

Via: http://www.linuxtechi.com/check-hard-drive-for-bad-sector-linux/

Author: Pradeep Kumar Translator: Vic ___ Proofreader: Caroline

Http://linux.cn/article-3671-1.html.

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.