📅 2016-Dec-21 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ harddisk, smart, smartctl, smartmontools ⬩ 📚 Archive
smartctl is a commandline tool to view S.M.A.R.T. information of a storage device and to run SMART tests on it. This is the tool that is used by other GUI tools like GNOME Disks or GSmartControl.
Installing it is easy:
$ sudo apt install smartmontools
$ sudo smartctl --info /dev/sdb
$ sudo smartctl --info /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Seagate Momentus 5400.7
Device Model: ST9500320AS
Serial Number: 5WX2QYSE
LU WWN Device Id: 5 000c50 037f547bc
Firmware Version: 0002BSM2
User Capacity: 500,107,862,016 bytes [500 GB]
Sector Size: 512 bytes logical/physical
Rotation Rate: 5799 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS T13/1699-D revision 4
SATA Version is: SATA 2.6, 1.5 Gb/s
Local Time is: Sun Dec 25 18:29:28 2016 SGT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Note the last two lines. They indicate that this storage device has SMART support and that it is enabled.
If the above command cannot print any SMART information, then it means that the program could not guess the device type correctly. In such a cause you will need to try some of the possible device types (see the -d
option in manpage for this) and try each of them. For example, I could not view SMART info for a Toshiba Canvio USB 3.0 drive. But, I could view the SMART info when I used this command:
$ sudo smartctl -d sat --info /dev/sdb
If a certain device type works, then you must remember to use that option all the time for this disk.
I have come across drives where SMART is not turned on, so you may have to manually enable it.
This is what I see when I enable SMART:
$ sudo smartctl --smart=on /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
Once enabled, SMART should remain enabled through power-cycling. Use off
instead of on
to disable SMART. I cannot think of any reason why you would disable it cause keeping it enabled does not affect disk performance.
This is a test that SMART can perform every four hours to check for disk defects. Enabling this test can degrade disk performance and is obsoleted. Most recent disks will not enable this test even if you try to enable it. It is better to disable it in case it is enabled.
This is what I see when I disable it:
$ sudo smartctl --offlineauto=off /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Automatic Offline Testing Disabled.
You can query and view the capabilities of the storage device. This includes the self-tests that SMART of this device can perform and the estimated time they will take.
This is what I see when I view capabilities of my device:
$ sudo smartctl --capabilities /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
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: ( 0) seconds.
Offline data collection
capabilities: (0x73) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
No 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: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 148) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x103b) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
For example, note how this device is telling me that performing a short self-test is estimated to take 1 minute.
You can view the SMART attributes supported by the device and their values. With my device I get this output:
$ sudo smartctl --attributes /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 092 092 006 Pre-fail Always - 104646032
3 Spin_Up_Time 0x0003 097 093 000 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 100 100 020 Old_age Always - 621
5 Reallocated_Sector_Ct 0x0033 045 045 036 Pre-fail Always - 1128
7 Seek_Error_Rate 0x000f 062 060 030 Pre-fail Always - 1606206
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 319
10 Spin_Retry_Count 0x0013 100 099 097 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 020 Old_age Always - 393
184 End-to-End_Error 0x0032 100 100 099 Old_age Always - 0
187 Reported_Uncorrect 0x0032 001 001 000 Old_age Always - 445
188 Command_Timeout 0x0032 100 092 000 Old_age Always - 8590065680
189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 066 050 045 Old_age Always - 34 (Min/Max 25/34)
191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 257
193 Load_Cycle_Count 0x0032 098 098 000 Old_age Always - 5170
194 Temperature_Celsius 0x0022 034 050 000 Old_age Always - 34 (0 20 0 0 0)
195 Hardware_ECC_Recovered 0x001a 049 046 000 Old_age Always - 104646032
197 Current_Pending_Sector 0x0012 095 095 000 Old_age Always - 103
198 Offline_Uncorrectable 0x0010 095 095 000 Old_age Offline - 103
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
254 Free_Fall_Sensor 0x0032 100 100 000 Old_age Always - 0
This table shows a list of attributes that the SMART of this device supports. By looking at the values in the ID column, we can see that a particular device will only support a small subset of all the attributes defined in the SMART standard.
The attribute Type indicates whether the value of that attribute indicates imminent failure, like in next few hours (if it says Pre-fail) or indicates that the disk is getting old (if it says Old-age).
The Value is a normalized value that has been converted from the Raw Value by the device firmware. Devices do not necessarily have to provide these values in a way that make sense to normal users. What we can do is to compare the value to the Threshold value and come to a decision.
Threshold is a value in the range 0-255. The most confusing part is that the attribute is said to have failed if the normalized value is less than the threshold (and not greater than as I assumed)! I know it does not make any sense, but that is how it is defined.
I found that the attribute values cannot always indicate there is a problem with your disk. For example, the above values are seem normal, but this disk already has bad sectors and is failing. The best way to be sure is to run the SMART self-tests available in the device firmware. These tests are designed such that they can be performed even if the device is mounted and being used. You might notice some IO performance degradation while the test is running.
$ sudo smartctl --test=short /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== 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 1 minutes for test to complete.
Test will complete after Sun Dec 25 19:50:22 2016
Use smartctl -X to abort test.
The command returns immediately, because the self-test will be run by the device in the background.
Here is what I see on a good drive:
$ sudo smartctl --capabilities /dev/sda
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Here is what I see on a failing device:
$ sudo smartctl --capabilities /dev/sda
Self-test execution status: ( 121) The previous self-test completed having
the read element of the test failed.
$ sudo smartctl --log=selftest /dev/sdb
smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-47-generic] (local build)
Copyright (C) 2002-16, 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 Short offline Completed: read failure 90% 319 849336942
# 2 Short captive Completed: read failure 90% 319 849336942
# 3 Short offline Completed: read failure 90% 319 849336942
# 4 Short offline Completed: read failure 90% 319 849336942
# 5 Short offline Completed: read failure 90% 318 849336942
# 6 Short offline Completed: read failure 90% 318 849336942
# 7 Short offline Completed: read failure 90% 318 849336942
# 8 Conveyance offline Completed: read failure 90% 318 849336942
We can see that there are failures, indicating that the disk is already failing.
Tried with: smartmontools 6.4 and Ubuntu 16.04