UN*X: How to check disks health using smart on Linux, Mac and BSD


In this article we have a look at how to check disks health status using SMART and smartctl on Linux OS (RHEL, CentOS, PacketLinux and Debian/Ubuntu/KALI based distros), macOS and BSD systems.

Usual disclaimer: First off this article is not a full User Guide about SMART utilities nor it pretend to be. Also please note that SMART and SMART utilities cannot guarantee 100% of accuracy in their reports for the actual health status of disks, so do not rely on them only when determining the health status of  your disks. Last, but not least, a good redundant backup solution is always the best approach to preserve your data!

What is SMART?

SMART or Self-Monitoring, Analysis and Reporting Technology is a monitoring system included in most computer hard disk drives (HDDs) and solid-state drives (SSDs) that detects and reports on various indicators of drive reliability, with the intent of enabling the anticipation of hardware failures. (more info here).

How can I use it to check the health status of my disks?

To use and/or query SMART monitoring system we need to install smart utilities on our Linux System:

On RHEL, CentOS, Fedora, PacketLinux and Scientific Linux

To use it only via command line:

$ sudo yum install smarttools -y

OR to use it also via Gnome GUI:

$ sudo yum install smarttools gsmartcontrols -y

On Debian, Ubuntu, KALI, PrometheOS and other debian based distros

To use it only via command line:

$ sudo apt-get install smarttools -y

OR to use it via command lien and Gnome GUI:

$ sudo apt-get install smarttools gsmartcontrols -y

On Apple Mac, BSD and other systems

Please check the F.A.Q. section at the end of this article, it describes how to install smart tools on other systems like macOS, BSD etc.

Once you completed the installation of S.M.A.R.T tools on your system you are ready for the next steps of this how-to.

How to check if my HDD/SSD support SMART:

First of all let’s check if your disk supports SMART. Not all HDD/SSD/Controllers support SMART, so you should check this first ALWAYS.

In the example below I use sda (which, in theory should be present on most systems, but, before blindly copy and past, make sure you know which disks your system has got. If you are not familiar with Linux then please read first my articles on how to explore a Linux System).

$ sudo smartctl -i /dev/sda

The output of this command should look like:

smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.13.0-9.1-prometheos-amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model: ST2000LX001-1RG174
Serial Number: AAAAAAAA
LU WWN Device Id: n nnnnnn nnnnnn
Firmware Version: SDM1
User Capacity: 2,000,398,934,016 bytes [2.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-3 T13/2161-D revision 5b
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Tue Oct 24 18:10:49 2017 BST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

What we need to look up first is the field SMART support is: [Available], because if this field reports Not Available, then it means your disk has no SMART support and so you won’t be able to continue following this how-to, nor check your disk health status using SMART.

How to enable/disable SMART support on a disk

If your disk offers SMART support (and it’s not enabled) you can enable it using the following command:

$ sudo smartctl -s on /dev/sda

Or in the more extended form:

$ smartctl --smart=on --offlineauto=on --saveauto=on /dev/sda

The second syntax is more complete and tell smartctl also to enable the offline auto test (this parameter is for ATA only disks!) which will run a selftest scan every 4 hours to check for disk defects. Please note that offlineauto may not be implemented on all drives that support SMART. The saveauto=on tells smartctl to also enable SMART autosave of device vendor-specific Attributes.

How can I display all SMART info about my disk?

Well, if you made it that far with this how-to procedure without errors then it’s time to display all SMART info about your disk, to do that simply use:

$ sudo smartctl -a /dev/sda

The output of this command can be quite big and full of informations, however they all appear quite readable easily so you should not have problems understanding the output of it.

First of all what you should look at is the following part of the output:

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

The PASSED status indicate your disk has passed the overall-health self-assessment test, which is good 🙂

Another field you want to have a look at it SMART Error Log:

SMART Error Log Version: 1
No Errors Logged

No errors Logged is good.

However SMART self-assessment is usually based on the short test which is designed to run a collection of disk tests that that the highest probability of detecting problems, so it’s not a comprehensive test! To have a better feedback you should run the extended (or long) self-test. Be aware that the extended self-test can take a lot of time to complete (mostly depending on the speed and size of your disk), it can take up to hours. In general long self-test can be executed in normal system operation (with the exception if you used the captive mode via -C option).

If you are examining a laptop disk or a disk you bring around traveling then you may want to run the conveyance self-test, which is intended to identify damage incurred during transporting of a drive. This test usually take just few minutes, but it’s not as comprehensive as the extended test.

Another option is the offline self-test, which can be performed in normal system operations too.

How to run a SMART test on demand?

To specify one of the tests above to be executed when you need it use:

$ smartctl --test=long /dev/sda

The command above will execute the extended self-test, replace “long” with short, offline or conveyance as you need.

If, for any reasons, you need to stop an ongoing selftest you can stop it using:

$ smartctl -X

How can I check/display SMART self-test results?

When the test is completed you can display it’s results with the following command:

$ sudo smartctl --attributes --log=selftest --quietmode=errorsonly /dev/sda

The syntax above will display only the errors (if any), so the output results a little quicker to read.

If you want a complete report then you can use:

$ sudo smartctl --attributes --log=selftest /dev/sda

F.A.Q:

Q – Can I use SMART in  VMware Virtual Machine?

A – No, VMware (at least till recent releases WS 10 etc…) don’t have a VM SMART (and why would they need that since a VM disk is a virtual disk?). However you can use SMART on the HOST System and, if you use VMware ESX then you can check SMART status via:

esxcli storage core device smart get -d device

However the output of esxcli command is different than the standard SMART output.

 

Q – Does macOS supports SMART?

A – Yes internally in the OS, so you can quickly access some info via System Report -> SATA/Sata Express. However to have a better control like in this how-to then I recommend to install smartmontools via Brew using:

$ brew install smartmontools

And then query your disk using:

$ smartctl -a disk0s2

 

Q – Does FreeBSD has SMART support?

A – YES, you can install smartmontools via:

$ pkg_get -r smartmontools

Also make sure on BSD to add smartd_enable=”YES” in /etc/rc.conf to start its SMART daemon at boot if you need it.

At this point you can use smartctl as explained in the how-to.

 

Q – Does Windows has SMART support?

A – Seriously does this blog seems to support Windows in any form? LOL Jokes apart, no Windows doesn’t seems to be supporting SMART directly, or in a way the user can access directly, so you’ll need to install 3rd party utilities to check your drive SMART status on Windows.

There are plenty of tools available to download, free or commercial.

Thanks for reading and, if you enjoyed this post, please support my blog by visiting my on-line hacking and engineering merchandise shop on redbubble.com by clicking here, thank you!:)

 

Leave a Reply or Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.