How to test Snapraid data corruption?

I'm running Snapraid on my hard drives. However, I want to test it's data integrity features, to see how/if they actually work.

But I don't really understand how to 'corrupt' my data. I can just manually change the contents of my files. However, Snapraid will just sync this change normally. And Snapraid fix will automatically revert the files to before the change.

But how do I test an actual data corruption, and how do I know if Snapraid has actually fixed it?


Solution 1:

Maybe this works. At first sync your data:

snapraid sync

Now check the size and timestamps of your file

stat foo.txt

Now create a backup of the timestamps:

touch -r foo.txt foo.timestamps

Next step is to change foo.txt through an file editor like vi / nano without changing the filesize (replace one character).

After that restore the timestamps:

touch -r foo.timestamps foo.txt

Delete the timestamp backup file:

rm foo.timestamps

Check and compare the results

stat foo.txt

Check for new files

snapraid diff

It shouldn't return anything as we did not change the filesize and timestamp of foo.txt.

Finally start a full scrub:

snapraid scrub full

Now snapraid creates checksums of all files and compares them with the metadata and foo.txt should be listed as fixable file.