By regularly checking for errors, you can detect issues early and address them before they lead to hardware failure. In this article, you will learn different ways to check drive integrity, use key disk utilities, and stay informed about your hard drive’s health.
Why Hard Drive Health Matters
Hard drive health is not something you should ignore. A failing drive can corrupt files, slow down your system, and cause unexpected downtime. Regular checks help you identify problems such as bad sectors or damaged file systems. By being proactive, you can back up important data and replace the disk if needed.
Using SMART Tools
One of the most popular methods to check hard drive status in Linux is through SMART (Self-Monitoring, Analysis, and Reporting Technology) attributes. These attributes provide information on disk performance, temperature, and error rates. Here is how to use smartctl from the smartmontools package:
1. Install smartmontools:
sudo apt-get update sudo apt-get install smartmontools2. Check Drive Status:
sudo smartctl -H /dev/sdaReplace /dev/sda with the appropriate disk identifier on your system. This command gives you a quick overview of the health status. If the drive is in good condition, it usually shows “PASSED,” like in the image below.

3. Perform a Detailed Test:
sudo smartctl -t long /dev/sdaAn extended test performs a thorough check of the drive. After the test finishes, you can view the results with:
sudo smartctl -a /dev/sdaIf you don’t want to perform a long test, you can do a short one:
sudo smartctl -t short /dev/sda
$ 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.
Checking the File System
In addition to SMART checks, you should also verify the integrity of your file system. The fsck command scans file systems for errors and repairs them if possible:
sudo fsck -f /dev/sda1Ensure you replace /dev/sda1 with the correct partition on your system. If possible, unmount the partition before running fsck to avoid conflicts during the repair process.
You will get this error if you try to run the above command without unmounting your partition:
$ sudo fsck -f /dev/sda1
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
/dev/sda1 is mounted.
e2fsck: Cannot continue, aborting.
This is the result after you run the above command:
$ sudo fsck -f /dev/sda1
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Data: 21820/29310976 files (0.6% non-contiguous), 28782192/117212416 blocks
Using badblocks for Surface Scans
Another useful tool is badblocks, which scans your hard drive for unreadable or faulty sectors (this process takes a lot of time to complete based on the capacity of your drive):
sudo badblocks -sv /dev/sdaThe -s option displays the scanning progress, while the -v option shows detailed information. If badblocks finds any problematic sectors, you can decide whether to replace the hard drive or attempt to repair it.
Additional Tools
- Gnome Disks: A graphical utility that checks SMART data and performs simple benchmarks.
- hdparm: Useful for changing hard drive settings and getting performance data.
Conclusion
Staying on top of your hard drive’s health in Linux is easier than you might think. Tools like smartctl, fsck, and badblocks give you valuable insights into your disk’s condition, allowing you to detect errors before they cause data loss. Spending little time on regular checks can save you from major headaches later. By taking these proactive steps, you can maintain system performance, safeguard your files, and extend the life of your hardware.
