Skip to main content

CLI tool for remapping bad sectors on Linux disks using device-mapper

Project description

remap-badblocks

remap-badblocks is a Linux CLI tool written in Python that scans a block device for bad sectors and creates a device-mapper target that skips over them. It can also reserve extra space to dynamically remap future badblocks.

It's a simple way to extend the usefulness of slightly damaged drives, ideal for anyone who wants to avoid discarding a disk due to a few bad sectors.

Features

  • Scans disks using badblocks to identify damaged sectors
  • Creates a device-mapper target that avoids bad sectors
  • Reserves spare sectors for dynamic remapping
  • Supports using only part of a device (e.g., for hard partitioning or isolation)

Installation

From PyPI

pip install remap-badblocks

From source

git clone https://gitlab.com/Luigi-98/remap-badblocks.git
cd remap-badblocks
pip install -e .[dev]

Usage

Database

remap-badblocks relies on a single source of stateful storage: a SQLite database. By default, it is stored at /etc/remap_badblocks/devices_config.db, but you can specify an alternative location using the -P option.

Device Identification

Devices can be referenced by either:

  • Name: set at creation, used as the name of the output device-mapper
  • ID: an internal remap-badblocks identifier

CLI Reference

remap-badblocks --help

Example Workflow

# Add a new device
remap-badblocks add my_remapped_device --path /dev/sda

# Run a read-mode scan and initialize the mapping
#   by reserving spare space
remap-badblocks update --name my_remapped_device --mode read --spare-space 100MB

# Apply changes to generate the device-mapper
remap-badblocks apply

# Resulting device appears under /dev/mapper
ls /dev/mapper/
# /dev/mapper/my_remapped_device

Contributing

We welcome feedback, bug reports, feature ideas, code contributions, and help shaping the roadmap — or even rethinking the project from the ground up.

Start with CONTRIBUTING.md, then open an issue or submit a merge request to get involved.

License

GPL v3 License — see LICENSE for details.

Community

Acknowledgements & Related Tools

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

remap_badblocks-0.10.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

remap_badblocks-0.10-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file remap_badblocks-0.10.tar.gz.

File metadata

  • Download URL: remap_badblocks-0.10.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for remap_badblocks-0.10.tar.gz
Algorithm Hash digest
SHA256 9c2c0c9ef8fe937314e3be596791ca729e841c3fa4e89f8ca2edcf92ba83f7ed
MD5 da205ea7722428df2195d1824d2e4465
BLAKE2b-256 b476bfe771e7636419d141726c551006a227f0cb6fba169b5862c365c5392bb6

See more details on using hashes here.

File details

Details for the file remap_badblocks-0.10-py3-none-any.whl.

File metadata

  • Download URL: remap_badblocks-0.10-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for remap_badblocks-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 8661c22d1579fb6c9d0274e2145262afb4d4c70d04b195209a65e063df5d9d08
MD5 1bc0ff75f21b9dae2df0ad8da0f51517
BLAKE2b-256 14479bfb88ef5aad098408db4b8ca74f5d875b29f28571dc5ce1346b97fa2721

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page