Introduction / Why This Matters
smartmontools is a suite of utilities for monitoring the health of storage drives (HDD and SSD) using SMART (Self-Monitoring, Analysis and Reporting Technology) technology. SMART helps detect signs of wear, failures, or potential drive issues in advance, which is critical for preventing data loss.
After installing smartmontools, you will be able to:
- View detailed disk health information (temperature, number of reallocated sectors, power-on hours, etc.).
- Run built-in disk self-tests.
- Receive warnings about impending failure.
- Integrate monitoring into alerting systems (e.g., via Nagios, Zabbix).
This guide is suitable for all popular Linux distributions.
Requirements / Preparation
Before you begin, ensure that:
- You have terminal access with sudo privileges (or root).
- The disk you plan to monitor supports SMART technology (virtually all modern drives do).
- You have an internet connection for package installation (if working on an offline server, you will need to download packages manually).
⚠️ Important: For NVMe drives, use
smartctlwith special options. In this guide, we will cover the general case for SATA/SAS drives. For NVMe, see the Potential Issues section.
Step 1: Identify the Disk Name
First, you need to find out how your disk is represented in the system. Open a terminal and run:
lsblk
You will see a list of all block devices. Typically, the system disk is /dev/sda, and additional drives are /dev/sdb, /dev/sdc, etc. For NVMe drives, names look like /dev/nvme0n1.
Note down the name of the disk you want to monitor (e.g., /dev/sda). If you are unsure which disk is needed, check the mount point in the lsblk output or use sudo fdisk -l.
Step 2: Install the smartmontools Package
Installation is done via your distribution's package manager. Choose the command that matches your system:
For Debian/Ubuntu and derivatives (Linux Mint, Pop!_OS, etc.)
sudo apt update
sudo apt install smartmontools
For RHEL/CentOS 7/8 and derivatives (AlmaLinux, Rocky Linux)
sudo yum install smartmontools
For Fedora, RHEL 8+, CentOS Stream
sudo dnf install smartmontools
For Arch Linux and derivatives (Manjaro, EndeavourOS)
sudo pacman -S smartmontools
For openSUSE
sudo zypper install smartmontools
After running the command, the package manager will install the smartctl (main utility), smartd (background daemon), and documentation.
Step 3: Verify the Installation
Make sure the utility installed correctly:
smartctl --version
Expected output (version may vary):
smartctl 7.3 2022-02-28 r5145 [x86_64-linux-5.15.0-50-generic] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org
If the command is not found, check if the package is installed and that /usr/sbin (where smartctl resides) is in your PATH.
Step 4: Perform Your First Disk Check
Now you can query disk information. Replace /dev/sdX with your disk's name (e.g., /dev/sda):
sudo smartctl -a /dev/sdX
Key points in the output:
- SMART overall-health self-assessment test result:
PASSEDorFAILED. IfFAILED— the disk will fail soon. - SMART capabilities: Should be
Enabled. IfDisabled, enable it withsudo smartctl -s on /dev/sdX. - Attributes (ATTRIBUTE_NAME): Pay attention to:
Reallocated_Sector_Ct(reallocated sectors) — a value >0 indicates wear.Current_Pending_Sector(pending reallocation) — a value >0 is a warning sign.UDMA_CRC_Error_Count(cable errors) — often indicates a bad SATA cable.Temperature_Celsius— disk temperature.
Quick Health Check
If you only need the overall status, use:
sudo smartctl -H /dev/sdX
Output will be brief:
SMART Health Status: OK
Step 5: (Optional) Configure the smartd Background Daemon
For automatic regular monitoring, you can run the smartd daemon. It will check disks on a schedule and send notifications (e.g., to syslog).
- Edit the configuration:
sudo nano /etc/smartd.conf - Add a line for your disk (example for
/dev/sda):
Where:DEVICESCAN -a -o on -S on -s (S/../.././02|L/../../6/03)DEVICESCAN— automatically find all SMART-capable disks.-a— monitor all attributes.-o on— enable automatic data collection at startup.-S on— enable automatic attribute saving.-s— test schedule: short test every 2 hours, long test every 6 months.
- Start and enable autostart:
sudo systemctl enable --now smartd - Check status:
sudo systemctl status smartd
Now the daemon will run in the background. Check logs in /var/log/syslog or with journalctl -u smartd.
Verification
After completing the steps:
- Run
sudo smartctl -a /dev/sdXand ensure the output shows no access errors and displays full information. - If you configured
smartd, verify the daemon is active:sudo systemctl is-active smartd(should returnactive). - For a test, try running a short test manually:
Wait 1-2 minutes, then runsudo smartctl -t short /dev/sdXsudo smartctl -a /dev/sdXagain and look for theSelf-test execution statussection at the end with the result.
If all steps completed without errors — installation and basic configuration are done.
Potential Issues
1. Error SMART support is: Unavailable or Unable to detect SMART capability
- Cause: The disk or controller is not passing SMART data (common with RAID arrays or some USB enclosures).
- Solution:
- For RAID: use utilities from the controller manufacturer (e.g.,
MegaClifor LSI). - For USB: try connecting the disk directly via SATA.
- For NVMe: use
sudo smartctl -a /dev/nvme0(note the-d nvmeoption for some versions).
- For RAID: use utilities from the controller manufacturer (e.g.,
2. Error Permission denied or smartctl: Command line error: Invalid argument (-a)
- Cause: Forgot
sudoor specified an incorrect disk name. - Solution: Always use
sudoand verify the disk name withlsblk.
3. smartd fails to start or cannot find disks
- Cause: Incorrect configuration in
/etc/smartd.conf. - Solution:
- Simplify the config:
DEVICESCAN -a(for testing only). - Verify disks are readable for SMART: does
sudo smartctl -a /dev/sdXwork? - Check logs:
sudo journalctl -u smartd -n 50.
- Simplify the config:
4. User lacks permissions to read SMART (without sudo)
- Cause: By default, only root can read SMART data.
- Solution: Add the user to the
diskgroup:
Note: This grants access to all disks. Log out and back in, or runsudo usermod -aG disk $USERnewgrp disk.
5. smartctl reports SMART overall-health self-assessment test result: FAILED!
- Cause: The disk already has critical attributes (e.g., many reallocated sectors).
- Solution: Replace the disk immediately. Back up data as a priority. A SMART failure means the drive may fail at any moment.
6. For NVMe drives: smartctl: Permission denied or No such device
- Cause: NVMe requires specifying a driver.
- Solution: Use:
Or for auto-detection:sudo smartctl -a -d nvme /dev/nvme0
(newer smartmontools versions auto-detect the driver).sudo smartctl -a /dev/nvme0