Smartmontools
Also see badblocks and Smartmontools badblock howto
Basic Commands
Short Selftest
smartctl -t short /dev/sdb
Long Selftest
smartctl -t long /dev/sda
List Selftest results
smartctl -l selftest /dev/sda
Show smart data
smartctl -A /dev/sda
Results interpretation
The parameters of particular interest are Reallocated_Sector_Ct (ID #5), Reallocated_Event_Count (#196), Current_Pending_Sector (#197), and Offline_Uncorrectable (#198).
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 100 100 051 Pre-fail Always - 27
2 Throughput_Performance 0x0026 056 056 000 Old_age Always - 11945
3 Spin_Up_Time 0x0023 089 079 025 Pre-fail Always - 3453
4 Start_Stop_Count 0x0032 099 099 000 Old_age Always - 1706
5 Reallocated_Sector_Ct 0x0033 252 252 010 Pre-fail Always - 0
7 Seek_Error_Rate 0x002e 252 252 051 Old_age Always - 0
8 Seek_Time_Performance 0x0024 252 252 015 Old_age Offline - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 3185
10 Spin_Retry_Count 0x0032 252 252 051 Old_age Always - 0
12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 1145
191 G-Sense_Error_Rate 0x0022 100 100 000 Old_age Always - 53
192 Power-Off_Retract_Count 0x0022 252 252 000 Old_age Always - 0
194 Temperature_Celsius 0x0002 064 056 000 Old_age Always - 36 (Min/Max 11/44)
195 Hardware_ECC_Recovered 0x003a 100 100 000 Old_age Always - 0
196 Reallocated_Event_Count 0x0032 252 252 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 252 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 252 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0036 100 100 000 Old_age Always - 1
200 Multi_Zone_Error_Rate 0x002a 100 100 000 Old_age Always - 10142
223 Load_Retry_Count 0x0032 100 100 000 Old_age Always - 41
225 Load_Cycle_Count 0x0032 083 083 000 Old_age Always - 175187
Find number of bad sectors
dd if=/dev/sda of=/dev/null bs=64k conv=noerror