Skip to content

Commit 216d98a

Browse files
committed
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.
1 parent fbc97dc commit 216d98a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

nixos/modules/system/boot/systemd/initrd.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ in
481481
settings.Manager.DefaultEnvironment = "PATH=/bin:/sbin";
482482

483483
contents = {
484-
"/tmp/.keep".text = "systemd requires the /tmp mount point in the initrd cpio archive";
485484
"/init".source = "${cfg.package}/lib/systemd/systemd";
486485
"/etc/systemd/system".source = stage1Units;
487486

@@ -507,6 +506,8 @@ in
507506

508507
"/bin".source = "${initrdBinEnv}/bin";
509508
"/sbin".source = "${initrdBinEnv}/sbin";
509+
"/usr/bin".source = "${initrdBinEnv}/bin";
510+
"/usr/sbin".source = "${initrdBinEnv}/sbin";
510511

511512
"/etc/sysctl.d/nixos.conf".text = "kernel.modprobe = /sbin/modprobe";
512513
"/etc/modprobe.d/systemd.conf".source = "${cfg.package}/lib/modprobe.d/systemd.conf";

pkgs/build-support/kernel/make-initrd-ng.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ runCommand name
100100
++ lib.optional makeUInitrd ubootTools;
101101
})
102102
''
103-
mkdir -p ./root/var/empty
103+
mkdir -p ./root/{run,tmp,var/empty}
104+
ln -s ../run ./root/var/run
104105
make-initrd-ng "$contentsPath" ./root
105106
mkdir "$out"
106107
(cd root && find . -exec touch -h -d '@1' '{}' +)

0 commit comments

Comments
 (0)