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).
This commit is contained in:
parent
6f6e2c430f
commit
deae4eff7b
|
@ -71,8 +71,8 @@ mount -t devtmpfs -o "size=@devSize@" devtmpfs /dev
|
|||
mkdir -p /run
|
||||
mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run
|
||||
|
||||
# Optionally log the script output to /dev/kmsg or /run/log/stage-1-init.log
|
||||
if test -n "@logCommands@"; then
|
||||
|
||||
# Optionally log the script output to /dev/kmsg or /run/log/stage-1-init.log.
|
||||
mkdir -p /tmp
|
||||
mkfifo /tmp/stage-1-init.log.fifo
|
||||
logOutFd=8 && logErrFd=9
|
||||
|
@ -80,7 +80,7 @@ if test -n "@logCommands@"; then
|
|||
if test -w /dev/kmsg; then
|
||||
tee -i < /tmp/stage-1-init.log.fifo /proc/self/fd/"$logOutFd" | while read line; do
|
||||
if test -n "$line"; then
|
||||
echo "stage-1-init: $line" > /dev/kmsg
|
||||
echo "<7>stage-1-init: $line" > /dev/kmsg
|
||||
fi
|
||||
done &
|
||||
else
|
||||
|
@ -88,7 +88,7 @@ if test -n "@logCommands@"; then
|
|||
tee -i < /tmp/stage-1-init.log.fifo /run/log/stage-1-init.log &
|
||||
fi
|
||||
exec > /tmp/stage-1-init.log.fifo 2>&1
|
||||
fi
|
||||
|
||||
|
||||
# Process the kernel command line.
|
||||
export stage2Init=/init
|
||||
|
|
|
@ -201,7 +201,7 @@ let
|
|||
inherit (config.boot) resumeDevice devSize runSize;
|
||||
|
||||
inherit (config.boot.initrd) checkJournalingFS
|
||||
logCommands preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules;
|
||||
preLVMCommands preDeviceCommands postDeviceCommands postMountCommands kernelModules;
|
||||
|
||||
resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
|
||||
(filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices);
|
||||
|
@ -269,14 +269,6 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
boot.initrd.logCommands = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
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.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.prepend = mkOption {
|
||||
default = [ ];
|
||||
type = types.listOf types.str;
|
||||
|
|
|
@ -157,19 +157,17 @@ mount -t tmpfs -o "mode=0755" tmpfs /var/setuid-wrappers
|
|||
|
||||
# Optionally log the script output to /dev/kmsg or /run/log/stage-2-init.log.
|
||||
# Only at this point are all the necessary prerequisites ready for these commands.
|
||||
if test -n "@logCommands@"; then
|
||||
exec {logOutFd}>&1 {logErrFd}>&2
|
||||
if test -w /dev/kmsg; then
|
||||
exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
|
||||
if test -n "$line"; then
|
||||
echo "stage-2-init: $line" > /dev/kmsg
|
||||
echo "<7>stage-2-init: $line" > /dev/kmsg
|
||||
fi
|
||||
done) 2>&1
|
||||
else
|
||||
mkdir -p /run/log
|
||||
exec > >(tee -i /run/log/stage-2-init.log) 2>&1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Run the script that performs all configuration activation that does
|
||||
|
@ -199,11 +197,9 @@ ln -sfn /run/booted-system /nix/var/nix/gcroots/booted-system
|
|||
@shell@ @postBootCommands@
|
||||
|
||||
|
||||
# Reset the logging file descriptors
|
||||
if test -n "@logCommands@"; then
|
||||
# Reset the logging file descriptors.
|
||||
exec 1>&$logOutFd 2>&$logErrFd
|
||||
exec {logOutFd}>&- {logErrFd}>&-
|
||||
fi
|
||||
|
||||
|
||||
# Start systemd.
|
||||
|
|
|
@ -17,7 +17,7 @@ let
|
|||
src = ./stage-2-init.sh;
|
||||
shellDebug = "${pkgs.bashInteractive}/bin/bash";
|
||||
isExecutable = true;
|
||||
inherit (config.boot) logCommands devShmSize runSize;
|
||||
inherit (config.boot) devShmSize runSize;
|
||||
inherit (config.nix) readOnlyStore;
|
||||
inherit (config.networking) useHostResolvConf;
|
||||
ttyGid = config.ids.gids.tty;
|
||||
|
@ -40,14 +40,6 @@ in
|
|||
|
||||
boot = {
|
||||
|
||||
logCommands = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
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.
|
||||
'';
|
||||
};
|
||||
|
||||
postBootCommands = mkOption {
|
||||
default = "";
|
||||
example = "rm -f /var/log/messages";
|
||||
|
|
Loading…
Reference in New Issue