setup ZFS services again

This commit is contained in:
Christoph Cullmann 2024-10-03 11:17:39 +02:00
parent 8b1d9e4b0a
commit 35987b0c29
No known key found for this signature in database

View file

@ -25,16 +25,37 @@ in
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?
# use the latest kernel with ZFS support and enable that file system
boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages;
# enable ZFS
boot.supportedFilesystems = [ "zfs" ];
# my kernel parameters
boot.kernelParams = [
# no hibernate for ZFS systems
"nohibernate"
# don't check for split locks, for KVM and Co.
"split_lock_detect=off"
];
# tweak ZFS
boot.extraModprobeConfig = ''
options zfs zfs_arc_meta_limit_percent=75
options zfs zfs_arc_min=134217728
options zfs zfs_arc_max=4294967296
options zfs zfs_txg_timeout=30
options zfs zfs_vdev_scrub_min_active=1
options zfs zfs_vdev_scrub_max_active=1
options zfs zfs_vdev_sync_write_min_active=8
options zfs zfs_vdev_sync_write_max_active=32
options zfs zfs_vdev_sync_read_min_active=8
options zfs zfs_vdev_sync_read_max_active=32
options zfs zfs_vdev_async_read_min_active=8
options zfs zfs_vdev_async_read_max_active=32
options zfs zfs_vdev_async_write_min_active=8
options zfs zfs_vdev_async_write_max_active=32
options zfs zfs_vdev_def_queue_depth=128
'';
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
@ -136,6 +157,15 @@ in
# kill the tmp content on reboots, we mount that to /nix/persistent to avoid memory fill-up
boot.tmp.cleanOnBoot = true;
# ensure our data is not rotting
services.zfs.autoScrub = {
enable = true;
interval = "weekly";
};
# trim the stuff, we use SSDs
services.zfs.trim.enable = true;
# enable fast dbus
services.dbus.implementation = "broker";
@ -490,6 +520,25 @@ in
mode = "0400";
};
# send mails on ZFS events
services.zfs.zed = {
settings = {
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
ZED_EMAIL_ADDR = [ "root" ];
ZED_EMAIL_PROG = "/run/wrappers/bin/sendmail";
ZED_EMAIL_OPTS = "@ADDRESS@";
ZED_NOTIFY_INTERVAL_SECS = 3600;
ZED_NOTIFY_VERBOSE = true;
ZED_USE_ENCLOSURE_LEDS = true;
ZED_SCRUB_AFTER_RESILVER = true;
};
# this option does not work; will return error
enableMail = false;
};
# use ZSH per default
programs.zsh.enable = true;
environment.shells = with pkgs; [ zsh ];