Operations 6 min read

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

Learn step-by-step how to identify and handle bad sectors on Linux disks using the badblocks utility and Smartmontools, covering device listing, scanning commands, marking defective blocks, and performing SMART health checks to maintain storage reliability and prevent hardware failures.

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

Introduction

Bad sectors (or bad blocks) are areas on a disk or flash storage that cannot be read or written due to permanent physical damage or transistor failure. When they accumulate, they degrade performance, reduce capacity, and can cause complete hardware failure, so they should be marked as unusable or the drive replaced.

Using badblocks

Use the badblocks tool to scan for bad sectors.

The tool scans storage devices such as hard drives or external drives, which are referenced as device files like /dev/sdc or /dev/sda.

Step 1: List all disks and partitions with super‑user privileges. sudo fdisk -l This command shows the correct device name for the subsequent scan.

Step 2: Scan the Linux disk for bad sectors/blocks. sudo badblocks -v /dev/sda10 > badsectors.txt The -v flag prints detailed progress, and the output is redirected to badsectors.txt for later use.

Step 3: If bad sectors are found, unmount the disk and mark those sectors as unavailable.

For ext2/ext3/ext4 filesystems: sudo e2fsck -l badsectors.txt /dev/sda10 For other filesystems: sudo fsck -l badsectors.txt /dev/sda10 These commands tell the filesystem to avoid writing to the listed bad blocks.

Smartmontools

Use smartmontools to check overall disk health (recommended for modern ATA/SATA, SCSI/SAS, and SSD drives).

Step 1: Install smartmontools.

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

Step 2: Use smartctl to access the S.M.A.R.T. system.

man smartctl
smartctl -h

You can view the manual or help page for usage details.

Step 3: Run a basic health test. sudo smartctl -H /dev/sda10 The command returns the overall health status; a “PASSED” result indicates the drive is currently healthy.

Conclusion

By combining badblocks and smartmontools, you can reliably detect, report, and mitigate bad sectors on Linux storage devices. Regular monitoring of disk health is essential to maintain system stability and prevent data loss.

Reference

Source: 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.