Skip to content

Commit

Permalink
dracut: 90zfs: zfs-load-key: wait for key to appear
Browse files Browse the repository at this point in the history
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes openzfs#12065
  • Loading branch information
nabijaczleweli committed May 23, 2021
1 parent 6388876 commit 2e483a7
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions contrib/dracut/90zfs/zfs-load-key.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,24 @@ if [ "$(zpool list -H -o feature@encryption "${BOOTFS%%/*}")" = 'active' ]; then

KEYLOCATION="$(zfs get -H -o value keylocation "${ENCRYPTIONROOT}")"
if ! [ "${KEYLOCATION}" = "prompt" ]; then
if ! [ "${KEYLOCATION#http}" = "${KEYLOCATION}" ]; then
systemctl start network-online.target
fi
case "${KEYLOCATION%%://*}" in
http*)
systemctl start network-online.target
;;
file)
KEYFILE="${KEYLOCATION#file://}"
[ -r "${KEYFILE}" ] || udevadm settle
[ -r "${KEYFILE}" ] || {
info "Waiting for key ${KEYFILE} for ${ENCRYPTIONROOT}..."
for _ in 1 2 3 4 5 6 7 8 9 10; do
sleep 1
[ -r "${KEYFILE}" ] && break
done
}
[ -r "${KEYFILE}" ] || warn "Key ${KEYFILE} for ${ENCRYPTIONROOT} hasn't appeared. Trying anyway."
;;
esac

zfs load-key "${ENCRYPTIONROOT}"
else
# decrypt them
Expand Down

0 comments on commit 2e483a7

Please sign in to comment.