Up to $100 off Dedicated Servers

Guide to the smartctl utility in smartmontools for Linux

Posted on by Luke Cavanagh
Reading Time: 9 minutes

Every modern HDD or SDD has an option to monitor its current status and health via SMART attributes. The SMART test can be performed to detect any potential problems with the hardware itself. Tests such as these are run using smartctl. According to the Linux man page, smartctl is a command line utility designed to perform SMART tasks. Examples of these tasks would be printing error logs or enabling and disabling automatic SMART testing. 

What is SmartCTL?

The smartctl tool is a utility in the smartmontools package. This tool is designed to function in conjunction with the SMART system, an abbreviation for Self-Monitoring, Analysis, and Reporting Technology. which is an embedded feature in modern hard disk drives (HDDs) and solid-state drives (SSDs). It assesses the well-being of devices while anticipating potential malfunctions.

To illustrate, consider a scenario where smartctl is utilized on a Linux operating system to observe an SSD's operational condition. Using the command smartctl -H /dev/disk0 outputs the overall health self-assessment test result. This quick status check provides the user with a clear indication of the device's health. By regularly reviewing this status, users can predict imminent failures and perform necessary replacements or backups to prevent data loss.


Before you jump into smartctl, a fundamental grasp of Linux terminal interactions and command functions is essential. Knowledge of file system setups and data storage devices can be quite helpful. Moreover, you need root or sudo privileges on the system where you intend to install and operate smartctl, as most of its features demand escalated rights.


In this article, we used AlmaLinux, but the installation guide will show you how you can install smartctl on Ubuntu 22.04 as well.


Step 1. Install

To install smartctl on AlmaLinux, you'll need to use the Yum package manager. First, open a terminal. Then, run the following command to install smartctl:

yum install smartmontools

Write the above command into your terminal, yum will check dependencies and available packages. When the installation is complete, you will be prompted with the questions, “Is it okay to continue the installation?” Just type y and let the installation complete.

 Package Arch Version Repository Size
 smartmontools x86_64 1:7.0-2.el7 base 546 k
Installing for dependencies:
 mailx x86_64 12.5-19.el7 base 245 k

Transaction Summary
Install 1 Package (+1 Dependent package)

Total download size: 791 k
Installed size: 2.4 M
Is this ok [y/d/N]: y

  smartmontools.x86_64 1:7.0-2.el7

Dependency Installed:
  mailx.x86_64 0:12.5-19.el7


Step 2. Enable smartctl

Once smartmontools is installed, it's necessary to enable and start the smartd service — the SMART daemon. Now that smartctl is installed, let’s start it and make sure that it always starts when the server is rebooted. We can accomplish this by running the following screen commands in Linux.

Once enabled, you need to start the service with the command below, This command will make sure that the smartctl daemon is up and running at every system startup. No output will be displayed when you use this command:

systemctl enable smartd

This next command will start smartctl, and this one also will not provide any output. You can use the status flag instead of the start flag to see if the smartctl service is running or not:

systemctl start smartd

Check the status of smartd with the following command:

systemctl status smartd

You should see that the service is active (running), as shown below:

● smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
   Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2023-05-31 12:28:58 EDT; 1s ago
     Docs: man:smartd(8)

Ubuntu 22.04

The installation of smartctl on Ubuntu is mostly the same as it is on AlmaLinux. The starting details are slightly different.

Step 1. Update system packages

Prior to putting any new software on your system, it's a good habit to update your system's package list. Run the following apt-get update command to do so:

sudo apt-get update

Step 2. Install smartmontools

And install smartmontools:

sudo apt-get install smartmontools

The rest of the process to enable smartctl and the user commands are the same as they are on AlmaLinux.

Step 3. Verify smartctl is installed

After the installation is complete, you can verify if smartctl was installed successfully by running the following command:

smartctl --version

Now, smartctl should now be installed. Next, let’s go through some basic usage examples where smartctl comes in handy. 


