ZFS & Legacy Kernel

I’m looking to try and run zfs with an older kernel, namely the 5.15. As context there is an issue with 6.X series kernels and vfio with newer am5 platforms. I verified this by testing my configuration on Rocky Linux 9 5.15 and it worked, with nix it didn’t.

I can’t seem to find a way to override the zfs package and corresponding kernel. Setting to the linux package for 5_15 resulted in an error.

       > created 19 symlinks in user environment
       > inconsistent kernel versions: 5.15.117
       > 6.1.34

This seems to be pinned here

I then tried creating a custom zfs package copying the stable version and adjusting it to support 5_15. But that option is readonly.

I thought may an override may work, but that doesn’t appear to work as there’s no exposed option.

  nixpkgs.config = {
    zfs = {
     kernel  = pkgs.linuxPackages_5_15;
     latestCompatibleLinuxPackages  = pkgs.linuxPackages_5_15;
    };
  };

I’m still not well versed in custom nix packaging. So may be missing a simple option. Is there a way to provide a custom kernel without having to port the entire zfs configuration module?

There is already a 5_15 zfs package.

The fact that the zfs package exposes its latest compatible kernel seems to have gotten you confused. You shouldn’t need to touch anything related to zfs

The inconsistent kernel versions error seems to result from an attempt to override just the zfs module.

Instead replace the kernel (or: kernelPackages). It’s in the NixOS manual.

boot.kernelPackages = pkgs.linuxKernel.packages.linux_5_15;
1 Like

I was trying that because it appeared it had been pinned. But this is the block that caused kernel version mismatch

  boot = {
    #kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
    kernelPackages = pkgs.linuxKernel.packages.linux_5_15;
    zfs = {
      devNodes = "/dev/disk/by-partuuid/bfd28831-fa5b-c44c-83c7-12d7bae254e8";
      forceImportAll = true;
      forceImportRoot = true;
    };
error: builder for '/nix/store/6hvdx2p82iikirajdv0c357ggppvyzsd-kernel-modules.drv' failed with exit code 1;
       last 3 log lines:
       > created 19 symlinks in user environment
       > inconsistent kernel versions: 5.15.119
       > 6.3.11
       For full logs, run 'nix log /nix/store/6hvdx2p82iikirajdv0c357ggppvyzsd-kernel-modules.drv'.
error: 1 dependencies of derivation '/nix/store/8n21bvbhpni23fn8a256570zm4dnzqsn-nixos-system-workstation-23.05.20230705.e111420.drv' failed to build
make: *** [Makefile:24: system-build] Error 1

It looked like any of the boot.zfs pulls in zfs stable? Which does that kernel version check. Which potentially I have to switch root fs off of zfs?

Shouldn’t happen. Certainly not based on the snippets you’ve provided.

It’s just used to determine the latest compatible version.

Just to confirm: I put my own suggestion in my configuration.nix and rebuilt a 5.15 kernel with zfs without issue. Note the inconsistent kernel versions error could be caused by any module - it doesn’t have to be zfs.

There must be something else to your config - can you share the full/more of your configuration.nix?

:man_facepalming:
Deeper down in my config I was over riding the arg. Thanks for the help. it’s working now.

1 Like