SysTutorials

Detecting Bad Blocks on Storage Devices

· updated April 12, 2026

If you suspect a disk has bad blocks, use the badblocks utility to scan for them. This tool probes a device (usually a disk partition) and reports which blocks are unreliable or unreadable.

Basic Usage

badblocks /dev/sda1

This scans /dev/sda1 from the first block to the last block on the device.

Common Options

Examples

Non-destructive read test on a mounted partition:

sudo badblocks -s -n /dev/sda1

Write-destructive test (warns: data will be overwritten):

sudo badblocks -s -w /dev/sda1

Test a specific range (blocks 1000 to 5000):

sudo badblocks -s /dev/sda1 5000 1000

Save results to a file:

sudo badblocks -s -o bad_blocks.txt /dev/sda1

Important Considerations

Integration with Filesystem Tools

After identifying bad blocks, use fsck with the bad block list to mark them as unusable:

sudo fsck -l bad_blocks.txt /dev/sda1

Alternatively, e2fsck for ext2/3/4 filesystems:

sudo e2fsck -l bad_blocks.txt /dev/sda1

Checking SMART Data First

Before running badblocks, check your drive’s SMART status to see if the manufacturer already detected issues:

sudo smartctl -a /dev/sda

This is faster and won’t risk further disk stress if the drive is already failing.

Additional Tips and Best Practices

When implementing the techniques described in this article, consider these best practices for production environments. Always test changes in a non-production environment first. Document your configuration changes so team members can understand what was modified and why.

Keep your system updated regularly to benefit from security patches and bug fixes. Use package managers rather than manual installations when possible, as they handle dependencies and updates automatically. For critical systems, maintain backups before making any significant changes.

Quick Verification

After applying the changes described above, verify that everything works as expected. Run the relevant commands to confirm the new configuration is active. Check system logs for any errors or warnings that might indicate problems. If something does not work as expected, review the steps carefully and consult the official documentation for your specific version.

← All posts