S.M.A.R.T.
From Indie IT Wiki
Self-Monitoring, Analysis and Reporting Technology System (S.M.A.R.T.)
SmartMonTools is used to access the a hard drives S.M.A.R.T. information.
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-3.3.8-gentoo] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net
The examples below use /dev/sdX as the first internal hard disk drive, and /dev/sdY as the external USB drive.
All the commands listed are good for both Linux and Windows unless otherwise stated.
HOWTO: INSTALL
Windows
Download and install the .exe file.
Linux
sudo aptitude install smartmontools
HOWTO:
Scan For Devices
sudo smartctl --scan
Scan For Devices And Try To Open Each Device
sudo smartctl --scan-open
Device Driver
sudo smartctl --device=test /dev/sdX /dev/sdX: Device of type 'scsi' [SCSI] detected /dev/sdX [SAT]: Device open changed type from 'scsi' to 'sat' /dev/sdX [SAT]: Device of type 'sat' [ATA] opened
So, we use the sat driver for this device.
Enable SMART Feature
sudo smartctl --device=sat --smart=on /dev/sdX
Information
sudo smartctl --device=sat --all /dev/sdX
Health Check
sudo smartctl --device=sat --health /dev/sdX
Tests - Internal Drives
Self-Test: Short (internal SATA)
sudo smartctl --device=sat --test=short /dev/sdX
Self-Test: Medium (internal SATA)
sudo smartctl --device=sat --test=conveyance /dev/sdX
Self-Test: Long (internal SATA)
sudo smartctl --device=sat --test=long /dev/sdX
Tests - USB External Drives
Self-Test: Short
sudo smartctl --device=sat,16 --test=short /dev/sdY
Self-Test: Medium
sudo smartctl --device=sat,16 --test=conveyance /dev/sdY
Self-Test: Long
sudo smartctl --device=sat,16 --test=long /dev/sdY
The last long test on an external USB drive may need to be combined with this series of commands to stop the kernel from sleeping the drive:-
while true; do dd if=/dev/sdX iflag=direct count=1 of=/dev/null; sleep 60s; done
Stop Running Tests
sudo smartctl --device=sat --abort /dev/sdX
Display Test Logs
sudo smartctl --device=sat --log=selftest /dev/sdX The output should look like the following: smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.16.0-31-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Extended offline Completed without error 00% 62071 - # 2 Short offline Completed without error 00% 57922 - # 3 Short offline Completed without error 00% 51265 -
Display Hard Drive Details and Test Logs
sudo smartctl -i --device=sat --log=selftest /dev/sdX The output should look like the following: smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-38-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Western Digital Caviar SE Serial ATA Device Model: WDC WD800JD-60JRA0 Serial Number: WD-WMAMD2064823 Firmware Version: 05.01C05 User Capacity: 80,026,361,856 bytes [80.0 GB] Sector Size: 512 bytes logical/physical Device is: In smartctl database [for details use: -P show] ATA Version is: ATA/ATAPI-7 (minor revision not indicated) Local Time is: Tue Oct 14 13:06:35 2014 BST SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Extended offline Completed without error 00% 62071 - # 2 Short offline Completed without error 00% 57922 - # 3 Short offline Completed without error 00% 51265 -
Daily, Weekly, Monthly Checks In CRON (Linux)
# hard disk drive checks @daily /usr/sbin/smartctl --device=sat --all /dev/sdX && /usr/sbin/smartctl --device=sat --all /dev/sdY && /usr/sbin/smartctl --device=sat --all /dev/sdc @weekly /usr/sbin/smartctl --device=sat --test=short /dev/sdX && /usr/sbin/smartctl --device=sat --test=short /dev/sdY && /usr/sbin/smartctl --device=sat --test=short /dev/sdc @monthly /usr/sbin/smartctl --device=sat --test=long /dev/sdX && /usr/sbin/smartctl --device=sat --test=long /dev/sdY && /usr/sbin/smartctl --device=sat --test=long /dev/sdc
Prevent Power Management Sleep During SMART Tests
while true; do dd if=/dev/sdX iflag=direct count=1 of=/dev/null; sleep 60s; done
Thanks to SourceForge.