···71mkdir -p /run
72mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run
730000000000000000007475# Process the kernel command line.
76export stage2Init=/init
···414415# Stop udevd.
416udevadm control --exit
00000000417418# Kill any remaining processes, just to be sure we're not taking any
419# with us into stage 2. But keep storage daemons like unionfs-fuse.
···71mkdir -p /run
72mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run
7374+# Optionally log the script output to /dev/kmsg or /run/log/stage-1-init.log
75+if test -n "@logCommands@"; then
76+ mkdir -p /tmp
77+ mkfifo /tmp/stage-1-init.log.fifo
78+ logOutFd=8 && logErrFd=9
79+ eval "exec $logOutFd>&1 $logErrFd>&2"
80+ if test -w /dev/kmsg; then
81+ tee -i < /tmp/stage-1-init.log.fifo /proc/self/fd/"$logOutFd" | while read line; do
82+ if test -n "$line"; then
83+ echo "stage-1-init: $line" > /dev/kmsg
84+ fi
85+ done &
86+ else
87+ mkdir -p /run/log
88+ tee -i < /tmp/stage-1-init.log.fifo /run/log/stage-1-init.log &
89+ fi
90+ exec > /tmp/stage-1-init.log.fifo 2>&1
91+fi
9293# Process the kernel command line.
94export stage2Init=/init
···432433# Stop udevd.
434udevadm control --exit
435+436+# Reset the logging file descriptors.
437+# Do this just before pkill, which will kill the tee process.
438+if test -n "@logCommands@"
439+then
440+ exec 1>&$logOutFd 2>&$logErrFd
441+ eval "exec $logOutFd>&- $logErrFd>&-"
442+fi
443444# Kill any remaining processes, just to be sure we're not taking any
445# with us into stage 2. But keep storage daemons like unionfs-fuse.
+10-2
nixos/modules/system/boot/stage-1.nix
···200201 inherit (config.boot) resumeDevice devSize runSize;
202203- inherit (config.boot.initrd) checkJournalingFS
204- preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules;
205206 resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
207 (filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices);
···266 Specify here the device where the file resides.
267 You should also use <varname>boot.kernelParams</varname> to specify
268 <literal><replaceable>resume_offset</replaceable></literal>.
00000000269 '';
270 };
271
···200201 inherit (config.boot) resumeDevice devSize runSize;
202203+ inherit (config.boot.initrd) checkJournalingFS
204+ logCommands preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules;
205206 resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
207 (filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices);
···266 Specify here the device where the file resides.
267 You should also use <varname>boot.kernelParams</varname> to specify
268 <literal><replaceable>resume_offset</replaceable></literal>.
269+ '';
270+ };
271+272+ boot.initrd.logCommands = mkOption {
273+ default = false;
274+ type = types.bool;
275+ description = ''
276+ 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.
277 '';
278 };
279