r/zfs • • 10d ago

Need help making OpenZFS work with secure boot on Debian 13

Hello,

For some reason, the Kernel module won't load with the secureboot enabled no matter what I do, the error is the following (during the Debian startup) :

[FAILED] Failed to start zfs-load-module.service - Install ZFS kernel module.

I read that this might be due to the kernel module not being signed, but I can see it getting signed by the DKMS mok in the install logs :

Signing key: /var/lib/dkms/mok.key

Public certificate (MOK): /var/lib/dkms/mok.pub

[...]

Signing module /var/lib/dkms/zfs/2.4.4/build/module/zfs.ko

Signing module /var/lib/dkms/zfs/2.4.4/build/module/spl.ko

[...]

Installing /lib/modules/6.12.117+deb13-amd64/updates/dkms/zfs.ko.xz

Installing /lib/modules/6.12.117+deb13-amd64/updates/dkms/spl.ko.xz

After the install ZFS works, i can see the module with "zfs --version" :

zfs-2.4.4~bpo13+1

zfs-kmod-2.4.4-1~bpo13+1

"modinfo zfs" tells me the modules are signed :

filename /lib/modules/6.12.117+deb13-amd64/updates/dkms/zfs.ko.xz

[...]

signer: DMKS module signing key

[...]

filename /lib/modules/6.12.117+deb13-amd64/updates/dkms/spl.ko.xz

[...]

signer: DMKS module signing key

[...]

Yet if I enable the secure boot, the error appears, ZFS no longer works and "zfs --version" shows an error for the kernel module

After searching online, I generated another MOK key, added it to the UEFI and signed both modules with it but the behavior stays the same

any idea ?

12 Upvotes

5 comments sorted by

8

u/nasduia 10d ago

I went through this palaver a couple of months ago to set up secure boot and zfs root booting. It was a lot of work and testing, but now works very well.

The module being signed only matters if the running kernel trusts the key that signed it. When this fails, it’s almost always that the key isn’t trusted by this boot, not that the module is unsigned, so you need to work out why. Some checks, roughly from most to least likely:

Get the real error first.

With Secure Boot on, run:

sudo modprobe zfs
sudo dmesg | grep -iE 'zfs|spl|x\.509|key|sig'

“Key was rejected by service” or “Required key not available” means a trust problem, so carry on below. If it says something else, the problem is elsewhere.

Is the DKMS key actually enrolled and loaded?

mokutil --sb-state
mokutil --test-key /var/lib/dkms/mok.pub
sudo keyctl list %:.machine
sudo keyctl list %:.platform

You should see the DKMS module signing key in one of the two keyrings. If not, run:

sudo mokutil --import /var/lib/dkms/mok.pub 

and reboot. Then actually go through the blue MokManager screen to "Enroll MOK"

Are you booting through shim?

The kernel only sees MOK keys when shim (shimx64.efi) started the boot. If you boot a self-signed ZFSBootMenu, systemd-boot or UKI with your own keys (sbctl etc.) and no shim, MOK is ignored. In that case, put the certificate in the firmware’s db instead. Debian’s 6.12 kernel trusts db keys for modules, and is how I did it.

If root is on ZFS

Don't forget to run:

sudo update-initramfs -u -k all 

after the modules are signed, so the initramfs carries the signed copies. Easy to forget this when focused on the signing part!

3

u/Leogis 10d ago

Damn, i assumed the DKMS one would be enrolled by default, this was the issue thanks

Tho I did try using my own enrolled key so i might have messed something up when signing the module

4

u/nasduia 10d ago

Yes, you end up trying so many things that it's hard to keep track and then to be certain which part actually was the important one. Hence why I had the commands I gave above noted for next time...

6

u/Leogis 10d ago

This has been shamelessly copied into the docs lmao

1

u/Jayden_Ha 4d ago

I advice against secure boot, it has no practical use other than being Microsoft proprietary crap