Detects bad and bad blocks on a hard drive on Linux

Source: Internet
Author: User

Linux detects bad and bad blocks on the hard drive

Let's start with the definition of bad and bad blocks, which are parts of a disk or flash memory that can no longer be read and written, typically due to specific physical damage on the disk surface or failure of the flash transistor.

There are three types of disk bad lanes:

0 Track bad path, bad logic, hard drive bad way.

The logical bad way can be repaired using the above method, the 0 track bad track repair method is to isolate 0 tracks, using the Fdsk partition area from the 1 tracks began to partition. If the hard drive is bad, it can only be isolated and cannot be repaired. Hard drive Bad Channel monitoring method: Using the above method to detect the repair, and then use badblocks-s-v-o/ROOT/BADBLOCKS.LOG/DEV/SDA monitoring to see if there is still a bad path, if the bad word or exist, it means bad road belongs to the hard drive bad. Hard drive Bad Channel isolation method, first record the detected hard drive bad channel, and then partition the hard drive when the bad path is located in a partition (the size is generally greater than the bad sector size), divided the bad channel partition is not used to achieve the purpose of isolation. Isolation is only a temporary solution, it is recommended to replace the hard disk as soon as possible, because the bad channel will spread to avoid serious data problems later.

As the disk's bad path continues to accumulate, it can have a devastating effect on your disk or flash capacity, and may even cause the hard drive to fail.

It is also important to note the presence of bad blocks. You should consider replacing the new disk or marking the bad block as unusable.

So, with a few small steps, we use specific disk scanning tools to let you know if a Linux disk or flash memory has a bad path.

The procedure is as follows:

Use bad block tools on Linux to check for bad lanes

The so-called bad block tool is the ability to allow users to scan the device to check for bad or bad blocks. The device can be a disk or an external disk, represented by a file such as/dev/sdb.

The Power user executes the FDISK command to display your disk information, their partition information, and so on:

Fdisk–l

Detecting bad/bad blocks on a Linux hard drive:

Badblocks–v [which partition of the disk] > Badsectors.txt

For example: I detected my/dev/sda1 partition, the command is as follows:

Badblocks–v/dev/sda1


Scan hard drive bad path on Linux

Ps:badblocks Scan Device/DEV/SDA (don't forget to specify your actual device), the-V option displays the details of the operation. If you use redirect >, the result is redirected to a specified file.

If any bad lanes are found, unmount the disk as follows to let the system do not write data to disk.

You can use the e2fsck or FSCK command (for the Ext2/ext3/ext4 file system), and you need to use Badsectors.txt files and device files in the command.

The-l option tells the command to add a bad block list to the sector numbers listed in the specified file Badsectors.txt.

The command is as follows:

E2fsck–l badsectors.txt/dev/sda1 or Fsck–l badsectors.txt/dev/sda1

You can also use the Scan bad DAO tool----Smartmontools tool on Linux

Modern disks with s.m.a.r.t (self-monitoring Analysis reporting technology) systems are more reliable and efficient. Be able to help detect, report, and record their health status.

Use SMARTCTL to control disk-integrated S.M.A.R.T systems using the Smartmontools required to install and after installation is complete.

You can use the Smartctl–h help command.

The command parameter-H or-health displays the smart overall health self-assessment test results.

The-A or-all option displays smart information about the disk, and-X or-xall displays all smart information about the disk and non-smart information.



This article from "Lu Chunning" blog, declined reprint!

Detects bad and bad blocks on a hard drive on Linux

Related Article

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.