Skip to content

Read-test zones on a zoned block device (Host-managed SMR drive) to check for bad sectors.

License

Notifications You must be signed in to change notification settings

playercatboy/badzones

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

badzones

A Linux utility for detecting bad sectors, bad blocks, and bad zones on host-managed SMR (Shingled Magnetic Recording) drives and other zoned block devices.

Features

  • Detects bad sectors and zones by performing read tests
  • Supports host-managed SMR drives using the Linux zoned block device API
  • Uses direct I/O (O_DIRECT) for accurate hardware access
  • Configurable zone range and read block size
  • Real-time progress display with read speed statistics
  • Graceful interruption via Ctrl+C
  • Detailed summary with zone statistics and error counts

Requirements

  • Linux kernel with zoned block device support
  • Linux kernel headers (linux/blkzoned.h, linux/fs.h)
  • GCC compiler
  • Root privileges (required for direct device access)

Building

make

Installation

sudo make install

This installs:

  • badzones binary to /usr/local/bin
  • Man page to /usr/local/share/man/man1

To uninstall:

sudo make uninstall

Usage

badzones [options] <device>

Options

Option Long Option Description
-s <zone> --start <zone> Start from zone number (default: 0)
-e <zone> --end <zone> End at zone number (default: last zone)
-b <size> --block <size> Read block size in bytes (default: zone size, max 256M)
-v --verbose Show info for each zone
-E --read-empty Also read empty sequential zones
-a --all Show all zone info (implies -v)
-h --help Show help message

Examples

Check all zones on a device:

sudo badzones /dev/sda

Check a specific range of zones:

sudo badzones -s 100 -e 200 /dev/sda

Verbose output showing each zone:

sudo badzones -v /dev/sda

Show all zone information:

sudo badzones -a /dev/sda

Interruption

Press Ctrl+C to stop gracefully. The program will finish checking the current zone and display a summary of results.

Exit Codes

Code Description
0 Success - no errors detected
1 Error - failed to open device or other runtime error
2 Errors detected - bad zones or read errors found
3 Interrupted - check was stopped by user

License

This project is licensed under the GNU General Public License v2.0 or later. See the LICENSE file for details.

Author

PlayerCatboy me@ralf.ren

About

Read-test zones on a zoned block device (Host-managed SMR drive) to check for bad sectors.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published