How to check and monitor a hard drive in Linux

Hard drive failures rarely happen without warning — and that’s exactly where S.M.A.R.T. technology becomes essential. By monitoring disk health indicators in real time, administrators can detect potential failures before data loss occurs. In this guide, you’ll learn how to use Smartmontools in Linux to check drive health, enable SMART support, and configure automatic monitoring.

 

Key Points

  • SMART technology helps detect potential hard drive failures by monitoring disk health indicators.
  • Smartmontools includes smartctl for manual checks and smartd for automated background monitoring.
  • You can use smartctl to enable SMART, check disk information, and verify overall drive health status.
  • Configuring smartd allows automatic testing and email notifications in case of disk errors.

What Is SMART and Smartmontools?

SMART (Acronym for Self-Monitoring, Analysis and Reporting Technology) can be found on all modern hard drives, allowing for the detection of conditions and the reporting of the times a unit can “fall” permanently. Smartmontools is a free multiplatform tool that uses the S.M.A.R.T. of hard drives to get informed about their status. With Smartmontools, a user or system administrator can be constantly informed about the imminent hard disk failure.

How to Install Smartmontools on Linux

On Ubuntu or Debian systems, Smartmontools is available in official repositories:

sudo apt-get install smartmontools

It is possible that other important Linux distributionsArch, Fedora, Suse/openSuse, CentOS/Red Hat, Slackware – to be in the official warehouses (for Fedora it surely is).

Installing Smartmontools provides 2 programs: smartctl, which can be used in an interactively mode and smartd, which, as the name suggests, is a daemon meant to run in the background.

Using smartctl to Check Disk Health

Smartctl requires root permissions to run. Smartctl monitors an entire hard disk (not a particular partition). To get information about a hard drive, we will use the -i option:

sudo smartctl -i /dev/sda

where sdx is the drive you are interested in.

You will receive some drive info and you can also see if SMART support is available and enabled for your unit. If the SMART attribute is available but not enabled, you have the following command available:

sudo smartctl -s on /dev/sda

To check the health of your hard drive, we will use the -H option:
sudo smartctl -H /dev/sda

If we do not have PASSED at the exit, it means the hard drive has cracked or this will happen in a very short time. To see the SMART hard drive yield, use the -c option:

sudo smartctl -c / dev / sda

Configuring smartd for Automatic Monitoring

Smartctl is a fantastic tool that needs to be run periodically. Smartd is a daemon designed to periodically run the SMART diagnostics of selected drives. So if the hard drive did not pass the tests or an error occurred, the owner will be notified immediately.

The configuration file can normally be found at /etc/smartd.conf. We open this file and look for the lines that begin with DEVICESCAN and comment on it by adding # to its beginning. Then we show the system the list of drives to be scanned:

/dev/sda -a -o on -S on -s (S/../.././07 | L/../../6/03) -m [email protected] -M exec /usr/share/smartmontools/smartd-runner

The options listed above show the following:

• /dev/sda: The hard disk indicated for scanning
• -a: Activates some recommended options
• -d sat: on most systems (and mine), smartctl correctly recognizes that I have an ATA serial hard drive. smartd does not. If the smartd fails or does not start running, it is advisable to add the -d TYPE option
• -o on: enables SMART Automatic offline tests
• -S on: Enables SMART auto save
• -s (S/../.././07 | L/../../6/03): Run short tests (S/../.././02) and long (L/. ./../6/03) at the preset time. This example shows that a short test will start at 7:00 a day, and a long test at 3 o’clock.
• -m root: will send an email to the specified address; multiple addresses can be separated by commas. Keep in mind that this fat requires an active e-mail service (for example, on servers).
• -M exec /usr/share/smartmontools/smartd-runner: modifies the behavior of the -m option On Debian and Ubuntu systems, smartd-runner performs other actions in addition to the email option (-m).

For more information, see the smartd.conf man page:

man smartd.conf

After the smartd setup, we need to make sure that the scan will start in the same time with the system. To do this, open the /etc/default/smartmontools configuration file and uncomment line #start_smartd=yes (delete the # character). We save and start startd by commands:

sudo /etc/init.d/smartmontools restart

We should receive a message at the indicated address.

Smartmontools provides a powerful and reliable way to monitor disk health and detect potential hardware failures before they become critical. By combining smartctl for manual checks and smartd for automated background monitoring, Linux administrators can significantly improve system reliability and data protection.

If you are managing Linux servers and want full control over system health, user management, and performance tuning, you may also find our guide on the useradd command for adding users to Linux helpful for broader system administration tasks.

Frequently Asked Questions About Smartmontools and SMART in Linux

What is SMART in Linux?
SMART (Self-Monitoring, Analysis and Reporting Technology) is a monitoring system built into modern hard drives and SSDs. It helps detect potential hardware failures by tracking disk health parameters and reporting possible issues before a complete failure occurs.
How do I check disk health using smartctl?
You can check disk health by running the command “sudo smartctl -H /dev/sdX”. This will display the overall SMART health status of the selected drive. Replace sdX with the correct disk identifier for your system.
What is the difference between smartctl and smartd?
smartctl is a command-line utility used to manually check SMART information and run diagnostics on a drive. smartd is a background daemon that automatically monitors selected drives and can send alerts if errors or failures are detected.

About the author

Ilias spiros
By Ilias spiros

Categories