Operations 6 min read

Detect and Fix Bad Sectors on Linux with badblocks and Smartmontools

Learn step-by-step how to identify and handle bad sectors on Linux disks using the badblocks utility and Smartmontools, covering device enumeration, scanning commands, interpreting results, and marking defective blocks as unusable to maintain storage performance and prevent hardware failure.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Detect and Fix Bad Sectors on Linux with badblocks and Smartmontools

Introduction

Bad sectors (or bad blocks) are areas on a disk or flash storage that cannot be read or written, usually due to permanent physical damage or transistor failure. An increasing number of bad sectors degrades performance, reduces capacity, and can lead to total hardware failure. This guide explains how to use Linux disk‑scanning tools to detect and manage bad sectors.

badblocks

Use the badblocks utility to scan for bad sectors.

The badblocks command scans storage devices (e.g., /dev/sda or /dev/sdc) for unreadable blocks.

Step 1: List all disks and partitions with super‑user privileges. sudo fdisk -l Step 2: Scan the target Linux disk for bad sectors. sudo badblocks -v /dev/sda10 > badsectors.txt The -v flag shows detailed progress, and the output is redirected to badsectors.txt . Replace /dev/sda10 with the actual device name.

Step 3: Mark the identified bad sectors as unusable.

For ext2/ext3/ext4 filesystems: sudo e2fsck -l badsectors.txt /dev/sda10 For other filesystems:

sudo fsck -l badsectors.txt /dev/sda10

Smartmontools

Use smartmontools to check disk health (recommended).

Smartmontools leverages the S.M.A.R.T. (Self‑Monitoring, Analysis and Reporting Technology) system built into modern ATA/SATA, SCSI/SAS, and SSD drives to report health status and predict failures.

Step 1: Install Smartmontools.

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

Step 2: Use smartctl to perform a health check.

man smartctl
smartctl -h

Step 3: Run a basic health test. sudo smartctl -H /dev/sda10 The -H (or --health ) flag displays the overall S.M.A.R.T. health assessment.

Conclusion

By combining badblocks and smartmontools, you can detect, analyze, and mitigate bad sectors on Linux storage devices, ensuring reliable performance and preventing unexpected hardware failures.

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.