How do I know if my hard drive is failing?
apt-get install smartmontools
smartctl controls the Self-Monitoring, Analysis and Reporting Technology (SMART) system built into many ATA-3 and later ATA, IDE and SCSI-3 hard drives. The purpose of SMART is to monitor the reliability of the hard drive and predict drive failures, and to carry out different types of drive self-tests. smartctl is a command line utility designed to perform SMART tasks such as printing the SMART self-test and error logs, enabling and disabling SMART automatic testing, and initiating device self-tests. Make sure S.M.A.R.T. support is enabled in the BIOS. The next step is to make sure that smart is enabled on your disks.
smartctl -i /dev/sdb
If it’s disabled, you can enable it like this.
smartctl -s on -d ata /dev/sdb
smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF ENABLE/DISABLE COMMANDS SECTION === SMART Enabled.
Test Disk Health
smartctl -d ata -H /dev/sdb
smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED
You can get more information like this.
smartctl -d ata -a /dev/sdb
smartctl version 5.37 [i686-pc-linux-gnu] Copyright (C) 2002-6 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF INFORMATION SECTION === Model Family: Western Digital Caviar SE16 family Device Model: WDC WD4000KD-00NAB0 Serial Number: WD-WMAMY1036416 Firmware Version: 01.06A01 User Capacity: 400,088,457,216 bytes Device is: In smartctl database [for details use: -P show] ATA Version is: 7 ATA Standard is: ATA/ATAPI-7 published, ANSI INCITS 397-2005 Local Time is: Fri Jan 4 08:56:57 2008 EST SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED General SMART Values: Offline data collection status: (0x82) Offline data collection activity was completed without error. Auto Offline Data Collection: Enabled. Self-test execution status: ( 0) The previous self-test routine completed without error or no self-test has ever been run. Total time to complete Offline data collection: (10530) seconds. Offline data collection capabilities: (0x7b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. Conveyance Self-test supported. Selective Self-test supported. SMART capabilities: (0x0003)Saves SMART data before entering power-saving mode. Supports SMART auto save timer. Error logging capability: (0x01)Error logging supported. General Purpose Logging supported. Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 152) minutes. Conveyance self-test routine recommended polling time: ( 5) minutes. 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 0x000b 200 200 051 Pre-fail Always - 0 3 Spin_Up_Time 0x0007 233 220 021 Pre-fail Always - 5366 4 Start_Stop_Count 0x0032 100 100 040 Old_age Always - 229 5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0 7 Seek_Error_Rate 0x000b 200 200 051 Pre-fail Always - 0 9 Power_On_Hours 0x0032 084 084 000 Old_age Always - 11968 10 Spin_Retry_Count 0x0013 100 062 051 Pre-fail Always - 0 11 Calibration_Retry_Count 0x0013 100 100 051 Pre-fail Always - 0 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 225 194 Temperature_Celsius 0x0022 122 100 000 Old_age Always - 30 196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0 197 Current_Pending_Sector 0x0012 200 200 000 Old_age Always - 0 198 Offline_Uncorrectable 0x0012 200 200 000 Old_age Always - 0 199 UDMA_CRC_Error_Count 0x000a 200 253 000 Old_age Always - 0 200 Multi_Zone_Error_Rate 0x0009 200 200 051 Pre-fail Offline - 0 SMART Error Log Version: 1 No Errors Logged SMART Self-test log structure revision number 1 No self-tests have been logged. [To run self-tests, use: smartctl -t] SMART Selective self-test log data structure revision number 1 SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS 1 0 0 Not_testing 2 0 0 Not_testing 3 0 0 Not_testing 4 0 0 Not_testing 5 0 0 Not_testing Selective self-test flags (0x0): After scanning selected spans, do NOT read-scan remainder of disk. If Selective self-test is pending on power-up, resume after 0 minute delay.
You need to begin an extended self-test of drive /dev/sdb. You can issue this command on a running system. The results can be seen in the self-test log visible with the ´-l selftest´ option after it has completed.
smartctl -d ata -t long /dev/sdb
Now, to get this setup properly. First, you need to config the /etc/smartd.conf file for this to work properly.
This is an example file.
# schedule all tests (Offline, Extended and Conveyance tests) to be launched # every Thursday from 00:00 to 4:00, in succession /dev/sda -H -s (O/../../4/00|L/../../4/02|C/../../4/04) -d sat -m email@example.com /dev/sdb -H -s (O/../../4/00|L/../../4/02|C/../../4/04) -d sat -m firstname.lastname@example.org /dev/sdc -H -s (O/../../4/00|L/../../4/02|C/../../4/04) -d sat -m email@example.com /dev/sdd -H -s (O/../../4/00|L/../../4/02|C/../../4/04) -d sat -m firstname.lastname@example.org /dev/sde -H -s (O/../../4/00|L/../../4/02|C/../../4/04) -d sat -m email@example.com
This will run an Offline, Extended, and Conveyance tests in series on each of my hard drives Thursday mornings. If any errors occur, it will email me. Next you need to edit /etc/default/smartmontools.
And uncomment this line.
Finally, restart Smartmontools
If you get any error messages, check the logs
tail -n 100 /var/log/syslog