Pfsense zfs snapshot protection?

EDIT: right, so it’s copy on write that protects, I can see that. Snapshots had nothing to do with it.

So the buzz now that pfSense + 22.01 has been released is that one benefit to reinstall and use zfs rather than ufs is that snapshots can help recover from power shortages. I know zfs from Free/Truenas but I am not sure how that would work.

To my understanding zfs snapshots enable fast redeployment of a previous system state, I don’t see how they protect the current state from data corruption in a power loss.

Can someone want to clue me in?

ZFS is a CoW or Copy on Write file system and is a fundamental underpinning beneath most of what makes ZFS awesome. The basic concept is simple—if you ask a traditional filesystem to modify a file in-place, it does precisely what you asked it to. If you ask a copy-on-write filesystem to do the same thing, it says “okay”—but it’s lying to you.

Instead, the copy-on-write filesystem writes out a new version of the block you modified, then updates the file’s metadata to unlink the old block, and link the new block you just wrote.

Unlinking the old block and linking in the new is accomplished in a single operation, so it can’t be interrupted—if you dump the power after it happens, you have the new version of the file, and if you dump power before, then you have the old version. You’re always filesystem-consistent, either way.

These copy on write commits happen fast so the only data that might be lost is some log entries or if you lost power at the exact time you committed a config change it would just lose that last change.

1 Like