Smartmontools is a suite of utilities designed for monitoring and managing the health and performance of storage devices, primarily hard disk drives (HDDs), solid-state drives (SSDs) and NVMe. It enables users to regularly check drive health, display detailed SMART attributes, run diagnostic tests, log SMART data and events, receive alerts for potential failures, integrate with monitoring systems, retrieve drive information, and conduct advanced diagnostics. By providing proactive monitoring and analysis capabilities, smartmontools help users anticipate and prevent storage device failures, ensuring the reliability and longevity of their storage infrastructure.
Without getting into more detailed information, let’s use it!
Installation
Installation of Smartctl in Ubuntu
sudo apt-get install smartmontools
Installation of Smartctl in Redhat / CentOS
sudo dnf install smartmontools
Start the Smartctl Service
For Ubuntu
sudo /etc/init.d/smartmontools start
For CentOS & RHEL
systemctl start smartd; chkconfig smartd on
Example 1: Check Whether Smart Capability is enabled or not for the disk
[root@box944 ~]# smartctl -i /dev/sda
[OUTPUT]
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-477.13.1.el8_8.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Crucial/Micron BX/MX1/2/3/500, M5/600, 1100 SSDs
Device Model: Micron_M600_MTFDDAK1T0MBF
Serial Number: 15070ED1211C
LU WWN Device Id: 5 00a075 10ed1211c
Firmware Version: MU03
User Capacity: 1,024,209,543,168 bytes [1.02 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-3 T13/2161-D revision 4
SATA Version is: SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Mon May 13 03:23:27 2024 EDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Where ‘/dev/sda’ is your hard disk. The last two lines in the above output show that SMART capability is enabled for the device.
Example 2: Enable Smart Capability for the disk.
[root@nohost ~]# smartctl -s on /dev/sda
[OUTPUT]
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-477.13.1.el8_8.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
Example 3: Disable Smart Capability for the disk.
[root@nohost ~]# smartctl -s on /dev/sda
[OUTPUT]
smartctl 7.1 2019-12-30 r5022 [x86_64-linux-4.18.0-477.13.1.el8_8.x86_64] (local build)
Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Disabled. Use option -s with argument 'on' to enable it.
Example 4: Display Detailed Smart info for the disk.
[root@nohost ~]# smartctl -a /dev/sdb // For IDE drive
[root@nohost ~]# smartctl -a -d ata /dev/sdb // For IDE drive
Example 5: Display Overall health of the Disk
[root@nohost ~]# sudo smartctl -H /dev/sda
[OUTPUT]
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-4.18.0-477.13.1.el8_8.x86_64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Health Status: OK
Example 6: Test Hard drive using long & short option.
Long Test
[root@nohost ~]# smartctl --test=long /dev/sda
[OUTPUT]
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-4.18.0-477.13.1.el8_8.x86_64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 13 minutes for test to complete.
Test will complete after Mon May 13 03:48:25 2024
Use smartctl -X to abort test.
OR We can redirect test output to a log file, as shown below.
[root@nohost ~]# smartctl --test=long /dev/sdb > /var/log/long.text
Short Test
[root@nohost ~]# smartctl --test=short /dev/sda
[OUTPUT]
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-4.18.0-477.13.1.el8_8.x86_64] (local build)
Copyright (C) 2002-20, 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 Nov 16 12:51:45 2014
Use smartctl -X to abort test.
OR
[root@nohost ~]# smartctl --test=short /dev/sda > /var/log/short.text
Note: Short tests will take maximum 2 minutes whereas in long tests there is no time restriction because it reads & verifies every segment of the entire disk.
Example 7: To View Drive’s Self Test result
[root@nohost ~]# smartctl -l selftest /dev/sda
[OUTPUT]
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-4.18.0-477.13.1.el8_8.x86_64] (local build)
Copyright (C) 2002-20, 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 without error 00% 1099 -
# 2 Extended offline Completed without error 00% 1099 -
Example 8: Calculate Estimate time to perform test
[root@nohost ~]# smartctl -c /dev/sda
[OUTPUT]
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1160.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
General SMART Values:
Offline data collection status: (0x80) Offline data collection activity
was never started.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 249) Self-test routine in progress...
90% of test remaining.
Total time to complete Offline
data collection: ( 1492) 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: ( 8) minutes.
Conveyance self-test routine
recommended polling time: ( 3) minutes.
SCT capabilities: (0x0035) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.
Example 9: Display Error logs of the disk
[root@nohost ~]# smartctl -l error /dev/sda
[OUTPUT]
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1160.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF READ SMART DATA SECTION ===
SMART Error Log Version: 1
No Errors Logged
Example 10: In case if you are using RAID, append the following to your command.
[root@nohost ~]# smartctl -i /dev/sda -d megaraid,0
// Append "-d megaraid,N" to your command. Where N is number of your drive you want to perform your test on.
Example 11: Get all information at once. This is the super command to get all information you get by running all the above commands at once.
[root@nohost ~]# smartctl --all -d megaraid,0 /dev/sda
[OUTPUT]
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1160.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Crucial/Micron BX/MX1/2/3/500, M5/600, 1100 SSDs
Device Model: Micron_M600_MTFDDAK1T0MBF
Serial Number: 15070ED1211C
LU WWN Device Id: 5 00a075 10ed1211c
Firmware Version: MU03
User Capacity: 1,024,209,543,168 bytes [1.02 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-3 T13/2161-D revision 4
SATA Version is: SATA 3.2, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Mon May 13 04:04:46 2024 EDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART Status not supported: ATA return descriptor not supported by controller firmware
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.
General SMART Values:
Offline data collection status: (0x80) Offline data collection activity
was never started.
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: ( 1496) 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: ( 8) minutes.
Conveyance self-test routine
recommended polling time: ( 3) minutes.
SCT capabilities: (0x0035) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.
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 0x002f 100 100 000 Pre-fail Always - 0
5 Reallocate_NAND_Blk_Cnt 0x0032 100 100 010 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 1100
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 12
171 Program_Fail_Count 0x0032 100 100 000 Old_age Always - 0
172 Erase_Fail_Count 0x0032 100 100 000 Old_age Always - 0
173 Ave_Block-Erase_Count 0x0032 100 100 000 Old_age Always - 0
174 Unexpect_Power_Loss_Ct 0x0032 100 100 000 Old_age Always - 12
180 Unused_Reserve_NAND_Blk 0x0033 000 000 000 Pre-fail Always - 7527
183 SATA_Interfac_Downshift 0x0032 100 100 000 Old_age Always - 0
184 Error_Correction_Count 0x0032 100 100 000 Old_age Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
194 Temperature_Celsius 0x0022 079 073 000 Old_age Always - 21 (Min/Max 16/27)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 100 100 000 Old_age Always - 0
202 Percent_Lifetime_Remain 0x0030 100 100 001 Old_age Offline - 0
206 Write_Error_Rate 0x000e 100 100 000 Old_age Always - 0
210 Success_RAIN_Recov_Cnt 0x0032 100 100 000 Old_age Always - 0
246 Total_Host_Sector_Write 0x0032 100 100 000 Old_age Always - 46502448
247 Host_Program_Page_Count 0x0032 100 100 000 Old_age Always - 1535108
248 FTL_Program_Page_Count 0x0032 100 100 000 Old_age Always - 13372808
SMART Error Log Version: 1
No Errors Logged
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% 1100 -
# 2 Short offline Completed without error 00% 1100 -
# 3 Short offline Completed without error 00% 1099 -
# 4 Extended offline Completed without error 00% 1099 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Completed [00% left] (500102316-500167851)
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.
Other than the above-mentioned commands you can use any other set or combinations of commands to get details and test health of your attached drives. For details about all the commands, can be found by running smartctl -h or smartctl --help
within your terminal.
If you seem that the SMARTCTL is complicated for you to understand and need to know about your drives with an easy understandable manner. You can check out our post about HDSentinel Tools. For other details and drive-related assistance, contact our team at BigBoxHost website.