How to Detect and Fix Bad Sectors on Linux with badblocks and smartmontools
This guide explains what bad sectors are, why they matter, and provides step‑by‑step Linux commands using badblocks and smartmontools to scan disks, list faulty blocks, and mark them as unusable, helping administrators maintain storage health.
Introduction
Bad sectors (bad blocks) are areas on a hard‑disk or flash device that can no longer be read or written, typically due to permanent physical damage or a failed flash transistor. Accumulating bad sectors degrade performance, reduce capacity, and can lead to complete hardware failure, so they should be identified and handled promptly.
Using badblocks
List all disks and partitions with super‑user privileges:
sudo fdisk -lScan the target device (replace /dev/sda10 with the actual device) and save the list of bad blocks:
sudo badblocks -v /dev/sda10 > badsectors.txtIf bad sectors are reported, unmount the filesystem and mark those sectors as unusable. For ext2/3/4 filesystems: sudo e2fsck -l badsectors.txt /dev/sda10 For other filesystems:
sudo fsck -l badsectors.txt /dev/sda10Using smartmontools
Install the package:
sudo apt install smartmontools # Debian‑based
sudo dnf install smartmontools # RHEL‑basedRead the manual or help page to become familiar with smartctl :
man smartctl
smartctl -hRun a basic health check on the device (replace /dev/sda10 as needed):
sudo smartctl -H /dev/sda10The command returns the overall SMART health status, indicating whether the drive is currently healthy.
Conclusion
Combining badblocks to locate physical bad sectors and smartmontools to monitor overall drive health enables Linux administrators to detect, isolate, and prevent further damage to storage devices.
Reference: https://www.tecmint.com/check-linux-hard-disk-bad-sectors-bad-blocks/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
