On Linux, I use RAID mirror (mdadm - software reaid). How to configure it so that data is read from both underlying devices and compared, to detect data bitrot and fail in such case?
Is that at all supported?
Would be good option to have.
(Of course as one of layers of protection, for important data)
Traditionally RAID is for uptime or speed, this isn’t that (actually quite the opposite). If you want to do an extra integrity check one of the popular ways to do it is to use a file system that has checksums, like zfs or btrfs.
How to configure it so that data is read from both underlying devices and compared, to detect data bitrot and fail in such case?
You don’t lol
Is that at all supported?
Not afaik.
Would be good option to have.
If it ain’t broke don’t fix it. Use ZFS or BTRFS
I believe you can get this if you setup the underlying disks with dm-integrity, though I’m not sure it’s really worth it since it’s a very manual setup and has lots of potential edge cases and performance issues. Basically when the underlying disks are setup with dm-integrity, each read is verified with a checksum, if the checksum doesn’t match, the dm-integrity layer will return a read error and mdadm will log an error and automatically fallback to the secondary mirror. A “scrub” in this case would simply be reading the disk to /dev/null with dd, then checking the mdadm logs for any errors.
Note that it’s been a long time since I’ve messed with this, so it’s possible I got the exact details of the setup wrong.
Red Hat made Stratis to layer all this stuff together but I’ve never tried it.
https://en.wikipedia.org/wiki/Stratis_(configuration_daemon)
Unfortunately, it’s not supported in mdadm. As an alternatives, you may look into zfs and btrfs. Also, backups with versioning may help you if bit rot happened to restore a good version of your file.