ZFS: Difference between revisions

imported>ThomasHertleif
m Fix zfs trim option "enabled" to "enable"
imported>Grahamc
Show an example pool layout which keeps /nix out of the hierarchy of /, and create a list of explicitly recommended dataset properties.
Line 144: Line 144:


== How to install NixOS on a ZFS root filesystem ==
== How to install NixOS on a ZFS root filesystem ==
=== Pool Layout Considerations ===
it is important to keep <code>/nix</code> and the rest of the filesystem in
different sections of the dataset hierarchy, like this:
<syntaxhighlight lang="console">
rpool/
      local/
            nix        mounted to /nix
      safe/
            root        mounted to /
            home        mounted to /home
            ...
</syntaxhighlight>
the name of `local` and `safe` can change, but them being peers
is important.
ZFS can take consistent and atomic snapshots recursively down a
dataset's hierarchy. Since Nix is good at being Nix, we almost
never want to take snapshots of <code>/nix</code> as well. Regular system
backups certainly shouldn't.
=== Dataset Properties ===
The following is a list of recommended dataset properties which have no drawbacks under regular uses:
* <code>compression=lz4</code>
* <code>xattr=sa</code> for Journald
* <code>acltype=posixacl</code> also for Journald
The following is a list of dataset properties which are often useful, but do have drawbacks:
* <code>atime=off</code> disables if a file's access time is updated when the file is read. This can result in significant performance gains, but might confuse some software like mailers.
==== Journald ====
Journald requires some properties for <code>journalctl</code> to work for non-root users. The dataset containing <code>/var/log/journal</code> (probably the <code>/</code> dataset for simple configurations) should be created with <code>xattr=sa</code> and <code>acltype=posixacl</code>.
For example:
<syntaxhighlight lang="console">
$ zpool create  -O xattr=sa -O acltype=posixacl rpool ...
</syntaxhighlight>
or:
<syntaxhighlight lang="console">
$ zfs create -o xattr=sa -o acltype=posixacl rpool/root
</syntaxhighlight>
If you have already created the dataset, these properties can be set later:
<syntaxhighlight lang="console">
$ zfs set xattr=sa acltype=posixacl rpool/root
</syntaxhighlight>


=== Single-disk ===
=== Single-disk ===