55 lines
1.7 KiB
Org Mode
55 lines
1.7 KiB
Org Mode
:PROPERTIES:
|
|
:ID: 20231129T105148.214325
|
|
:END:
|
|
#+TITLE: Basic ZFS Configuration
|
|
|
|
#+AUTO_TANGLE: t
|
|
#+ARCOLOGY_KEY: cce/zfs
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
|
|
#+ARROYO_NIXOS_MODULE: nixos/zfs.nix
|
|
#+ARROYO_SYSTEM_EXCLUDE: waterboy
|
|
#+ARROYO_SYSTEM_EXCLUDE: droid
|
|
|
|
This stuff is pretty straightforward. I set up automatic snapshots, and SSD TRIM and scrubbing:
|
|
|
|
#+begin_src nix :tangle ~/arroyo-nix/nixos/zfs.nix
|
|
{ pkgs, lib, ... }:
|
|
|
|
{
|
|
boot.zfs.devNodes = "/dev/mapper"; # (ref:devNodes)
|
|
boot.zfs.forceImportRoot = false;
|
|
boot.zfs.forceImportAll = false;
|
|
|
|
# i wonder how much disk this will eat up
|
|
services.zfs.autoSnapshot = {
|
|
enable = true;
|
|
daily = 2;
|
|
weekly = 2;
|
|
monthly = 3;
|
|
};
|
|
services.zfs.trim.enable = true;
|
|
services.zfs.autoScrub.enable = true;
|
|
|
|
imports = [ ./zfs-snapshot-activation.nix ];
|
|
}
|
|
#+end_src
|
|
|
|
everyone I've seen talk about this sort of just says "oh =boot.zfs.devNodes= is a thing you do to make virtualization disks work" or whatever, but [[(devNodes)]] instructs ZFS to load the underlying physical devices out of =/dev/mapper= which is where LUKS volumes unvaulted with =cryptsetup luksOpen= will end up.
|
|
|
|
* Snapshot ZFS volumes when you activate a nixos generation:
|
|
|
|
#+begin_src nix :tangle ~/arroyo-nix/nixos/zfs-snapshot-activation.nix
|
|
{ config, pkgs, ... }:
|
|
|
|
with pkgs; let
|
|
mkSnapshotCommand = fsName: fsAttrs: "${config.boot.zfs.package}/bin/zfs snapshot ${fsAttrs.device}@${config.system.nixos.label}-$(date +%s) \n";
|
|
|
|
eligibleFs = lib.filterAttrs (name: attrs: attrs.fsType == "zfs") config.fileSystems;
|
|
snapshotCommands = lib.mapAttrsToList mkSnapshotCommand eligibleFs;
|
|
in {
|
|
system.activationScripts.zfs-snapshot.text = lib.concatStrings snapshotCommands;
|
|
}
|
|
#+end_src
|
|
|