···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
7474+7575+# Optionally log the script output to /dev/kmsg or /run/log/stage-1-init.log.
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 "<7>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 &
9189fi
9090+exec > /tmp/stage-1-init.log.fifo 2>&1
9191+92929393# Process the kernel command line.
9494export stage2Init=/init
+2-10
nixos/modules/system/boot/stage-1.nix
···200200201201 inherit (config.boot) resumeDevice devSize runSize;
202202203203- inherit (config.boot.initrd) checkJournalingFS
204204- logCommands preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules;
203203+ inherit (config.boot.initrd) checkJournalingFS
204204+ 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.
277269 '';
278270 };
279271
+13-17
nixos/modules/system/boot/stage-2-init.sh
···157157158158# Optionally log the script output to /dev/kmsg or /run/log/stage-2-init.log.
159159# Only at this point are all the necessary prerequisites ready for these commands.
160160-if test -n "@logCommands@"; then
161161- exec {logOutFd}>&1 {logErrFd}>&2
162162- if test -w /dev/kmsg; then
163163- exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
164164- if test -n "$line"; then
165165- echo "stage-2-init: $line" > /dev/kmsg
166166- fi
167167- done) 2>&1
168168- else
169169- mkdir -p /run/log
170170- exec > >(tee -i /run/log/stage-2-init.log) 2>&1
171171- fi
160160+exec {logOutFd}>&1 {logErrFd}>&2
161161+if test -w /dev/kmsg; then
162162+ exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
163163+ if test -n "$line"; then
164164+ echo "<7>stage-2-init: $line" > /dev/kmsg
165165+ fi
166166+ done) 2>&1
167167+else
168168+ mkdir -p /run/log
169169+ exec > >(tee -i /run/log/stage-2-init.log) 2>&1
172170fi
173171174172···199197@shell@ @postBootCommands@
200198201199202202-# Reset the logging file descriptors
203203-if test -n "@logCommands@"; then
204204- exec 1>&$logOutFd 2>&$logErrFd
205205- exec {logOutFd}>&- {logErrFd}>&-
206206-fi
200200+# Reset the logging file descriptors.
201201+exec 1>&$logOutFd 2>&$logErrFd
202202+exec {logOutFd}>&- {logErrFd}>&-
207203208204209205# Start systemd.