root on ZFS Install

In order to import a ZFS pool, ZFS must be enabled in the NixOS configuration file.

Make sure zfs is in boot.supportedFilesystems.

{ config, pkgs, ... }:

{
  imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-graphical-kde.nix> ];
  boot.supportedFilesystems = [ "zfs" ];
}

Rebuild NixOS and switch to the new configuration.

nixos-rebuild switch

Check zfs is working,modprobe zfs should show no problems.

ZFS should now work.

Pool

Create a new pool or mount an existing pool.

Creating a pool

Create a pool using the disk ID and set it to 4k block size as default with ashift=12.

ls -la /dev/disk/by-id/
zpool create -f -o ashift=12 vault /dev/disk/by-id/${DISKS}

Export the pool after creation.

Using an Existing pool

The existing pool assigning it to be relative to /mnt with -R, the -N flag will tell ZFS not to mount any datasets.

Setup Datasets

Mount all datasets partitions to /mnt.

Filesystem

Setup datasets. Set all legacy.

Mount Datasets

Mount the datasets:

Boot

Create a 512M esp, mount to /boot

Format boot and mount.

Swap

Create a partition of desired size.

Enable swap.

Install

Setup config in /mnt/etc/nixos and install.

Last updated