How to test SSD / HDD health on Linux

CLEVER (Self-Monitoring, Analysis, and Reporting Technology) is a function that is activated in all modern hard drives and SSDs in order to monitor / test the reliability. It checks various drive attributes to identify the possibility of drive failure. Various tools are available on Linux and Windows to run the SMART tests.

In this tutorial we will learn how to test SSD / HDD Health in Linux of CLI and GUI

Two methods explained here are:

  • Using Smartctl
  • Using Gnome Hard Drives

Test the SSD state with Smartctl

Smartctl is a command line utility that can be used to check the SMART capable HDD or SSD status in the Linux system.

The Smartctl utility is provided with the package smartmontools.Smartmontools is available by default in all Linux distributions including Ubuntu, RHEL, and Centos and Fedora.

How to install smartmontools on Linux:

Ubuntu

$ sudo apt install smartmontools 

Start the service with the following command.


$ sudo /etc/init.d/smartmontools start

RHEL and CentOS

$ sudo yum install smartmontools

Fedora

$ sudo dnf install smartmontools

The smartd service is started automatically after successful installation.

If not started, start the smartd service:

$ sudo systemctl start smartd

Test the state of SSD / HDD

To test the overall health of the drive, enter:

$ sudo smartctl -d ata -H /dev/sda

Where,

d – Indicates the type of device.
ata – the device type is ATA, use scsi for the SCSI device type.
H – Check the device to report its SMART health status.


Check the overall health of the drive

The PASSED result indicates that the drive is OK. If the device reports a bad health status, it means that the device has either already failed or may fail very soon.

If it shows an error, use the -a option for more information.

$ sudo smartctl -a /dev/sda

Smartctl Command – SMART Attributes

You can monitor the following attributes:

[ID 5] Number of reassigned sectors – Number of sectors reallocated due to read errors.

[ID 187] Reported as incorrect – Number of uncorrectable errors when accessing read / write access to the sector.

[ID 230] Media wear indicator – Current operating status of the drive based on the life curve.

100 is the BEST value and 0 is the WORST.

Check SMART attribute details for more informations.

To start the extended test (long) with the following command:

$ sudo smartctl -t long /dev/sda

Start extended test

To run a self-test, do the following:

$ sudo smartctl -t short /dev/sda

Self-test with smartctl. start

Use the following command to determine the drive self-test result.

$ sudo smartctl -l selftest /dev/sda

Result of the smartctl self-test

Run the following command to evaluate the estimated time it will take to complete the test.

$ sudo smartctl -c /dev/sda

Calculate the estimated time to complete the test

You can print hard drive error logs by using the command:

$ sudo smartctl -l error /dev/sda

Print drive error logs

Testing SSD / HDD health with Gnome hard drives

With GNOME disks utility, you can get a quick look at your SSD drives, format your drives, create a disk image, run standard SSD drive tests, and restore a disk image.

Install Gnome hard drives

In Ubuntu 20.04, the GNOME hard drives Application comes with the installed GNOME hard disk tool. If you can’t find the tool, use the command below to install it.

$ sudo apt-get install gnome-disk-utility

GNOME Disk is now installed, now you can go to your desktop menu, navigate to the application, and launch it. From the application you can see all of your connected drives. You can also use the following command to start the GNOME Disk application.

$ sudo gnome-disks 

GNOME hard drive GUI

The test can now be carried out on the drives. To do this, start the GNOME hard drives and select the hard drive that you want to test. You will find the quick evaluation of the drives such as size, partitioning, serial number, temperature and condition. Click the gear icon and select SMART Data & Self-Tests.


GNOME Disks SMART Data and self-tests

In the new window you will find the results of the last test. At the top right of the window you can see that the SMART option is enabled. If SMART is disabled, it can be enabled by clicking the slider. To start the new test, click the Start Self-Test button.


GNOME hard drives with self-test

After clicking the Start Self-Test button, a drop-down menu will appear where you can select the test types which are Short, Advanced, and Transport. Select the test type and enter your sudo password to continue the test. The percentage of the test completed can be shown on the progress bar.


Result of the GNOME hard drive self-test

diploma

In this tutorial I explained the basic concept of SMART technology including its applications in the Linux system. I also covered how to install the smartctl command line utility on the Linux computer and how it can be used to monitor the health of hard drives. You will also get an idea of ​​the GNOME Disks utility for monitoring SSD drives. Hope this article will help you monitor your SSD drives using smartctl and GNOME Disks utility.