ZFS: Difference between revisions

imported>VincentVanlaer
(Auto ZFS trimming: clarify that this doesn't refer to the autotrim property)
imported>SuperSandro2000
(Improve wording, fix ref links)
Line 1: Line 1:
[https://zfsonlinux.org/ {{PAGENAME}}] ([[wikipedia:en:{{PAGENAME}}]]) - also known as [https://openzfs.org/ OpenZFS] ([[wikipedia:en:OpenZFS]]) - is modern filesystem. It is (very well) supported on [[NixOS]].
[https://zfsonlinux.org/ {{PAGENAME}}] ([[wikipedia:en:{{PAGENAME}}]]) - also known as [https://openzfs.org/ OpenZFS] ([[wikipedia:en:OpenZFS]]) - is modern filesystem which is well supported on [[NixOS]].


There are a lot of packages for [[{{PAGENAME}}]]. For example there is the ''zfs'' package (''ZFS Filesystem Linux Kernel module'') itself.<ref>https://search.nixos.org/packages?channel=unstable&show=zfs&query=zfs</ref> But there are also a lot of packages of the [[{{PAGENAME}}]] ecosystem available.
There are a lot of packages for [[{{PAGENAME}}]]. For example there is the ''zfs'' package (''ZFS Filesystem Linux Kernel module'') itself.<ref>https://search.nixos.org/packages?channel=unstable&show=zfs&query=zfs</ref> But there are also a lot of packages of the [[{{PAGENAME}}]] ecosystem available.


[[{{PAGENAME}}]] is also [[module|modularized]] very well. For example it is available for ''boot''<ref>https://search.nixos.org/options?channel=unstable&query=boot.zfs]</ref> and as a ''service''<ref>https://search.nixos.org/options?channel=unstable&query=services.zfs]</ref>.
[[{{PAGENAME}}]] is also [[module|modularized]] very well. For example it is available for ''boot''<ref>https://search.nixos.org/options?channel=unstable&query=boot.zfs</ref> and as a ''service''<ref>https://search.nixos.org/options?channel=unstable&query=services.zfs</ref>.


== Limitations ==
== Limitations ==
Line 9: Line 9:
==== latestCompatibleLinuxPackages of ZFS for boot.kernelPackages ====
==== latestCompatibleLinuxPackages of ZFS for boot.kernelPackages ====


Newest kernels might not be supported by ZFS yet. If you are running an newer kernel which is not yet officially supported by zfs, the zfs module will refuse to evaluate and show up as ''broken''.  Use <code>boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;</code>
Newest kernels might not be supported by ZFS yet. If you are running an newer kernel which is not yet officially supported by zfs, the zfs module will refuse to evaluate and show up as ''broken''.  Use <code>boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;</code> to use the latest compatible kernel.


==== missing support for SWAP on ZFS ====
==== missing support for SWAP on ZFS ====


ZFS does not support swap. Hibernation must be either disabled with <code><nowiki>boot.kernelParams = [ "nohibernate" ];</nowiki></code>, or enabled with a separate, non-ZFS swap partition.
ZFS does not support swapfiles. Hibernation must be either disabled with <code><nowiki>boot.kernelParams = [ "nohibernate" ];</nowiki></code>, or be enabled with a separate, non-ZFS swap partition.


==== boot.zfs.devNodes in virtual machines ====
==== boot.zfs.devNodes in virtual machines ====
Line 21: Line 21:
==== declarative mounting of ZFS datasets ====
==== declarative mounting of ZFS datasets ====


* If possible, use legacy mountpoints <code>zfs create -o mountpoint=legacy</code> and declare mountpoints with <code>fileSystems."/mount/point" = {};</code>. ZFS native mountpoints are not managed as part of the system state. This can lead to conflicts if ZFS mount service is also enabled for the same datasets. Disable it with <code>systemd.services.zfs-mount.enable = false;</code>.
When using legacy mountpoints (created with eg<code>zfs create -o mountpoint=legacy</code>) mountpoints must be specified with <code>fileSystems."/mount/point" = {};</code>. ZFS native mountpoints are not managed as part of the system configuration but better support hibernation with a separate swap partition. This can lead to conflicts if ZFS mount service is also enabled for the same datasets. Disable it with <code>systemd.services.zfs-mount.enable = false;</code>.


== Guides ==
== Guides ==
Line 27: Line 27:
; OpenZFS Documentation for installing:
; OpenZFS Documentation for installing:


A guide for common ZFS installation is maintained as [https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/ OpenZFS Documentation (''Getting Started'' for ''NixOS'')].
A guide for a NixOS installation with ZFS is maintained at [https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/ OpenZFS Documentation (''Getting Started'' for ''NixOS'')]


It is about
It is about:
* [https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/index.html#installation enabling ZFS on an existing NixOS installation] and
* [https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/index.html#installation enabling ZFS on an existing NixOS installation] and
* [https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/#root-on-zfs (installing NixOS with) Root on ZFS].
* [https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/#root-on-zfs (installing NixOS with) Root on ZFS].
It is not about:
* integrating ZFS into your existing config


If an issue arises for this guide, submit an issue or pull request there.
If an issue arises for this guide, submit an issue or pull request there.