I’m using the Impermanence module and ZFS to keep my root system clean. Both the persistent dataset, nix dataset and root dataset are all on the same zpool (system), with the root dataset being system/local/root, nix being system/local/nix and the persistent dataset being system/safe/persist.
Because of impermanence, the persist dataset has to be marked neededForBoot.
I have the roll back working and everything is behaving, except for one thing: during boot, the system hangs waiting for system-safe-persist.device for a 1:30 during stage 1 until it times out. This happens after the system zpool is imported and rolled back, but before the sysroot target, because after the sysroot target the system mounts system/safe/persist with no issue.
I am using systemd in my initrd, and the relevant snippets of my config are below… I’m not sure what is causing it to hang, as an identical NixOS config on a nearly identical zpool layout on another system was working without issue.
# Enable systemd in initrd
boot.initrd.systemd.enable = true;
# systemd in initrd requires a service instead of a command
boot.initrd.systemd.services.reset = {
description = "reset root filesystem";
wantedBy = [ "initrd.target" ];
after = [ "zfs-import-system.service" ];
before = [ "sysroot.mount" ];
path = with pkgs; [ zfs ];
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
script = "zfs rollback -r system/local/root@blank";
};
# All directories to save
environment.persistence."/persist" = {
enable = true; # NB: Defaults to true, not needed
hideMounts = true;
directories = [
"/etc/nixos"
"/var/log"
"/var/lib/nixos"
"/var/lib/systemd"
"/var/lib/resilio-sync"
"/var/lib/zerotier-one"
];
files = [
"/etc/machine-id"
"/etc/ssh/ssh_host_rsa_key"
"/etc/ssh/ssh_host_rsa_key.pub"
"/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub"
"/etc/zfs/zpool.cache"
];
};
fileSystems."/" = {
device = "system/local/root";
fsType = "zfs";
};
fileSystems."/nix" = {
device = "system/local/nix";
fsType = "zfs";
};
fileSystems."/home" = {
device = "system/safe/home";
fsType = "zfs";
};
fileSystems."/persist" = {
device = "system/safe/persist";
fsType = "zfs";
neededForBoot = true;
};
There is no logs from system-safe-persist.device other than the three lines about it starting, timing out and moving on, and it comes between importing the zpool, and entering sysroot, at which time the system mounts system/safe/persist without issue.
Trying to decrease the mount timeout with x-systemd.mount-timeout as an option in filesystems did nothing since at least it would boot faster, and I haven’t been able to find any dependencies or even the actual service file with systemctl.
Any help would be appreciated.