Created
January 25, 2024 03:01
-
-
Save digitalsignalperson/f2b002e73d2f13e4a43d29a64b5f2a3e to your computer and use it in GitHub Desktop.
zfs force inherit encryptionroot on received dataset with pyzfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create test pool | |
dd if=/dev/zero of=/root/zpool bs=1M count=128 | |
zpool create testpool /root/zpool | |
# Create encryptionroot and some datasets | |
echo "12345678" | zfs create -o canmount=off -o mountpoint=/mnt -o encryption=on -o keylocation=prompt -o keyformat=passphrase testpool/enc | |
zfs create testpool/enc/data1 | |
zfs create testpool/enc/data2 | |
touch /mnt/data1/x | |
touch /mnt/data2/x | |
zfs snapshot -r testpool/enc@1 | |
# Make a recursive copy of the encryption root | |
zfs send -Rw testpool/enc@1 | zfs recv testpool/enc_copy | |
# Make a new dataset on the original encryption root and try to send to the new one | |
zfs create testpool/enc/data3 | |
touch /mnt/data3/x | |
zfs snapshot testpool/enc/data3@x | |
zfs send -Rw testpool/enc/data3@x | zfs recv testpool/enc_copy/data3 | |
# Fix the encryptionroot ourselves: | |
python -c 'import libzfs_core; libzfs_core.lzc_change_key(b"testpool/enc_copy/data3", "force_inherit")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment