https://github.com/illdefined/integrity-scrub
Scrub dm-integrity devices
https://github.com/illdefined/integrity-scrub
block-device dm-integrity integrity-checker
Last synced: about 1 year ago
JSON representation
Scrub dm-integrity devices
- Host: GitHub
- URL: https://github.com/illdefined/integrity-scrub
- Owner: illdefined
- Created: 2021-10-29T22:21:41.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-17T11:43:55.000Z (over 1 year ago)
- Last Synced: 2025-03-26T22:02:16.396Z (about 1 year ago)
- Topics: block-device, dm-integrity, integrity-checker
- Language: Rust
- Homepage:
- Size: 115 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Synopsis
This tool attempts to read all logical sectors of a block device, overwriting any sector that cannot be read due to an
I/O error with zeros. It is intended to restore Linux dm-integrity volumes with invalid (corrupted) integrity tags.
## Usage
If you wish to scrub a volume, consider creating a backup of the underlying physical device first.
Then run the tool with the volume device path (`/dev/mapper/…` or `/dev/dm-…`) as a command line argument.
Unless you really know what you are doing, you should not run it on a mounted volume. Data written by the filesystem
might get overwritten by interleaved writes of the tool.
## Implementation notes
The block device is first read in large chunks (the maximum sectors per request as reported by the `BLKSECTGET` ioctl).
If a read results in an integrity error (`EILSEQ`), the logical sectors in the chunk are read individually and any
erroneous sector is overwritten with zeros.
Reads are performed using direct I/O (`O_DIRECT`), while writes rely on buffered I/O with chunk‐wise asynchronous
flushing (`sync_file_range(2)`). Any outstanding writes are finalised using `fdatasync(3)` before the tool exits.
## Caveat
This tool might delete all your data and summon a seal. Use it at your own risk. The seal will demand fish.
If you are not using a filesystem with copy‐on‐write semantics (e.g. btrfs) or data journalling (e.g. ext4 with
`data=journal`), you should probably rely on dm-integrity’s data journal.
## Intellectual property
This work is dedicated to the public domain under the terms of the
[CC0 1.0 licence](https://creativecommons.org/publicdomain/zero/1.0/).
The author holds no patent rights related to this work.