This is a very reliable and efficient way when scanning for bad sectors in Linux. Most modern hard drives and solid state drives whip with S.M.A.R.T. This software helps to detect, report, and log the health status of the drive. Which helps users and admins predict and prevent hardware failures.
$ sudo apt-get install smartmontools
$ sudo yum install smartmontools.
Once installed, run the following command to see if your drive supports SMART.
$ sudo smartctl -i /dev/sda1
If your drive supports it use this command to verify that it is enabled. Keep in mind that if SMART was already enabled, it will do nothing.
$ sudo smartctl -s on /dev/sda1
To get complete information on IDE or SATA drive information, type the following commands.
$ sudo smartctl -a /dev/sda1 ( for IDE drives)
$ sudo smartctl -a -d ata /dev/sda1
Now, for checking the drives themselves and testing. Using -H will show you the health status of the drive. If it’s bad, backup everything! Using -c will show you how long each test will take.
$ sudo smartctl -H /dev/sda1
$sudo smartctl -c /dev/sda1
Finally, the testing part. There are three different test, short, extended (long) and conveyance.
$ sudo smartctl -t long /dev/sda1
$ sudo smartctl -short /dev/sda1
$ sudo smartctl -conveyance /dev/sda1
After running the test, check the results with the following command and options
$ sudo smartctl -l selftest /dev/sda1