About simulating a BitRot, why no one tell it can be easy done with dd
linux command on an off-line as well as on an on-line BTRFS?
https://man7.org/linux/man-pages/man1/dd.1.html
Let me explain how:
- Look for what devices are used by the BTRFS, let say they are /dev/sda1 and /dev/sdb1, just as an example.
- Just run a
dd
command to overwrite a small portion of one of the devices
Example, overwrite only one byte with random data at position N (in bytes):
dd bs=1 count=1 if=/dev/random of=/dev/sda1 seek=N
Explained parameters:
seek=N
indicates where to write from start of the device (replace N with position in bytes units
bs=1
indicates that units are in multiple of one byte
count=1
indicates that only one chunk (of bs
size) will be written
if=...
indicates where to read the data, (if ...
is /dev/random
it will be random data)
of=/dev/sda1
indicates where to write data (replace it with the device path, not the mounted path)
And that is it, you have written random data at a position in the device (out of the BTRFS chain control, aka, BitRot simulated).
Another thing is how to calulate that N to be inside a specific file... but since what is wanted is test Anti-BitRot of BTRFS the test can be done with a random N in a BTRFS with one huge big file on it (90% used, ~10% free).
To test if simulated BitRot get fixed you can create a MD5 sum before dd
command and after dd
command, they must match.
So:
- Create a BTRFS raid1 of two devices (better if they are not huge in size, just to test Anti-BitRot of BTRFS)
- Write a file with random data that has a sice of arrounf 90% of total BTRF volume size
- Create the MD5 sum of the file
- Do the
dd
command
- Create the MD5 sum of the file
- Compare both MD5 sum, they must match
No matter if BTRFS is online or offline (aka, mounted or not mounted) when doing the dd
command, since it is been done on one of the devices, not on the mount point of the BTRFS, the BTRFS will not know nothing about that write (BitRot simulated).
Hope this helps.