The smartctl tool designed to perform SMART tasks. You can use it to print the SMART self-test and error logs, enable and disable SMART automatic testing, and initiate device self-tests. To use smartctl, you'll first need to open a terminal.

The general syntax for the smartctl command is as follows:

smartctl [options] device

Here, options refers to the various commands and parameters you can pass to the smartctl, and device refers to the hard drive or SSD you want to examine. Here are some key options you might use:

For example, if you want to display all SMART information for the drive /dev/sda, you would use the following command:

smartctl -a /dev/sda

Remember to replace dev/sda with the path of your own device. If you’re not sure what your device’s path is, you can use the commands df -h and lsblk:

df -h

[root@host ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        926M     0  926M   0% /dev
tmpfs           936M     0  936M   0% /dev/shm
tmpfs           936M  106M  831M  12% /run
tmpfs           936M     0  936M   0% /sys/fs/cgroup
/dev/vda3        97G   70G   23G  76% /
tmpfs           188M     0  188M   0% /run/user/250
tmpfs           188M     0  188M   0% /run/user/1001


[root@host ~]# lsblk
sr0     11:0    1 1024M  0 rom
vda    253:0    0  100G  0 disk
├─vda1 253:1    0    1M  0 part
├─vda2 253:2    0    2G  0 part [SWAP]
└─vda3 253:3    0   98G  0 part /

More use cases

As stated above, smartctl can perform various hard drive tests. We can analyze a faulty drive or perform an ATA/SCSI test based on our HDD type. Generally, tests like these are divided into two types. The ATA/SCSI test and the ATA specified test. 

ATA/SCSI tests are divided into two test types: short and long tests. The ATA specified tests are divided into two types of tests: a Conveyance Test and Select Tests. Before running any of these tests, we must make sure that SMART is enabled on our HDD. Here is a command with which we can check to ensure it is enabled. 

smartctl -i /dev/vda

Keep in mind that the vda drive type is only used as an example. That is the HDD label on the test server that I used for this article. It will be different in your case, most likely. The easiest way to find out your HDD label is to run the df -h command. 

The output of the above command will look like this:

smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1127.19.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org

Vendor: QEMU
Product: Vz HARDDISK0
Revision: 2.5+
Compliance: SPC-3
User Capacity: 42,949,672,960 bytes [42.9 GB]
Logical block size: 512 bytes
LU is thin provisioned, LBPRZ=0
Serial number: e603b97ac34343e582bb
Device type: disk
Local Time is: Tue Oct 6 15:37:02 2020 EEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

The last two lines are the most important as they tell you if the hard drive is capable of running the SMART test. When you see that SMART support is available, but not enabled, you can run this command to enable it.

smartctl -s on -o on -S on /dev/vda

The output of the command above will look like this.

SMART Enabled.  
SMART Attribute Autosave Enabled.  
SMART Automatic Offline Testing Enabled every four hours.

Now that we are sure SMART is available and enabled on our device, let’s check some examples of smartctl commands. We will review how to use them and their purpose. 

Example commands

In the following sections, let's review some example commands you can use to perform SMART tasks. You'll find a detailed overview of the helpful commands that can be utilized with smartctl. These commands let you perform a variety of tasks related to driver health and SMART functionality.

We want to point out one thing before we check some common examples of smartctl commands. Each test that you can perform can run in two modes: a Background and a Foreground mode. When you run them in the background, priority on the test is low, and all the operations on the server will generally run as expected.

If the HDD suddenly gets busy and I/O goes sky-high, the test will be paused until things return to normal. The Foreground mode will not lower the tests' priority, and no matter what happens, tests will continue to run. The Foreground mode is only recommended for use when HDD is not being used by anything else. 

Now that we cleared that out of the way, let’s check commands. 

Disable smartctl

This command would turn off the automatic offline data collection for the specified hard drive. If you want to disable SMART capabilities on your hard drive, you can use this command:

smartctl -o off device

This might be used if you believe the testing is causing performance issues or otherwise interfering with normal operation.

Check drive health

This command checks the health status of the specified hard drive. If the drive is healthy according to its SMART self-tests, it will report that the health check passed. If there are problems, it will indicate that the health check failed, and you check the details to understand the problem.

smartctl -H device

Our output will look like this:

smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1127.19.1.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org

SMART Health Status: OK

Verify test mode

If you want to make sure that drive is capable of running tests on its own, you can use this one. It will show you what SMART can do on the specified hard drive, giving you an idea of what kinds of health checks and error checks you can do with it:

smartctl -c device

Run long/short test

When you want to run a short or long test on your HDD, you can use these two commands. The first one, the short device command starts a short test. It’ll take a few minutes to complete and check only major components:

smartctl short device

The second one, the long device command initiates an extensive test that will require a significant amount of time to complete, but it will comprehensively scan all elements.

It’s also recommended to use background testing with tests; please continue reading the background testing section for more information:

smartctl long device

Background testing

For any of the tests to run in the background, you can use -t flag. In smartctl, the -t flag allows you to initiate self-tests on your storage device that run in the background. Background testing lets you continue using the system while the test is ongoing. So, it’s recommended to use one of the following commands:

smartctl -t short device

smartctl -t long device

smartctl -t conveyance device

smartctl -t select device

Running these tests in the background is particularly useful for long tests, allowing uninterrupted system use during the testing period.

To check the test progress or results, use the below command:

smartctl -l selftest device

Foreground Testing

For the Foreground mode, the -C flag has to be added. Remember, run this only if the hard drive is not used by anything else:

smartctl -t short -C device

smartctl -t long -C device

smartctl -t conveyance -C device

smartctl -t select -C device

The -C option, also known as --captive, is used with the -t option to run the short, long, selective, or conveyance self-tests in a mode known as captive or foreground mode. This mode is unique because it commands the drive to conduct the test immediately and continuously, monopolizing the hard drive's resources for the test duration.

It can be helpful in certain situations where you want to get the test results as quickly as possible and if you're okay with the hard drive being temporarily unavailable for other tasks. Foreground tests often complete faster than background tests because other tasks do not slow down the hard drive.

View full results

Let’s check how we can view the results of our tests:

smartctl -a device

This command prints a comprehensive SMART report, including the device model, serial number, firmware version, SMART attributes, error log, self-test log, and more. Here is an example of the output that you will get, just a part of it because the whole output will be quite lengthy:

SMART Selective self-test log data structure revision number 1
    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

View limited results

If you need a shorter output that will display just the results of the test, you can use this command:

sudo smartctl -A device

This displays a table of the hard drive's SMART attributes, including their raw and normalized values and details, such as the worst value recorded and the threshold value for each attribute. This information can help you assess the health of the hard drive and identify potential issues.

When you are aware of your hard drive's errors, and you want to display them, use this command:

smartctl -l error device


This guide has offered an in-depth look at installing and using a powerful tool, smartctl, including various example commands. Whether running a basic health check, enabling or disabling SMART features, or performing comprehensive self-tests, smartctl offers you the options you need. Remember, it’s essential to regularly check the health of your driver and act swiftly, or contact your hosting provider, if you notice any sign of failure.

In the end, we hope that this article served as an introduction to this useful utility and that you will explore it on your own. In this article, we covered the very basics of the smartctl commands. If further information is needed, the smartctl man page can provide additional knowledge about this utility and all the available flags. We can type man smartdinto our terminal to open the man pages for smartctl

Want more information?

We pride ourselves on being The Most Helpful Humans In Hosting™! Our experienced Hosting Solutions advisors are always available to show you how you can take advantage of these techniques today!

We are available 24 hours a day, 7 days a week 365 days a year to assist you.

Avatar for Luke Cavanagh

About the Author: Luke Cavanagh

Product Operations Manager at Liquid Web. Devoted husband and Tween wrangler. Synthwave enthusiast. Jerry Goldsmith fan. Doctor Who fan and related gubbins.

Latest Articles

Mount ISO files via IPMI using a local file and the Java method

Read Article

How to use NextCloud — setup and features

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article