First, initialize SnapRAID and some test data:
cd /tmp
# Initialize disks
rm -f disk0; truncate -s 1G disk0; mkfs.ext4 disk0
rm -f disk1; truncate -s 1G disk1; mkfs.ext4 disk1
rm -f disk2; truncate -s 1G disk2; mkfs.ext4 disk2
rm -rf mnt0 mnt1 mnt2; mkdir -p mnt0 mnt1 mnt2
mount disk0 mnt0; mount disk1 mnt1; mount disk2 mnt2
# Setup SnapRAID
cat > /etc/snapraid.conf <<EOF
parity /tmp/mnt0/parity
data mnt1 /tmp/mnt1/data
data mnt2 /tmp/mnt2/data
content /tmp/mnt1/content
content /tmp/mnt2/content
EOF
mkdir -p mnt1/data mnt2/data
# Write data
dd if=/dev/urandom bs=1M count=1 of=mnt1/data/file1
dd if=/dev/urandom bs=1M count=1 of=mnt1/data/file2
dd if=/dev/urandom bs=1M count=1 of=mnt2/data/file3
dd if=/dev/urandom bs=1M count=1 of=mnt2/data/file4
snapraid sync
This creates the following directory structure:
/tmp
├── mnt0
│ └── parity
├── mnt1
│ ├── content
│ ├── content.lock
│ └── data
│ ├── file1
│ └── file2
└── mnt2
├── content
└── data
├── file3
└── file4
Now, simulating a failure of one disk by removing file1 and file2. Running
snapraid fix successfully restores them without issues as expected. Removing
file1 and file4 also permits restoring them because they don’t share the
same parity. However, removing file1 and file3 prevents the restore:
[...]
unrecoverable file1
unrecoverable file3
100% completed, 3 MB accessed in 0:00
8 errors
0 recovered errors
4 UNRECOVERABLE errors
DANGER! Unrecoverable errors detected!
This means that removing any file is potentially unsafe when other errors
(like a broken disk) can occur. The exact effect depends on the configuration
and number of parities. This behavior can be especially unexpected with
mergerfs. A typical setup is to
configure mergerfs over multiple directories on different drives and then also
to protect those directories with SnapRAID. However, the default allocation
strategy ("percentage free random distribution") can lead to a situation where
deleting a single directory can then delete files on multiple disks causing
the mentioned problem.