Commit 628c5324 authored by James T. Lee's avatar James T. Lee
Browse files

zfs: Load file based keys at boot

parent 08b773b1
...@@ -37,11 +37,16 @@ if [ "$(zpool list -H -o feature@encryption $(echo "${root}" | awk -F\/ '{print ...@@ -37,11 +37,16 @@ if [ "$(zpool list -H -o feature@encryption $(echo "${root}" | awk -F\/ '{print
# if the root dataset has encryption enabled # if the root dataset has encryption enabled
ENCRYPTIONROOT=$(zfs get -H -o value encryptionroot "${root}") ENCRYPTIONROOT=$(zfs get -H -o value encryptionroot "${root}")
if ! [ "${ENCRYPTIONROOT}" = "-" ]; then if ! [ "${ENCRYPTIONROOT}" = "-" ]; then
# decrypt them KEYFORMAT=$(zfs get -H -o value keyformat "${root}")
TRY_COUNT=5 if [ "${KEYFORMAT}" = "passphrase" ]; then
while [ $TRY_COUNT -gt 0 ]; do # decrypt them
systemd-ask-password "Encrypted ZFS password for ${root}" --no-tty | zfs load-key "${ENCRYPTIONROOT}" && break TRY_COUNT=5
TRY_COUNT=$((TRY_COUNT - 1)) while [ $TRY_COUNT -gt 0 ]; do
done systemd-ask-password "Encrypted ZFS password for ${root}" --no-tty | zfs load-key "${ENCRYPTIONROOT}" && break
TRY_COUNT=$((TRY_COUNT - 1))
done
else
zfs load-key "${ENCRYPTIONROOT}"
fi
fi fi
fi fi
...@@ -3,6 +3,29 @@ class nest::profile::base::zfs { ...@@ -3,6 +3,29 @@ class nest::profile::base::zfs {
ensure => installed, ensure => installed,
} }
$zfs_mount_override = @(EOF)
[Service]
ExecStart=
ExecStart=/sbin/zfs mount -al
| EOF
file {
default:
mode => '0644',
owner => 'root',
group => 'root',
;
'/etc/systemd/system/zfs-mount.service.d':
ensure => directory,
;
'/etc/systemd/system/zfs-mount.service.d/load-key.conf':
content => $zfs_mount_override,
notify => Nest::Systemd_reload['zfs'],
;
}
file { '/usr/lib/dracut/modules.d/90zfs/zfs-load-key.sh': file { '/usr/lib/dracut/modules.d/90zfs/zfs-load-key.sh':
mode => '0755', mode => '0755',
owner => 'root', owner => 'root',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment