Enable ZFS self healing by mirroring across 2 partitions of same SSD?

Started by ozpac, April 18, 2024, 07:13:44 PM

Previous topic - Next topic
My ZFS root accumulated some file damage and then refused to mount.
I will rebuild the filesystem from scratch but want to increase resiliency by making use of ZFS's self healing abilities which requires mirrored data.
I'm using a Protectli device which only has one drive bay (a mini pcie port for mSATA cards).
My idea is to split that 128gb drive into two 64GB partitions then make the OPNSense system root a mirrored zpool across the two.

I will also run daily snapshots to external drives and so on, but I want better prevention rather than just better cures.

Is this a good plan?

How do you replace the broken partition while keeping the other one? Because that is what "self healing" means. You replace the broken disk. ZFS "resilvers" the data until redundancy is restored.

Does not make much sense to me.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

As I understand it, ZFS computes and stores checksums for everything (blocks?). It uses these to determine whether the block is in tact or damaged. If damaged then it will refer to the mirror to see if that block is in tact. It will then automatically write the undamaged block over the damaged one - thus self healing.  With only one copy of the data then self healing isn't possible.
Isn't that accurate?

In other words, this is the only way I can defend against bitrot, on this hardware. If I can do more I would love to do so.

A broken block stays broken until you perform a resilver operation. Usually after you swapped the broken device.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Ah I see, that makes sense.
How about bitflips (eg cosmic ray)? This would mitigate them wouldn't it?
I gather they are very rare but nevertheless, would my scheme work?

Most certainly yes. You could also create the zpool with copies=2 or copies=3

https://jrs-s.net/2016/05/02/zfs-copies-equals-n/

Mark the second paragraph with the laptop example.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Incredibly helpful info, thank kindly! I appreciate your efforts.

Question from a newbie: is the ZFS's self healing enabled by defauld having installed OPNsense with two drives (mirror) ?

Tia.

There is no healing without operator intervention. You can enable regular scrubs via cron jobs, though.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)