Installation of Smartmontools
The Smartmontools can be installed on Ubuntu using the package sources:
sudo apt-get install smartmontools
To ensure the hard disk supports SMART and is enabled, use the following command (in this example for the hard disk /dev/sdc):
sudo smartctl -i /dev/sdc
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.5.0-39-generic] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF INFORMATION SECTION === Model Family: Western Digital RE4 Serial ATA Device Model: WDC WD5003ABYX-01WERA1 Serial Number: WD-WMAYP5453158 LU WWN Device Id: 5 0014ee 00385d526 Firmware Version: 01.01S02 User Capacity: 500,107,862,016 bytes [500 GB] Sector Size: 512 bytes logical/physical Device is: In smartctl database [for details use: -P show] ATA Version is: 8 ATA Standard is: Exact ATA specification draft version not indicated Local Time is: Mon Sep 2 14:06:57 2013 CEST SMART support is: Available - device has SMART capability. SMART support is: Enabled
The last two lines are the most important as these indicate whether SMART support is available and enabled.
SMART offers two different tests, according to specification type, for and SCSI devices. Each of these tests can be performed in two modes:
- Foreground Mode
- Background Mode
In Background Mode the priority of the test is low, which means the normal instructions continue to be processed by the hard disk. If the hard drive is busy, the test is paused and then continues at a lower load speed, so there is no interruption of the operation.
In Foreground Mode all commands will be answered during the test with a “CHECK CONDITION” status. Therefore, this mode is only recommended when the hard disk is not used. In principle, the background mode is the preferred mode.
The goal of the short test is the rapid identification of a defective hard drive. Therefore, a maximum run time for the short test is 2 min. The test checks the disk by dividing it into three different segments. The following areas are tested:
- Electrical Properties: The controller tests its own electronics, and since this is specific to each manufacturer, it cannot be explained exactly what is being tested. It is conceivable, for example, to test the internal RAM, the read/write circuits or the head electronics.
- Mechanical Properties: The exact sequence of the servos and the positioning mechanism to be tested is also specific to each manufacturer.
- Read/Verify: It will read a certain area of the disk and verify certain data, the size and position of the region that is read is also specific to each manufacturer.
The long test was designed as the final test in production and is the same as the short test with two differences. The first: there is no time restriction and in the Read/Verify segment the entire disk is checked and not just a section. The Long test can, for example, be used to confirm the results of the short tests.
ATA specified Tests
All tests listed here are only available for ATA hard drives.
This test can be performed to determine damage during transport of the hard disk within just a few minutes.
During selected tests the specified range of LBAs is checked. The LBAs to be scanned are specified in the following formats:
sudo smartctl -t select,10-20 /dev/sdc #LBA 10 to LBA 20 (incl.) sudo smartctl -t select,10+11 /dev/sdc #LBA 10 to LBA 20 (incl.)
It is also possible to have multiple ranges, (up to 5), to scan:
sudo smartctl -t select,0-10 -t select,5-15 -t select,10-20 /dev/sdc
Test procedure with smartctl
Before performing a test, an approximate indication of the time duration of the various tests are displayed using the following command:
sudo smartctl -c /dev/sdc
[...] Short self-test routine recommended polling time: ( 2) minutes. Extended self-test routine recommended polling time: ( 83) minutes. Conveyance self-test routine recommended polling time: ( 5) minutes. [...]
The following command starts the desired test (in Background Mode):
sudo smartctl -t <short|long|conveyance|select> /dev/sdc
It is also possible to perform an “offline” test. However, only of the standard self test (Short Test) is performed.
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.5.0-39-generic] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 2 minutes for test to complete. Test will complete after Mon Sep 2 15:32:30 2013 Use smartctl -X to abort test.
To perform the tests in Foreground Mode a “-C” must be added to the command.
sudo smartctl -t <short|long|conveyance|select> -C /dev/sdc
Viewing the Test Results
In general, the test results are included in the output of the following commands:
sudo smartctl -a /dev/sdc
[...] SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Short offline Completed without error 00% 2089 - # 2 Extended offline Completed without error 00% 2087 - # 3 Short offline Completed without error 00% 2084 - 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. [...]
The following command can also be used, if only the test results should are displayed:
sudo smartctl -l selftest /dev/sdc
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.5.0-39-generic] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net === 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 Short offline Completed without error 00% 2089 - # 2 Extended offline Completed without error 00% 2087 - # 3 Short offline Completed without error 00% 2084 -