CLI tool for remapping bad sectors on Linux disks using device-mapper
Project description
remap_badblocks
remap_badblocks is a Linux utility that lets you safely create a virtual block device which skips bad sectors and transparently remaps new bad sectors to healthy spare sectors elsewhere on the same disk. It is useful for squeezing safe, stable usage out of partially failing disks.
🔧 How It Works
- Stores devices configurations in a persistent database (this is crucial for accessing the remapped disks)
- badblocks
- mapping between real and virtual blocks
- number of spare sectors in the device
- It can either create a new mapping from scratch or update the existing one to remap new badblocks by keeping everything intact
- It can generate device-mapper devices that follow the stored mappings
🚀 Usage
remap-badblocks [-h] [-P DB_PATH] {add,get,update,apply} ...
Global Options
-P, --db-path— path to the configuration database (default is internal)
Commands:
add
Register a new device in the remap database.
remap-badblocks add [--wwn WWN] [--path PATH] name
name: required alias for the device--wwn: optional WWN of the device--path: optional device path (e.g.,/dev/sdX)
get
Retrieve registered devices or a specific one:
remap-badblocks get [--id ID]
update
Compute and store badblocks, update the mapping:
remap-badblocks update [--mode {read,write,skip}] [--block-range RANGE] [--output OUTPUT] [--spare-space N] id
--mode: how badblocks should operate (default:read)--block-range: e.g.,0-100000or1573---output: also save badblocks to a file--spare-space: reserve N good sectors for future remapping
apply
Apply the device-mapper table to create a virtual remapped device:
remap-badblocks apply [--id ID] [--method device-mapper]
🛠️ Example Workflow
- Register the device:
remap-badblocks add --path /dev/disk/by-id/myid mydrive
- Run badblocks scan and create the mapping:
remap-badblocks update --mode read --spare-space 512MB --id 1
- Apply the remapping to create a safe virtual block device:
remap-badblocks apply --id 1
- Use
/dev/mapper/mydriveas your new clean device
⚠️ Warnings
- This tool does not recover corrupted data, it only prevents future reads/writes from known bad sectors.
- Only usable on non-boot drives.
- Always keep backups.
- Devices are not persistent between boots, you have to manually apply them at startup (
remap-badblocks apply), but this will be changed in the future.
📆 Future Plans
Done
- Manage dependencies between different devices
- Empty db column for "apply at startup"
- Leave free space in disks for possible future metadata (around 4-8B per badblock + 12-24B per mapping, let's consider around 1k badblocks + 1k mappings = 16-32kB => maybe 100kB is good)
- Check already applied devices
- Add version option for getting version
🤝 Contributions Welcome
Feel free to submit improvements or suggestions.
For issues or feature requests, please open a card on GitLab.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file remap_badblocks-0.7.tar.gz.
File metadata
- Download URL: remap_badblocks-0.7.tar.gz
- Upload date:
- Size: 37.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9653380078a879fef28d7adab51961da9a6878962d242cf4fc3436d53e0fe88e
|
|
| MD5 |
f0f414ac44f5abf13dad85724b5d0640
|
|
| BLAKE2b-256 |
686add9bae01a7a1b27aa25226601ce5e056279314b3e4d58afe0124814cbe2e
|
File details
Details for the file remap_badblocks-0.7-py3-none-any.whl.
File metadata
- Download URL: remap_badblocks-0.7-py3-none-any.whl
- Upload date:
- Size: 60.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d0fa19fa6b57646cbea57f884b6c7c2c68ac778d2acece4715c865c9ea98676
|
|
| MD5 |
b6180556002b651f204b805a99030f03
|
|
| BLAKE2b-256 |
e17e1e0429f0e0d4b9e105dfa0b836a82ff755686ff222b1610bc1c339f4c94e
|