#linux #utility #system

nightly app integrity-scrub

Scrub dm-integrity volumes

23 releases

0.6.3 Aug 28, 2023
0.6.2 May 24, 2023
0.6.1 Apr 11, 2023
0.6.0 Jan 1, 2023
0.5.1 Nov 27, 2021

#3 in #linux-utility

Download history 26/week @ 2023-05-30 1/week @ 2023-06-06 4/week @ 2023-06-13 23/week @ 2023-06-20 44/week @ 2023-06-27 7/week @ 2023-07-04 3/week @ 2023-07-11 9/week @ 2023-07-18 3/week @ 2023-07-25 1/week @ 2023-08-01 5/week @ 2023-08-08 23/week @ 2023-08-15 38/week @ 2023-08-22 10/week @ 2023-08-29 52/week @ 2023-09-05 3/week @ 2023-09-12

103 downloads per month

MirOS license

432 lines


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.


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.


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.


~72K SLoC