In this lesson, you will learn how to use smartmontools to interpret disk telemetry and predict potential hardware failures before your filesystem is compromised.
While filesystems like Ext4 or XFS manage data integrity, they rely on the underlying hardware to persist that data correctly. If a physical disk develops bad sectors or mechanical issues, the filesystem may encounter I/O errors that lead to corruption or read-only remounts. To prevent this, Linux uses S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology).
Using smartmontools
The smartmontools package provides the smartctl utility, which communicates directly with your disk’s internal monitoring system. It retrieves telemetry—a collection of health data points—that the disk hardware has been tracking during its operation.
To check the overall health status of a disk (e.g., /dev/sda), run:
sudo smartctl -H /dev/sda
The output will provide a simple PASSED or FAILED result. If it says PASSED, the disk’s internal logic believes it is currently functional. However, you should look deeper to see if failure is imminent.
Interpreting Failure Patterns
To see the full report, use sudo smartctl -a /dev/sda. Look specifically for these attributes in the output:
- Reallocated_Sector_Ct: This counts the number of sectors the drive has "retired" because they were damaged. A non-zero, increasing number is a strong indicator of a dying drive.
- Current_Pending_Sector: These are sectors waiting to be reallocated because they could not be read. These are often the cause of "Input/Output" errors when trying to access specific files.
- Power_On_Hours: Useful for context; a drive failing after 50,000 hours is expected, but failing after 100 hours indicates a premature defect.
When smartctl reports an increasing count of reallocated or pending sectors, the hardware is actively struggling to map its data. Even if the filesystem is currently "healthy," this telemetry is your early warning sign to backup your data immediately and replace the drive.
Key Takeaway: Use smartctl to monitor disk telemetry like reallocated sectors; a rising count in these values is a critical precursor to filesystem-level hardware failures.