From 216d98ab97fbec49a213e4b5a6df0c6e771aef3d Mon Sep 17 00:00:00 2001 From: andre4ik3 Date: Mon, 11 Aug 2025 05:34:33 +0000 Subject: [PATCH] nixos/systemd-initrd: silence various warnings Silences 2 warning messages that appear when using the systemd initrd: 1. "System tainted (var-run-bad)": occurs because `/var/run` isn't a symlink to `/run`. Fixed by making /run and linking /var/run to it. 2. "Failed to make /usr a mountpoint": occurs because ProtectSystem defaults to true in the initrd, which makes systemd try to remount `/usr` as read-only, which doesn't exist in the initrd. Fixed by linking `/usr/bin` and `/usr/sbin` to the initrd bin directories. Also moves the `/tmp` creation from the initrd module to make-initrd-ng, to avoid making an unnecessary `/tmp/.keep`, saving a store path and a few bytes in the initrd image. --- nixos/modules/system/boot/systemd/initrd.nix | 3 ++- pkgs/build-support/kernel/make-initrd-ng.nix | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index c2b1b1ab005c..ffce5e7e0dfa 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -481,7 +481,6 @@ in settings.Manager.DefaultEnvironment = "PATH=/bin:/sbin"; contents = { - "/tmp/.keep".text = "systemd requires the /tmp mount point in the initrd cpio archive"; "/init".source = "${cfg.package}/lib/systemd/systemd"; "/etc/systemd/system".source = stage1Units; @@ -507,6 +506,8 @@ in "/bin".source = "${initrdBinEnv}/bin"; "/sbin".source = "${initrdBinEnv}/sbin"; + "/usr/bin".source = "${initrdBinEnv}/bin"; + "/usr/sbin".source = "${initrdBinEnv}/sbin"; "/etc/sysctl.d/nixos.conf".text = "kernel.modprobe = /sbin/modprobe"; "/etc/modprobe.d/systemd.conf".source = "${cfg.package}/lib/modprobe.d/systemd.conf"; diff --git a/pkgs/build-support/kernel/make-initrd-ng.nix b/pkgs/build-support/kernel/make-initrd-ng.nix index b5cfc55c695e..35fd66e89db7 100644 --- a/pkgs/build-support/kernel/make-initrd-ng.nix +++ b/pkgs/build-support/kernel/make-initrd-ng.nix @@ -100,7 +100,8 @@ runCommand name ++ lib.optional makeUInitrd ubootTools; }) '' - mkdir -p ./root/var/empty + mkdir -p ./root/{run,tmp,var/empty} + ln -s ../run ./root/var/run make-initrd-ng "$contentsPath" ./root mkdir "$out" (cd root && find . -exec touch -h -d '@1' '{}' +)