From 3e3e763a075cea09e6db7a4ec51aa0e90435f2fe Mon Sep 17 00:00:00 2001 From: hyperfekt Date: Wed, 2 Dec 2020 00:54:35 +0100 Subject: [PATCH] nixos/systemd: enable systemd-pstore.service As described in issue #81138, the Install section of upstream units is currently ignored, so we make it part of the sysinit.target manually. --- nixos/doc/manual/release-notes/rl-2105.xml | 6 ++++++ nixos/modules/profiles/installation-device.nix | 8 ++++++++ nixos/modules/system/boot/systemd.nix | 2 ++ 3 files changed, 16 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2105.xml b/nixos/doc/manual/release-notes/rl-2105.xml index 924fe7ae038e..d767b8ba74b1 100644 --- a/nixos/doc/manual/release-notes/rl-2105.xml +++ b/nixos/doc/manual/release-notes/rl-2105.xml @@ -1035,6 +1035,12 @@ environment.systemPackages = [ + + + The newly enabled systemd-pstore.service now automatically evacuates crashdumps and panic logs from the persistent storage to /var/lib/systemd/pstore. + This prevents NVRAM from filling up, which ensures the latest diagnostic data is always stored and alleviates problems with writing new boot configurations. + + diff --git a/nixos/modules/profiles/installation-device.nix b/nixos/modules/profiles/installation-device.nix index 7dc493fb495d..8e3aa20daa65 100644 --- a/nixos/modules/profiles/installation-device.nix +++ b/nixos/modules/profiles/installation-device.nix @@ -99,5 +99,13 @@ with lib; # because we have the firewall enabled. This makes installs from the # console less cumbersome if the machine has a public IP. networking.firewall.logRefusedConnections = mkDefault false; + + # Prevent installation media from evacuating persistent storage, as their + # var directory is not persistent and it would thus result in deletion of + # those entries. + environment.etc."systemd/pstore.conf".text = '' + [PStore] + Unlink=no + ''; }; } diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index d4ae4c93468f..6be7b7e6846c 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -90,6 +90,7 @@ let "systemd-fsck@.service" "systemd-fsck-root.service" "systemd-remount-fs.service" + "systemd-pstore.service" "local-fs.target" "local-fs-pre.target" "remote-fs.target" @@ -1183,6 +1184,7 @@ in systemd.targets.remote-fs.unitConfig.X-StopOnReconfiguration = true; systemd.targets.network-online.wantedBy = [ "multi-user.target" ]; systemd.services.systemd-importd.environment = proxy_env; + systemd.services.systemd-pstore.wantedBy = [ "sysinit.target" ]; # see #81138 # Don't bother with certain units in containers. systemd.services.systemd-remount-fs.unitConfig.ConditionVirtualization = "!container";