geli setkey
command could be used for the procedure. This command can be expected to change the encryption key and re-encrypt the file system with the changed key. However, this is a critical task. You only have one shot to do it right - or you are facing a restore. There are examples of geli setkey
usage on specific geli
encrypted file systems, such a non operating file system on an external disk. I am not sure, that the same examples would apply for ZFS operating file systems. # cd /tmp/test
# dd if=/dev/random of=bolt01.key bs=64 count=1
# dd if=/dev/zero of=bolt01 bs=1024k count=512
# mdconfig -a -t vnode -f /tmp/test/bolt01
# geli init -s 4096 -K /tmp/test/bolt01.key /dev/md0
# geli attach -k /tmp/test/bolt01.key /dev/md0
# zpool create testpool /dev/md0.eli
# zfs create testpool/a
# cd /testpool/a/
# for i in `seq 1 12`; do echo "hi $i" > file$i; done
# ls -la
total 63
drwxr-xr-x 2 root wheel 14 Feb 22 12:02 .
drwxr-xr-x 3 root wheel 3 Feb 22 12:02 ..
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file1
-rw-r--r-- 1 root wheel 6 Feb 22 12:02 file10
-rw-r--r-- 1 root wheel 6 Feb 22 12:02 file11
-rw-r--r-- 1 root wheel 6 Feb 22 12:02 file12
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file2
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file3
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file4
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file5
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file6
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file7
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file8
-rw-r--r-- 1 root wheel 5 Feb 22 12:02 file9
#
# cat file2
hi 2
#
# zpool export testpool
# geli detach md0
# geli setkey -k /tmp/test/bolt01.key -K /tmp/test/bolt01.key /dev/md0
Enter passphrase:
Enter new passphrase:
Reenter new passphrase:
Note, that the master key encrypted with old keys and/or passphrase may still exists in a metadata backup file.
# geli backup /dev/md0 newmd0.eli
# geli attach -k /tmp/test/bolt01.key /dev/md0
Enter passphrase: <NEW PASSPHRASE>
#
# zpool import testpool
# zfs list -r testpool
NAME USED AVAIL REFER MOUNTPOINT
testpool 464K 472M 96K /testpool
testpool/a 152K 472M 152K /testpool/a
#
# cat /testpool/a/file8
hi 8
#