How to check disk health status in Linux
S.M.A.R.T. or Self-Monitoring, Analysis, and Reporting Technology is used to monitor hard drive's health status. It is built into both normal magnetic and SSD drives. You can use it to anticipate hard drive failure and take appropriate action before it fails.
smartctl is a tool to check your S.M.A.R.T.-enabled hard disk drive's (hdd) status in Linux. It is part of the smartmontools suite and is available in most Linux distributions, such as Ubuntu.
You can check disk health in Ubuntu and other Linux distribution by installing smartmontools suite and use the included smartctl utility at the terminal. Disk errors such as bad sectors or corrupted filesystems are not covered by S.M.A.R.T., thus requiring other methods to check.
Related: How to check for disk error in Linux
Steps to check hard drive health status in Linux:
Install smartmontools package for your system.
$ sudo apt update && sudo apt install --assume-yes smartmontools # Ubuntu and Debian
List installed hard drive on your system.
$ lsblk | grep disk sda 8:0 0 20G 0 disk sdb 8:16 0 5G 0 disk
Instruct hard drive to perform self-test using smartctl.
$ 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.
Check hard drive health status of selected hard drive using smartctl after the previous self-test has completed.
$ 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 Health Status: OK