Mind the encryptionroot: How to save your data when ZFS loses its mind

sambowman.tech

146 points by 6581 a day ago


aborsy - 20 hours ago

Nice write up and website. I should snapshot my empty root!

If I’m not wrong, at least some of those sharp edges have been resolved. There was a famous very hard to reproduce bug causing problems with ZFS send receive of encrypted snapshots once in a blue moon, that was hunted down and fixed recently.

Still, ZFS needs better tooling. The user has two keys and an encrypted dataset, doesn’t care what is encryption root, and should be able to decrypt. ZFS should send all information required to decrypt.

The code for ZFS encryption hasn’t been updated since the original developer left, last I checked.

In my view, in this case, you could say ZFS nearly lost data: it ties dataset settings in a pool and doesn’t send the necessary settings for reproduction when one of them is replicated. The user is clearly knowledgeable in ZFS and still almost lost data.

chasing0entropy - a day ago

Why zfs freak out is accepted as "normal" in a dev environment is beyond me. I use storage spaces on a daily basis in production and dev environment and have for nearly 10 years now and with only marginal use of PowerShell I have been able to restore every array I didn't destroy intentionally. This is the bare minimum I expect out of an redundant array of any type regardless of its speed or scalability promises.

wkat4242 - a day ago

> Lesson: Test backups continuously so you get immediate feedback when they break.

This is a very old lesson that should have been learned by now :)

But yeah the rest of the points are interesting.

FWIW I rarely use ZFS native encryption. Practically always I use it on top of cryptsetup (which is a frontend for LUKS) on Linux, and GELI on FreeBSD. It's a practice from the time ZFS didn't support encryption and these days I just keep doing what I know.

3abiton - a day ago

> I very nearly permanently lost 8.5 TiB of data after performing what should've been a series of simple, routine ZFS operations but resulted in an undecryptable dataset. Time has healed the wound enough that I am no longer filled with anguish just thinking about it, so I will now share my experience in the hope that you may learn from my mistakes.

As a zfs user employing encryption, that read like a horror story. Great read, and thanks for the takeaway.

kalaksi - a day ago

I've used zfs and btrfs and while I haven't quite lost data, I have also hit some unnerving pitfalls / sharp edges that have confirmed that I should keep at least one copy using just LUKS + ext4. I like the features but I think the more complicated filesystems bring about other kind of risks.

Imustaskforhelp - 12 hours ago

I am not sure if this is the correct place but pardon me, I was one trying to remove the luksEncryption key and I searched it on stackoverflow thinking that I am going to figure this out myself...

The first thing on stackoverflow permanently made the data recoverable and it was only under the comment that people mentioned this...

My whole data of projects and what not got lost because of it and that just gave me the lesson of actually reading the whole thing.

I sometimes wonder if using AI would've made any difference or would it have even mattered because I didn't want to use AI and that's why I went to stackoverflow lol... But at the same point, AI makes hallucinations too but it was a good reality check for me as well to always read the whole thing before running commands.

ysleepy - 9 hours ago

Would it not have been easier to just mount the destroyed old pool or recovering the dataset from the history ring buffer?

zpool import -D

https://openzfs.github.io/openzfs-docs/man/master/8/zpool-im...

I haven't tried this, but I gather from the blog post that it would have been much simpler as it didn't require any of the encryption stuff.

asmor - 7 hours ago

Thanks for validating my choice to not use raw send/recv. I know not everyone can avoid it, but it also seemed to be a bit prone to this kind of issue.

ed_db - a day ago

This is one hell of a bad day, I am impressed at how they were able to solve this.

pessimizer - a day ago

This all seems unbelievably more complicated and prone to failure than just doing luks over mdadm. You could just skip this weird, arcane process by imaging the disks, walking them to where they needed to be, then slapping them into the other machine and mounting them as normal.

I do not understand making RAID and encryption so very hard, and then using some NAS in a box distribution like an admission you don't have the skills to handle it. A lot of people are using ZFS and "native encryption" on Archlinux (not in this case) when they should just be using mdadm and luks on Debian stable. It's like they're overcomplicating things in order to be able to drop trendy brand names around other nerds, then often dramatically denouncing those brand names when everything goes wrong for them.

If you don't have any special needs, and you don't know what you're doing, just do it the simple way. This all just seems horrific. I've got >15 year old mdadm+luks arrays that have none of their original disks, are 5x their original disk size, have survived plenty of failures, and aren't in their original machines. It's not hard, and dealing with them is not constantly evolving.

Reading this gives me childhood anxiety from when I compressed by dad's PC with a BBS pirated copy of Stacker so I would have more space for pirated Sierra games, it errored out before finishing, and everything was inaccessible. I spent from dusk to dawn trying to figure out how to fix it (before the internet, but I was pretty good at DOS) and I still don't know how I managed it. I thought I was doomed. Ran like a dream afterwards and he never found out.

lofaszvanitt - 8 hours ago

I like these writeups. People like to overly complicate their lives, but why? Does this give them wings?

jgalt212 - 10 hours ago

Encryption keys for backups make me nervous. We use restic, password required, and also rsync (no password) high priority drives.