···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
91fi
009293# Process the kernel command line.
94export stage2Init=/init
···71mkdir -p /run
72mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run
7374+75+# Optionally log the script output to /dev/kmsg or /run/log/stage-1-init.log.
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 "<7>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 &
0089fi
90+exec > /tmp/stage-1-init.log.fifo 2>&1
91+9293# Process the kernel command line.
94export stage2Init=/init
+2-10
nixos/modules/system/boot/stage-1.nix
···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
···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
+13-17
nixos/modules/system/boot/stage-2-init.sh
···157158# Optionally log the script output to /dev/kmsg or /run/log/stage-2-init.log.
159# Only at this point are all the necessary prerequisites ready for these commands.
160-if test -n "@logCommands@"; then
161- exec {logOutFd}>&1 {logErrFd}>&2
162- if test -w /dev/kmsg; then
163- exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
164- if test -n "$line"; then
165- echo "stage-2-init: $line" > /dev/kmsg
166- fi
167- done) 2>&1
168- else
169- mkdir -p /run/log
170- exec > >(tee -i /run/log/stage-2-init.log) 2>&1
171- fi
172fi
173174···199@shell@ @postBootCommands@
200201202-# Reset the logging file descriptors
203-if test -n "@logCommands@"; then
204- exec 1>&$logOutFd 2>&$logErrFd
205- exec {logOutFd}>&- {logErrFd}>&-
206-fi
207208209# Start systemd.
···157158# Optionally log the script output to /dev/kmsg or /run/log/stage-2-init.log.
159# Only at this point are all the necessary prerequisites ready for these commands.
160+exec {logOutFd}>&1 {logErrFd}>&2
161+if test -w /dev/kmsg; then
162+ exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
163+ if test -n "$line"; then
164+ echo "<7>stage-2-init: $line" > /dev/kmsg
165+ fi
166+ done) 2>&1
167+else
168+ mkdir -p /run/log
169+ exec > >(tee -i /run/log/stage-2-init.log) 2>&1
00170fi
171172···197@shell@ @postBootCommands@
198199200+# Reset the logging file descriptors.
201+exec 1>&$logOutFd 2>&$logErrFd
202+exec {logOutFd}>&- {logErrFd}>&-
00203204205# Start systemd.