Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed fix for issue: ZFS native encryption #79 #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions defaults/initrd.d/00-zfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
. /etc/initrd.d/00-common.sh
. /etc/initrd.d/00-fsdev.sh
. /etc/initrd.d/00-devmgr.sh
. /etc/initrd.d/00-splash.sh

is_zfs() {
# Note: this only works after zfs_real_root_init
Expand Down Expand Up @@ -98,6 +99,21 @@ zfs_start_volumes() {
zpool export -f "${ZFS_POOL}"
zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
fi
# If ${ZFS_POOL}" supports encryption and is active
if [ "$(zpool list -H -o feature@encryption $(echo "${ZFS_POOL}" | awk -F\/ '{print $1}'))" = "active" ]; then
good_msg "Native ZFS encryption detected. Checking for encryptionroot."
ENCRYPTIONROOT=$(/sbin/zfs get -H -o value encryptionroot "${ZFS_POOL}")
# If root dataset is encrypted...
if ! [ "${ENCRYPTIONROOT}" = "-" ]; then
good_msg "ZFS encryption root enabled"
ask_for_password --prompt "Encryption password for ('${ENCRYPTIONROOT}')" \
--tries 5 \
--cmd "/sbin/zfs load-key ${ENCRYPTIONROOT}"
else
good_msg "ZFS root is not encrypted."
fi
fi

else
good_msg "Importing ZFS pool ${ZFS_POOL}"
zpool import -N ${ZPOOL_FORCE} "${ZFS_POOL}"
Expand Down