Failed to mount /sysroot - zfs on luks with systemd-boot

I am using a mangaro live iso to install a fresh system.

On reboot I always get the error: Failed to mount /sysroot.

I tried changing the kernel parameters and different hooks. I can not enter the emergency shell because root seems to be locked, although a password is set for root.

I don’t understand why I don’t see the password promt before it’s trying to mount it.

journalctl in the chroot replies with no jornal.

so this is my setup:

sda                         
└─luksCont              crypt
  ├─systemVG-rootLV     lvm   
   |   └─zfs pool                /mnt
  └─systemVG-swapLV     lvm   

sdc (USB)                   
├─sdc1             /mnt/efi
└─sdc2             /mnt/boot
                      └─luksheader, keyfile

Bootloader: systemd-boot

mkinitcpio.conf:(only the Files and HOOKS)

FILES=(/boot/header.img /boot/key.img)

HOOKS=(base systemd autodetect modconf keyboard sd-vconsole block mycustomencrypthook lvm2 zfs filesystems)

first i wanted to use sd-encrypt then I read it’s not supporting zfs
so i wrote my own hook based on a hook i found in the arch wiki

/etc/initcpio/hook/mycustomencrypthook:

#!/usr/bin/ash

run_hook() {

modprobe -a -q dm-crypt >/dev/null 2>&1
modprobe loop

[ "${quiet}" = "y" ] && CSQUIET=">/dev/null"

echo 'Waiting for USB:'
echo ' /efi '
i=1
sp="/-\|"
echo -n ' '

while [ ! -L '/dev/disk/by-uuid/3EF6-1EDA' ]; do

	printf "\b${sp:i++%${#sp}:1}"
	sleep 1
done
printf "\bfound!"

echo ' /boot '
i=1
echo -n ' '

while [ ! -L '/dev/disk/by-uuid/1667-253D' ]; do

	printf "\b${sp:i++%${#sp}:1}"
	sleep 1
done
printf "\bfound!"

#mkdir -p /mnt
#mount /dev/disk/by-uuid/1667-253D /mnt

#cryptsetup open /mnt/key.img lukskey
cryptsetup open /boot/key.img luks-key
cryptsetup open /dev/disk/by-id/ata-SAMSUNG... --header=/boot/header.img --key-file=/dev/mapper/luks-key enc

cryptsetup close luks-key
}

not sure if this is worth it, but i also found a github project which apparently adds zfs support to systemd. I haven’t tried that yet, because I don’t know how to install it in a chroot. I get this error, when I use

pamac build mkinitcpio-sd-zfs:

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

But some seem to have problems very similar to mine even with that hook. Look here:

The only difference is that i don’t use legacy mounts but inherited ones:

zfs get mountpoint

returns:

        rpool                                mountpoint  /mnt                           local
        rpool/ROOT                           mountpoint  none                           local
        rpool/ROOT/manjaro                      mountpoint  /mnt                           local
        rpool/ROOT/opt                       mountpoint  /mnt/opt                       local
        rpool/ROOT/usr                       mountpoint  /mnt/usr                       local
        rpool/ROOT/usr/local                 mountpoint  /mnt/usr/local                 inherited from rpool/ROOT/usr
        rpool/ROOT/var                       mountpoint  /mnt/var                       local
        rpool/ROOT/var/lib                   mountpoint  /mnt/var/lib                   inherited from rpool/ROOT/var
        rpool/ROOT/var/lib/systemd           mountpoint  /mnt/var/lib/systemd           inherited from rpool/ROOT/var
        rpool/ROOT/var/lib/systemd/coredump  mountpoint  /mnt/var/lib/systemd/coredump  inherited from rpool/ROOT/var
        rpool/ROOT/var/log                   mountpoint  /mnt/var/log                   inherited from rpool/ROOT/var
        rpool/ROOT/var/log/journal           mountpoint  /mnt/var/log/journal           inherited from rpool/ROOT/var
        rpool/home                           mountpoint  /mnt/home                      inherited from rpool
        rpool/home/maksim                    mountpoint  /mnt/home/maksim               inherited from rpool
        rpool/home/root                      mountpoint  /mnt/root                      local

I’m a bit confuesed why

zfs mount

shows different output for me from within the chroot.

zfs mount (in chroot)
rpool/ROOT/default /

zfs mount (manjaro iso)

rpool/ROOT/opt                  /mnt/opt
rpool/home/root                 /mnt/root
rpool/ROOT/var/log              /mnt/var/log
rpool/home                      /mnt/home
rpool/ROOT/var/lib/systemd/coredump  /mnt/var/lib/systemd/coredump
rpool/ROOT/usr/local            /mnt/usr/local
rpool/home/maksim               /mnt/home/maksim
rpool/ROOT/var/log/journal      /mnt/var/log/journal
rpool/ROOT/default                 /mnt

/boot/loader/entries/archlinux.conf:

The comments are different variants I tried. They seem to not change anything. But maybe I’m missing something.

title Manjaro
linux /vmlinuz-5.10-x86_64
initrd /intel-ucode.img 
initrd /initramfs-5.10-x86_64.img
options root=zfs:AUTO 
#options root=zfs:rpool/ROOT/default
#options root=ZFS=rpool/ROOT/default
#options zfs=rpool/ROOT/default

/efi/loader/loader.conf:

default manjaro
timeout 3
console-mode max
editor 1
random-seed-mode with-system-token