[BUG] zfs hook won't ask for password


At the moment if you have your ROOT on ZFS and encrypted, zfs hook won’t ask for a password it will fail with can’t mount error.
I’ve made my own fix in /usr/lib/initcpio/hooks/zfs file but would be good if it gets mainstream as at the moment every time kernel gets updated I have to do my fix in.
I’ve only added the following two lines under zfs_mount_handler function.

KEY=$(zfs get -H -o value keyformat “${dataset}”)
if [ “$KEY” == “passphrase” ]; then echo “Ask for key…”; zfs load-key “${dataset}”; fi;
mount -t zfs -o “zfsutil,${rwopt_exp}” “${dataset}” “${node}${mountpoint}”

As an additon, I also have force flag in ZPOOL_IMPORT_FLAGS as if my laptop crash zfs won’t let you mount.

1 Like

If I am not completely mistaken - you can override the hook by creating a new hook in /etc/pacman.d/hooks

I don’t think it’s the same, those are the hooks that are used when booting ZFS not when doing updates to package itself. Probably yes you could do something like if ZFS kernel update then move your own ZFS hook before you rebuild initcpio but I think support for encrypted root should be out of the box rather then a complicated user workaround.

There is licensing incompatibilities with ZFS which prevents inclusion in the kernel and prvents distributions from defaulting it on a GPL license.

As such ZFS is the user’s choice - not the distribution.

Since pacman has hooks which can be placed /etc/pacman.d/hooks and it is a pacman hook which generates to .preset files in /etc/mkinitcpio.d if seems logic to create a hook to add your configuration to such custom hook instead of modifying the installation hook which will be overwritten by an update.

It looks like the hook is here and it’s been amended to include root decryption, just did an update and I can confirm it’s working.
gitlab . manjaro.org / packages/extra/zfs-utils/-/tree/master