Skip to content

Instantly share code, notes, and snippets.

@rkeiii
Created September 10, 2022 23:20
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkeiii/0fe05fdcee6f520c208280acbf2b49ea to your computer and use it in GitHub Desktop.
Save rkeiii/0fe05fdcee6f520c208280acbf2b49ea to your computer and use it in GitHub Desktop.
Hack fix script for volumes suffering ZFS encryption bug
#!/usr/bin/env bash
#
# This script attempts to recover a ZFS filesystem afflicted by the bug described in
# the following GitHub issues:
#
# * https://github.com/openzfs/zfs/issues/13859
# * https://github.com/openzfs/zfs/issues/13521
# * https://github.com/openzfs/zfs/issues/13709
#
# the ZFS filesystem we need to hack recover
fs=$1
# where to store ZFS incremental
tmpfile=/tmp/recover_zfs_hack
# tmp snapshot names
snap1=recover1
snap2=recover2
sudo zfs snapshot $fs@$snap1
sudo zfs snapshot $fs@$snap2
sudo zfs send --raw -i $fs@$snap1 $fs@$snap2 > $tmpfile
sudo zfs rollback -r $fs@$snap1
sudo zfs receive -F -v $fs < $tmpfile
sudo zfs mount $fs
sudo rm $tmpfile
echo "Enjoy your (hack) fixed ZFS filesystem! (Fingers crossed)"
@florian-obradovic
Copy link

Awesome, thanks a lot!

@mat128
Copy link

mat128 commented Oct 27, 2022

Thanks, this worked for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment