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,24 +71,24 @@ mount -t devtmpfs -o "size=@devSize@" devtmpfs /dev
|
||||||
mkdir -p /run
|
mkdir -p /run
|
||||||
mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /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
|
mkdir -p /tmp
|
||||||
mkfifo /tmp/stage-1-init.log.fifo
|
mkfifo /tmp/stage-1-init.log.fifo
|
||||||
logOutFd=8 && logErrFd=9
|
logOutFd=8 && logErrFd=9
|
||||||
eval "exec $logOutFd>&1 $logErrFd>&2"
|
eval "exec $logOutFd>&1 $logErrFd>&2"
|
||||||
if test -w /dev/kmsg; then
|
if test -w /dev/kmsg; then
|
||||||
tee -i < /tmp/stage-1-init.log.fifo /proc/self/fd/"$logOutFd" | while read line; do
|
tee -i < /tmp/stage-1-init.log.fifo /proc/self/fd/"$logOutFd" | while read line; do
|
||||||
if test -n "$line"; then
|
if test -n "$line"; then
|
||||||
echo "stage-1-init: $line" > /dev/kmsg
|
echo "<7>stage-1-init: $line" > /dev/kmsg
|
||||||
fi
|
fi
|
||||||
done &
|
done &
|
||||||
else
|
else
|
||||||
mkdir -p /run/log
|
mkdir -p /run/log
|
||||||
tee -i < /tmp/stage-1-init.log.fifo /run/log/stage-1-init.log &
|
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
|
fi
|
||||||
|
exec > /tmp/stage-1-init.log.fifo 2>&1
|
||||||
|
|
||||||
|
|
||||||
# Process the kernel command line.
|
# Process the kernel command line.
|
||||||
export stage2Init=/init
|
export stage2Init=/init
|
||||||
|
|
|
@ -200,8 +200,8 @@ let
|
||||||
|
|
||||||
inherit (config.boot) resumeDevice devSize runSize;
|
inherit (config.boot) resumeDevice devSize runSize;
|
||||||
|
|
||||||
inherit (config.boot.initrd) checkJournalingFS
|
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}")
|
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);
|
(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 {
|
boot.initrd.prepend = mkOption {
|
||||||
default = [ ];
|
default = [ ];
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
|
|
|
@ -157,18 +157,16 @@ 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.
|
# 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.
|
# Only at this point are all the necessary prerequisites ready for these commands.
|
||||||
if test -n "@logCommands@"; then
|
exec {logOutFd}>&1 {logErrFd}>&2
|
||||||
exec {logOutFd}>&1 {logErrFd}>&2
|
if test -w /dev/kmsg; then
|
||||||
if test -w /dev/kmsg; then
|
exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
|
||||||
exec > >(tee -i /proc/self/fd/"$logOutFd" | while read line; do
|
if test -n "$line"; then
|
||||||
if test -n "$line"; then
|
echo "<7>stage-2-init: $line" > /dev/kmsg
|
||||||
echo "stage-2-init: $line" > /dev/kmsg
|
fi
|
||||||
fi
|
done) 2>&1
|
||||||
done) 2>&1
|
else
|
||||||
else
|
mkdir -p /run/log
|
||||||
mkdir -p /run/log
|
exec > >(tee -i /run/log/stage-2-init.log) 2>&1
|
||||||
exec > >(tee -i /run/log/stage-2-init.log) 2>&1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,11 +197,9 @@ ln -sfn /run/booted-system /nix/var/nix/gcroots/booted-system
|
||||||
@shell@ @postBootCommands@
|
@shell@ @postBootCommands@
|
||||||
|
|
||||||
|
|
||||||
# Reset the logging file descriptors
|
# Reset the logging file descriptors.
|
||||||
if test -n "@logCommands@"; then
|
exec 1>&$logOutFd 2>&$logErrFd
|
||||||
exec 1>&$logOutFd 2>&$logErrFd
|
exec {logOutFd}>&- {logErrFd}>&-
|
||||||
exec {logOutFd}>&- {logErrFd}>&-
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Start systemd.
|
# Start systemd.
|
||||||
|
|
|
@ -17,7 +17,7 @@ let
|
||||||
src = ./stage-2-init.sh;
|
src = ./stage-2-init.sh;
|
||||||
shellDebug = "${pkgs.bashInteractive}/bin/bash";
|
shellDebug = "${pkgs.bashInteractive}/bin/bash";
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
inherit (config.boot) logCommands devShmSize runSize;
|
inherit (config.boot) devShmSize runSize;
|
||||||
inherit (config.nix) readOnlyStore;
|
inherit (config.nix) readOnlyStore;
|
||||||
inherit (config.networking) useHostResolvConf;
|
inherit (config.networking) useHostResolvConf;
|
||||||
ttyGid = config.ids.gids.tty;
|
ttyGid = config.ids.gids.tty;
|
||||||
|
@ -40,14 +40,6 @@ in
|
||||||
|
|
||||||
boot = {
|
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 {
|
postBootCommands = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "rm -f /var/log/messages";
|
example = "rm -f /var/log/messages";
|
||||||
|
|
Loading…
Reference in New Issue