How to detect bad and bad blocks on a hard disk in Linux

Source: Internet
Author: User
Tags superuser permission

How to detect bad and bad blocks on a hard disk in Linux
The introduction begins 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.

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.

The procedure is as follows: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/sdc

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

$ sudo fdisk -l<br>

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

$ sudo badblocks -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), and the-v option displays the operation details. In addition, the operation result is redirected to the badsectors.txt file using the output direction.

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 execute e2fsck (for ext2/ext3/ext4 file system commands or fsckcommand, the command also uses the badsectors.txt file and the device file.

-L indicates that the command adds the slice number listed in the specified badsectors.txt file to the bad block list.

------------ For ext2/ext3/ext4 File System ------------ $ sudo e2fsck-l kernel/dev/sda10 or ---------- for other file systems ------------ $ sudo fsck-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.
Run the following command to install smartmontools:

------------ On Debian/Ubuntu-based systems ------------ $ sudo apt-get install smartmontools ---------- on RHEL/CentOS-based systems ---------- $ sudo yum install smartmontools

After the installation is complete, use smartctl to control the disk-integrated S. M.A. R. T system. You can view its manual or help as follows:

$ man smartctl$ smartctl -h

Then run the smartctrl command and specify your device as the parameter in the command. The following command contains the parameter-H or -- health to display the SMART overall health self-evaluation test result.

$ sudo smartctl -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 the-a or -- all option to display all SMART information about the disk,-x or -- xall to display all SMART information about the disk and non-SMART information.

In this tutorial, we will discuss important topics about disk health diagnostics and hope to help you.

From: https://linux.cn/article-7961-1.html

Address: http://www.linuxprobe.com/check-linux-disk.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.