Monitoring disk health in Linux reduces the risk of sudden data loss by revealing failing HDDs and SSDs before they stop responding. Early detection allows storage to be replaced during maintenance windows instead of during outages, keeping services and personal files available.
Disk firmware exposes internal health metrics through S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology). On Linux these metrics are typically accessed with the smartctl utility from the smartmontools package, which can read attributes, run built-in self-tests, and show overall health summaries for devices such as /dev/sda or /dev/nvme0n1.
S.M.A.R.T. cannot detect every failure mode and does not substitute for regular backups, filesystem checks, or RAID monitoring. Some controllers or virtual disks may not expose full data, and intensive self-tests can temporarily impact performance on busy systems. The steps below focus on a short, non-destructive check on Ubuntu or other Debian-based distributions with root privileges available through sudo.
Related: How to check disk errors in Linux
Related: How to mount disks and partitions in Linux
Steps to check hard drive health status in Linux:
- Open a terminal session on the Linux system.
- Install the smartmontools package from the distribution repository.
$ sudo apt update && sudo apt install --assume-yes smartmontools Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB] Get:3 http://archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB] ##### snipped ##### Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: smartmontools 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 546 kB of archives. After this operation, 1,893 kB of additional disk space will be used. Do you want to continue? [Y/n] y ##### snipped #####
On Debian and Ubuntu, smartmontools provides the smartctl command; other distributions use package managers such as dnf, zypper, or pacman to install the same package.
- List block devices to identify the target disk name.
$ lsblk | grep -E 'disk|nvme' sda 8:0 0 20G 0 disk sdb 8:16 0 5G 0 disk nvme0n1 259:0 0 477G 0 disk
This output shows classic SATA disks such as /dev/sda and /dev/sdb as well as an NVMe disk /dev/nvme0n1; the appropriate device name is required for later commands.
- Query basic information on the selected disk to confirm that S.M.A.R.T. support is enabled.
$ sudo smartctl -i /dev/sda smartctl 7.3 2022-02-28 r5338 [x86_64-linux-5.15.0-76-generic] (local build) Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Samsung based SSDs Device Model: Samsung SSD 870 EVO 1TB Serial Number: S5RANX0T123456A LU WWN Device Id: 5 002538 f4a123456 Firmware Version: SVT01B6Q User Capacity: 1,000,204,886,016 bytes [1.00 TB] SMART support is: Available - device has SMART capability. SMART support is: Enabled
Proceed only when the output shows that S.M.A.R.T. support is available and enabled; some virtual disks or USB adapters may not expose these capabilities.
- Start a short S.M.A.R.T. self-test on the selected disk.
$ sudo smartctl -t short /dev/sda smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-47-generic] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 2 minutes for test to complete. Test will complete after Wed Jul 17 15:58:30 2019 Use smartctl -X to abort test.
Short self-tests are non-destructive but can still impact performance, so running tests on busy production disks may cause higher latency or temporary slowdowns.
- Display the overall S.M.A.R.T. health status after the short test completes.
$ sudo smartctl -H /dev/sda smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-47-generic] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART overall-health self-assessment test result: PASSED
A result such as PASSED or OK indicates that the disk firmware does not currently consider the device to be failing, although backups remain essential.
- Inspect detailed S.M.A.R.T. attributes to spot reallocated sectors or read errors.
$ sudo smartctl -a /dev/sda ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE 5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 0 9 Power_On_Hours 0x0032 098 098 000 Old_age Always - 1234 12 Power_Cycle_Count 0x0032 099 099 000 Old_age Always - 57
Growing counts for attributes such as Reallocated_Sector_Ct or Current_Pending_Sector often indicate impending failure even when the overall health status still shows PASSED.
- Review the S.M.A.R.T. self-test log to confirm that recent tests completed without error.
$ sudo smartctl -l selftest /dev/sda SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Short offline Completed without error 00% 1234 -
A status of Completed without error for the most recent entry verifies that the short self-test finished successfully.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
