···7171mkdir -p /run
7272mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run
73737474+# Optionally log the script output to /dev/kmsg or /run/log/stage-1-init.log
7575+if test -n "@logCommands@"; then
7676+ mkdir -p /tmp
7777+ mkfifo /tmp/stage-1-init.log.fifo
7878+ logOutFd=8 && logErrFd=9
7979+ eval "exec $logOutFd>&1 $logErrFd>&2"
8080+ if test -w /dev/kmsg; then
8181+ tee -i < /tmp/stage-1-init.log.fifo /proc/self/fd/"$logOutFd" | while read line; do
8282+ if test -n "$line"; then
8383+ echo "stage-1-init: $line" > /dev/kmsg
8484+ fi
8585+ done &
8686+ else
8787+ mkdir -p /run/log
8888+ tee -i < /tmp/stage-1-init.log.fifo /run/log/stage-1-init.log &
8989+ fi
9090+ exec > /tmp/stage-1-init.log.fifo 2>&1
9191+fi
74927593# Process the kernel command line.
7694export stage2Init=/init
···414432415433# Stop udevd.
416434udevadm control --exit
435435+436436+# Reset the logging file descriptors.
437437+# Do this just before pkill, which will kill the tee process.
438438+if test -n "@logCommands@"
439439+then
440440+ exec 1>&$logOutFd 2>&$logErrFd
441441+ eval "exec $logOutFd>&- $logErrFd>&-"
442442+fi
417443418444# Kill any remaining processes, just to be sure we're not taking any
419445# with us into stage 2. But keep storage daemons like unionfs-fuse.
+10-2
nixos/modules/system/boot/stage-1.nix
···200200201201 inherit (config.boot) resumeDevice devSize runSize;
202202203203- inherit (config.boot.initrd) checkJournalingFS
204204- preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules;
203203+ inherit (config.boot.initrd) checkJournalingFS
204204+ logCommands preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules;
205205206206 resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
207207 (filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices);
···266266 Specify here the device where the file resides.
267267 You should also use <varname>boot.kernelParams</varname> to specify
268268 <literal><replaceable>resume_offset</replaceable></literal>.
269269+ '';
270270+ };
271271+272272+ boot.initrd.logCommands = mkOption {
273273+ default = false;
274274+ type = types.bool;
275275+ description = ''
276276+ Whether to replicate command output of stage-1 booting to <filename>/dev/kmsg</filename> or <filename>/run/log/stage-1-init.log</filename> if <filename>/dev/kmsg</filename> is not writable.
269277 '';
270278 };
271279