Make stage-1/2 logging unconditional, and drop log level to "debug"

Using "debug" level prevents spamming the console with messages twice
(once directly and once via kmsg).

+33 -53
+17 -17
nixos/modules/system/boot/stage-1-init.sh
··· 71 mkdir -p /run 72 mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run 73 74 - # 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 92 93 # Process the kernel command line. 94 export stage2Init=/init
··· 71 mkdir -p /run 72 mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run 73 74 + 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 & 89 fi 90 + exec > /tmp/stage-1-init.log.fifo 2>&1 91 + 92 93 # Process the kernel command line. 94 export stage2Init=/init
+2 -10
nixos/modules/system/boot/stage-1.nix
··· 200 201 inherit (config.boot) resumeDevice devSize runSize; 202 203 - inherit (config.boot.initrd) checkJournalingFS 204 - logCommands preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules; 205 206 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
··· 200 201 inherit (config.boot) resumeDevice devSize runSize; 202 203 + inherit (config.boot.initrd) checkJournalingFS 204 + preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules; 205 206 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
+13 -17
nixos/modules/system/boot/stage-2-init.sh
··· 157 158 # 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 172 fi 173 174 ··· 199 @shell@ @postBootCommands@ 200 201 202 - # Reset the logging file descriptors 203 - if test -n "@logCommands@"; then 204 - exec 1>&$logOutFd 2>&$logErrFd 205 - exec {logOutFd}>&- {logErrFd}>&- 206 - fi 207 208 209 # Start systemd.
··· 157 158 # 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 170 fi 171 172 ··· 197 @shell@ @postBootCommands@ 198 199 200 + # Reset the logging file descriptors. 201 + exec 1>&$logOutFd 2>&$logErrFd 202 + exec {logOutFd}>&- {logErrFd}>&- 203 204 205 # Start systemd.
+1 -9
nixos/modules/system/boot/stage-2.nix
··· 17 src = ./stage-2-init.sh; 18 shellDebug = "${pkgs.bashInteractive}/bin/bash"; 19 isExecutable = true; 20 - inherit (config.boot) logCommands devShmSize runSize; 21 inherit (config.nix) readOnlyStore; 22 inherit (config.networking) useHostResolvConf; 23 ttyGid = config.ids.gids.tty; ··· 39 options = { 40 41 boot = { 42 - 43 - logCommands = mkOption { 44 - default = false; 45 - type = types.bool; 46 - description = '' 47 - Whether to replicate command output of stage-1 booting to <filename>/dev/kmsg</filename> or <filename>/run/log/stage-2-init.log</filename> if <filename>/dev/kmsg</filename> is not writable. 48 - ''; 49 - }; 50 51 postBootCommands = mkOption { 52 default = "";
··· 17 src = ./stage-2-init.sh; 18 shellDebug = "${pkgs.bashInteractive}/bin/bash"; 19 isExecutable = true; 20 + inherit (config.boot) devShmSize runSize; 21 inherit (config.nix) readOnlyStore; 22 inherit (config.networking) useHostResolvConf; 23 ttyGid = config.ids.gids.tty; ··· 39 options = { 40 41 boot = { 42 43 postBootCommands = mkOption { 44 default = "";