S.M.A.R.T.

Self-Monitoring, Analysis and Reporting Technology System (S.M.A.R.T.)
Linux uses SmartMonTools to access the SMART 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/sda as the first internal hard disk drive, and /dev/sdb as the external usb drive.

Scan For Devices
smartctl --scan

Device Driver
smartctl --device=test /dev/sda /dev/sda: Device of type 'scsi' [SCSI] detected /dev/sda [SAT]: Device open changed type from 'scsi' to 'sat' /dev/sda [SAT]: Device of type 'sat' [ATA] opened

So, we use the sat driver for this device.

Turn SMART Feature ON
smartctl --device=sat --smart=on /dev/sda

Information
smartctl --device=sat --all /dev/sda

Health Check
smartctl --device=sat --health /dev/sda

Tests - Internal Drives
Self-Test: Short (internal SATA)

smartctl --device=sat --test=short /dev/sda

Self-Test: Medium (internal SATA)

smartctl --device=sat --test=conveyance /dev/sda

Self-Test: Long (internal SATA)

smartctl --device=sat --test=long /dev/sda

Tests - USB External Drives
Self-Test: Short

smartctl --device=sat,16 --test=short /dev/sdb

Self-Test: Medium

smartctl --device=sat,16 --test=conveyance /dev/sdb

Self-Test: Long

smartctl --device=sat,16 --test=long /dev/sdb

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

Tests Stop
smartctl --device=sat --abort /dev/sda

Show Test Logs
Terminal:~$ 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 === 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) 1  Extended offline    Completed without error       00%     62071         -
 * 2) 2  Short offline       Completed without error       00%     57922         -
 * 3) 3  Short offline       Completed without error       00%     51265         -

Show Hard Drive Details and Test Logs
Terminal:~$ 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) 1  Extended offline    Completed without error       00%     62071         -
 * 2) 2  Short offline       Completed without error       00%     57922         -
 * 3) 3  Short offline       Completed without error       00%     51265         -

Daily, Weekly, Monthly Checks In CRON
@daily /usr/sbin/smartctl --device=sat --all /dev/sda && /usr/sbin/smartctl --device=sat --all /dev/sdb && /usr/sbin/smartctl --device=sat --all /dev/sdc @weekly /usr/sbin/smartctl --device=sat --test=short /dev/sda && /usr/sbin/smartctl --device=sat --test=short /dev/sdb && /usr/sbin/smartctl --device=sat --test=short /dev/sdc @monthly /usr/sbin/smartctl --device=sat --test=long /dev/sda && /usr/sbin/smartctl --device=sat --test=long /dev/sdb && /usr/sbin/smartctl --device=sat --test=long /dev/sdc
 * 1) hard disk drive checks

How To Stop A Hard Disk Drive From Power Management Sleep During SMART Tests
while true; do dd if=/dev/sdX iflag=direct count=1 of=/dev/null; sleep 60s; done