ZFS: Difference between revisions

m Formatting, grammar, etc.
Update guidance around Kernel versions
Line 8: Line 8:


==== Latest Kernel compatible with ZFS ====
==== Latest Kernel compatible with ZFS ====
ZFS often does not support the latest Kernel versions. It is recommended to use an LTS Kernel version whenever possible; the NixOS default Kernel is generally suitable. See [[Linux kernel|Linux Kernel]] for more information about configuring a specific Kernel version.


Newer Kernels might not be supported by ZFS yet. If you are running a Kernel which is not officially supported by ZFS, the module will refuse to evaluate and show an error. With that being said, NixOS does support a number of Kernel versions that are compatible with ZFS, and while it is important to understand these details on compatibility, they should not be taken as a deterrent from using ZFS on NixOS.  
If your config specifies a Kernel version that is not officially supported by upstream ZFS, the ZFS module will fail to evaluate with an error that the ZFS package is "broken".  


You can pin to a newer Kernel version explicitly, but note that this version may be dropped by upstream and in Nixpkgs prior to ZFS supporting the next version. See [[Linux kernel|Linux Kernel]] for more information, including which Kernel versions Nixpkgs provides.
===== Selecting the latest ZFS-compatible Kernel =====
 
{{Warning|This will often result in the Kernel version going backwards as Kernel versions become end-of-life and are removed from Nixpkgs. If you need more control over the Kernel version due to hardware requirements, consider simply pinning a specific version rather than calculating it as below.}}
Some basic examples of pinning the Kernel:
To use the latest ZFS-compatible Kernel currently available, the following configuration may be used.  
 
<syntaxhighlight lang="nix">
{
  boot.kernelPackages = pkgs.linuxPackages_latest;
  # OR
  boot.kernelPackages = pkgs.linuxPackages_6_6;
}
</syntaxhighlight>
 
The following snippet will configure the latest compatible Kernel.
Note that over time, this can jump back to old Kernel versions because non-LTS Kernel versions are eventually dropped and their newer replacements might be not supported by ZFS yet.


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 56: Line 46:
}
}
</syntaxhighlight>
</syntaxhighlight>
===== Using unstable, pre-release ZFS =====
{{Warning|Pre-release ZFS versions may be less well-tested, and may have critical bugs that may cause data loss.}}
In some cases, a pre-release version of ZFS may be available that supports a newer Kernel. Use it with <code>boot.zfs.package = pkgs.zfs_unstable;</code>.


==== Partial support for swap on ZFS ====
==== Partial support for swap on ZFS ====