|
|
(10 intermediate revisions by one other user not shown) |
Line 1: |
Line 1: |
| This is a userspace draft and is not supported by NixOS Wiki.
| | Moved to here: |
| | https://openzfs.github.io/openzfs-docs/Getting%20Started/NixOS/Root%20on%20ZFS.html |
|
| |
|
| == Enable ZFS on Existing Installation ==
| | Last version is: https://wiki.nixos.org/w/index.php?title=User:2r/NixOS_on_ZFS&oldid=5406 |
| Add the following lines to configuration:
| |
| <pre>boot.supportedFilesystems = [ "zfs" ];
| |
| networking.hostId = "deadbeef";</pre>
| |
| Host ID should be unique, generate one with <code>head -c 8 /etc/machine-id</code>.
| |
| | |
| Rebuild system with <code>nixos-rebuild switch</code>.
| |
| | |
| == Install NixOS on ZFS ==
| |
| === Layout ===
| |
| ==== Partitions ====
| |
| As swap on ZFS will cause deadlock and does not support hibernation, a separate swap partition should be created.
| |
| | |
| GRUB supports decrypting LUKS1 container and limited ZFS features, a separate, feature limited boot pool is created for compatibility.
| |
| {| class="wikitable"
| |
| |+ GPT partition table
| |
| |-
| |
| |
| |
| | ESP
| |
| | bpool
| |
| | rpool
| |
| | swap
| |
| | BIOS boot sector
| |
| |-
| |
| |width=5% valign=top| Filesystem
| |
| |width=20% valign=top| vfat
| |
| |width=20% valign=top| ZFS, feature limited for GRUB compatibility.
| |
| |width=20% valign=top| ZFS
| |
| |width=20% valign=top| swap
| |
| |width=5% valign=top| N/A
| |
| |-
| |
| |width=5% valign=top| Content
| |
| |width=20% valign=top| <code>grubx64.efi</code>
| |
| |width=20% valign=top| <code>/boot</code>
| |
| |width=20% valign=top| <code>/</code>
| |
| |width=20% valign=top| swap
| |
| |width=5% valign=top| N/A
| |
| |-
| |
| |width=5% valign=top| Encryption
| |
| |width=20% valign=top| No, can be validated with Secure Boot
| |
| |width=20% valign=top| LUKS1
| |
| |width=20% valign=top| ZFS Encrytion
| |
| |width=20% valign=top| random/LUKS2
| |
| |width=5% valign=top| N/A
| |
| |}
| |
| ==== Datasets ====
| |
| As NixOS lacks a service to handle native ZFS mounting at boot, such as <code>zfs-mount-generator</code>, all mountable datasets must be created with <code>mountpoint=legacy</code> to be mounted with <code>fileSystems</code> option.
| |
| | |
| Datasets with <code>canmount=off</code> are used as containers, that is, no data is stored directly under such datasets, but child datasets can inherit their properties or imitate directory structures, such as <code>/var/log</code>.
| |
| | |
| When creating pools, a default dataset with the same name as the pool name is also created.
| |
| {| class="wikitable"
| |
| |+ Dataset layout
| |
| |colspan="3"|<code>canmount=off</code>
| |
| |<code>canmount=noauto</code>
| |
| |-
| |
| | bpool
| |
| | sys
| |
| | BOOT
| |
| | default
| |
| |-
| |
| |rowspan="2"| rpool
| |
| |rowspan="2"| sys
| |
| | ROOT
| |
| | default
| |
| |-
| |
| | DATA
| |
| | default
| |
| |}
| |