Downgrade zfs to 2.0

Hi,

Is it possible to downgrade zfs to 2.0 on 21.11? I run into regression and I don’t want to downgrade whole system to 21.05.

1 Like

From skimming quickly over the NixOS module, it doesn’t seem to be supported in an easy way.

But from my quick look it should be sufficient to override the zfs attribute (or zfsUnstable if you use that) in an overlay, by using an older checkout of Nixpkgs (e.g. 20.05).

Of course this means that your combination of Kernel/ZFS version isn’t tested anymore by the NixOS testing infrastructure.

1 Like

CAVEAT: Downgrading ZFS will fail if you have upgraded your pool to use features that are not available in the older version. In the best case your pool just cannot be imported, in the worst case you suffer pool corruption and data loss.

Unfortunately there is no easy way. You’ll need a faily complicated overlay to use another version of ZFS because you have to override both the userspace tools and the kernel module.

overlay.nix

self: super:
let
  version = "2.0.7";
  src = self.fetchFromGitHub {
    owner = "openzfs";
    repo = "zfs";
    rev = "zfs-${version}";
    sha256 = "sha256-ZO87aPQNTbyKJ/elmdXdnQTGtcUNX7DoqlOA1iWDMo4=";
  };
in
{
  # Be sure to use a supported kernel!
  linuxPackages_5_15 = super.linuxPackages_5_15.extend (linuxPackagesSelf: linuxPackagesSuper: {
    zfs = linuxPackagesSuper.zfs.overrideAttrs (_: {
      name = "zfs-kernel-${version}-${linuxPackagesSuper.kernel.version}";
      inherit src;
    }
    );
  });

  zfs = super.zfs.overrideAttrs (_: {
    name = "zfs-user-${version}";
    inherit src;
  });
}

configuration.nix

{ config, lib, pkgs, ... }:
{
  boot.kernelPackages = pkgs.linuxPackages_5_15;
  nixpkgs.overlays = [ (import ./overlay.nix) ];
}
5 Likes

I know and I filled bug against openzfs. But between unsupported configuration and broken one I will choose unsupported one.

just for the sake of completeness, can you say what zfs regression you ran into.

1 Like

.zfs/snapshot/ is empty over NFS. It turned out to be regression due to some other reason - but now I verified it by downgrading zfs. I’m back on supported version and switched to SMB.

1 Like

NFS! The Notworking File System!

This may or may not be true, depending how old and unix jaded you are

Well. It did worked for a few years…

oh don’t mind me , i’m just a cynic, however i’m trying not to be.

Thank you @hmenke. I stole this to quickly upgrade to avoid the 2.1.3 FSAVE bug.