Use a bad block tool on Linux to check the bad trackA bad block tool allows users to scan devices to check bad track or bad blocks. A device can be a disk or an external disk, represented by a file such as/dev/sdc. 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
Run the following command to check the Bad Sectors/blocks on your Linux Hard Disk:
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 output redirection is used to redirect the operation result to the badsectors.txt file.
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.
Run the e2fsck (for ext2/ext3/ext4 File System) or fsck command. The badsectors.txt file and the device file must also be used in the command.
-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 ChannelsThis method is more reliable and efficient for modern disks (ATA/SATA and SCSI/SAS hard disks and solid state disks) with the S. M.A. R. T system. 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
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.
From: http://www.centoscn.com/CentOS/Intermediate/2016/1119/8218.html
Address: http://www.linuxprobe.com/smartmontools-detect-harddisk.html