Operations 5 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Detect and Fix Bad Sectors on Linux with badblocks and smartmontools

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 -l

Scan the target device (replace /dev/sda10 with the actual device) and save the list of bad blocks:

sudo badblocks -v /dev/sda10 > badsectors.txt

If 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/sda10

Using smartmontools

Install the package:

sudo apt install smartmontools   # Debian‑based
sudo dnf install smartmontools   # RHEL‑based

Read the manual or help page to become familiar with smartctl :

man smartctl
smartctl -h

Run a basic health check on the device (replace /dev/sda10 as needed):

sudo smartctl -H /dev/sda10

The 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/

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

bad sectorsbadblocksdisk healthsmartmontools
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.