Detect bad and bad blocks on the hard disk on CentOS

Source: Internet
Author: User

Detect bad and bad blocks on the hard disk on CentOS

Let's start with the definition of bad and bad blocks. They are part of a disk or flash memory that can no longer be read or written, it is generally caused by physical damage to the disk surface or flash transistor failure.

As Bad channels continue to accumulate, they will have an unpleasant or destructive impact on your disk or flash capacity, and may even cause hardware failure.

At the same time, it should be noted that the existence of Bad blocks warns you should begin to consider buying new disks, or simply mark the Bad blocks as unavailable.

Therefore, in this article, we take several necessary steps to use a specific disk scan tool to determine whether a Linux disk or flash memory has a bad track.

Follow these steps:

Use a bad block tool on Linux to check the bad track

The bad block tool allows the user to scan the device to check the bad track or bad block. A device can be a disk or an external disk/dev/sdcThis file represents.

First, run the fdisk command with the superuser permission to display all your disk or flash memory information and their partition information:

sudofdisk-l

List Linux File System partitions

Run the following command to check the Bad Sectors/blocks on your Linux Hard Disk:

 
  1. sudobadblocks-v/dev/sda10>badsectors.txt

Scan Hard Disk Bad Sectors in Linux

In the above command, badblocks scans the device/dev/sda10(Remember to specify your actual device ),-vOption to display the operation details. In addition, the output redirection is used to redirect the operation result to the file.badsectors.txt.

If you find any bad sectors on your disk, detach the disk and prevent the system from writing data to the sector in return as follows.

You need to executee2fsck(For ext2/ext3/ext4 file systems) orfsckCommand.badsectors.txtFile and device file.

-lIndicates that the command will be in the specified filebadsectors.txtAdd the sector numbers listed in to the bad block list.

 
  1. ------------ For the forext2/ext3/ext4 File System ------------
  2. $sudoe2fsck-l badsectors.txt/dev/sda10
  3. Or
  4. ------------ For other file systems ------------
  5. $sudofsck-l badsectors.txt/dev/sda10
Use the Smartmontools tool on Linux to scan bad Channels

This method is applicable (Self-monitoring and analysis report TechnologySelf-Monitoring, Analysis and Reporting Technology) The system's modern disks (ATA/SATA and SCSI/SAS hard disks and solid state disks) are more reliable and efficient. The S. M.A. R. T system can help detect, report, and possibly record their health status so that you can identify any possible hardware failures.

You can use the following command to installsmartmontools:

 
  1. ------------ On Debian/Ubuntu-based systems ------------
  2. $sudoapt-getinstall smartmontools
  3. ------------ On RHEL/CentOS-based systems ------------
  4. $sudoyuminstall smartmontools

After the installation is complete, usesmartctlControls the S. M.A. R. T System of disk integration. You can view its manual or help as follows:

 
  1. $mansmartctl
  2. $ smartctl-h

Then executesmartctrlCommand and specify your device as the parameter in the command. The following command contains the Parameter-HOr--healthTo display the SMART overall health self-assessment test results.

 
  1. $sudosmartctl-H/dev/sda10

Check Linux Hard Drive Health

The above results indicate that your hard disk is healthy and hardware failure is unlikely to happen in the near future.

To obtain the disk information overview, use-aOr--allOption to display all SMART information about the disk,-xOr--xallTo display all SMART information about disks and non-SMART information.

In this tutorial, we will discuss important topics about disk health diagnostics. You can share your thoughts or questions in the following feedback area, and remember to come back later.

Via: http://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/

Author: Aaron Kili Translator: alim0x Proofreader: wxy this article was originally compiled by LCTT and launched with the honor of Linux in China

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.