Best way to run latest kernel with ZFS

I’ve got a dilemma. I recently bought an X1 Carbon Gen 12. Nice looking laptop and great keyboard.

I also recently decided to make the switch to ZFS. My main desktop will hopefully follow at some point but for now my server will run with it as well as the laptop.

Being as the Gen 12 is still quite new it needs a relatively new kernel. Unfortunately, NixOS has just dropped support for 6.10 and ZFS doesn’t yet support 6.11.

Until this situation changes is there a way I can run a newer kernel than the current 6.6 LTS? I’ve seen that ZFS 2.2.6 has some experimental support for 6.11. How would I enable this? Or would it be better to try the new rc2 branch and if so how would I enable that? An override no doubt but anything else needed for that?

Honestly the best thing to do right now is to pin your own kernel version and run 6.10. Yes, this means compiling your own kernel, but messing with experimental ZFS releases is probably not a good idea.

1 Like

Ah! That will do nicely. Thank you. I’ll give that a go.

It worked! Overrode linux_6_6 with version 6.10.14 and now I have brightness controls and display is recognized.
It didn’t seem to need compiling. At least it didn’t seem to take very long to rebuild my config.

That seems odd… How did you include it in your config? And are you on stable or unstable?

The unfortunate truth in this is that ZFS is an out-of-tree module and as such, will always lag behind major version releases. Your choice is to either use the stable kernel or start maintaining an overlay for the ZFS kernel package. Since you do not want the LTS kernel on your laptop, you can use this overlay:

  nixpkgs.overlays = [
    (final: prev: {
      linuxPackages_latest = prev.linuxPackages_latest // {
        zfs = prev.linuxPackages_latest.zfs.overrideAttrs (oldAttrs: rec {
          meta.broken = false;
          version = "2.3.0-rc2";
          src = prev.fetchurl {
            url = "https://github.com/openzfs/zfs/releases/download/zfs-${version}/zfs-${version}.tar.gz";
            hash = "sha256-JrMgwN3d475ZiFQUcPM2/097vDL0J1G8SG0ar5bYzj8=";
          };
        });
      };
    })
  ];

The downside to this is that you are now responsible for updating the hash every time upstream tags a new release.

Edit: I recommend sticking to an older kernel release (6.10 instead of 6.11) instead of using an rc release of ZFS.

2 Likes

I’m on unstable.

I added it like this:

  boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linuxKernel.kernels.linux_6_6.override {
    argsOverride = rec {
      src = pkgs.fetchurl {
            url = "mirror://kernel/linux/kernel/v${lib.versions.major version}.x/linux-${version}.tar.xz";
            sha256 = "sha256-VeW8vGjWZ3b8RolikfCiSES+tXgXNFqFTWXj0FX6Qj4=";
      };
      version = "6.10.14";
      modDirVersion = "6.10.14";
    };
  });

1 Like

Huh, yea, for some reason that still evaluates to a cached build on the latest unstable. I guess none of its dependencies in nixpkgs have changed since it was removed, so it’s still the same derivation as before the removal? Dunno

Please don’t do this. The value of config.boot.kernelPackages.zfs.meta.broken is false for linuxKernel but true for linuxKernel_latest. What you’re doing right now is better served by setting zfs.meta.broken to false.

As for why the “please don’t do this”, zfs-2.2.6 isn’t compatible with linux_6_11 and therefore you might encounter corruption issues, which is why doing so isn’t recommended. You’re using an incompatible version of the Linux kernel with the ZFS version included in nixpkgs. Better upgrade the ZFS version to a supported one with v6.11.

Edit: I noticed you are using the 6.10 (and not 6.11) kernel. This is fine.

1 Like

But I’m overriding to 6.10 which is supported by ZFS 2.2.6.

Yea, the zfs nix expressions will correctly set the broken flag if they try to use an unsupported kernel, as long as @PhilT sets the version argument for the kernel override truthfully. If the zfs derivation isn’t marked broken and causing an eval error, it is a fully supported kernel and there is no issue. What they’ve done is completely fine

1 Like