-
-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stage-1: Log to secondary consoles #123039
Conversation
This obsoletes NixOS#42255. bootlogd is both a console multiplexer, and console logger. This allows us to drop the fiddly redirecting we were doing in shell script, and ensures each console= parameters on the kernel command-line gets the stage-1 output. This also gives us *way earlier* stage-1 logging than before.
This verifies: - That the very first output is logged - That logging to /dev/kmsg works
54154d4
to
d9ab0c7
Compare
It might be useful to print a message like I'm anxious about merging this in before 21.05 branchoff so soon to cutoff, but would be +1 on the next release. |
The stage-1 sh script could loop on |
|
||
# `-f true` to force bootlogd to fork itself. bootlogd will only fork once it's ready to consume logs. Otherwise it could skip the first few lines. | ||
# `-p` ensures required mount points are mounted. | ||
# `-l` logs to /dev/kmsg too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# `-l` logs to /dev/kmsg too | |
# `-k` logs to /dev/kmsg too |
I marked this as stale due to inactivity. → More info |
Closing in favour of systemd's stage-1 infra, which I assume intrinsically supports console multiplexing just like its stage-2 does. I won't get back to dealing with the complexity of this. |
Motivation for this change
The output from
init
will only be present on the last validconsole=
parameter from the kernel command-line.This is extremely inconvenient, when not harmful, for generic images. On many ARM platforms the serial console names differ, so there is no absolute truthful console name to use here. Additionally, this prevents logging to be shown on both the connected display, and the serial output at once.
With
bootlogd
, the output is redirected to allconsole=
parameters. It also replaces the ad-hoc logging to /run/log and the logging to /dev/kmsg.This way we should be able to get rid of one of the main annoyance with ARM platforms early boot debugging.
This has been used for a good while in Mobile NixOS.
Ideally we'd somehow do a system test that confirms it logs to multiple serial consoles, but I really don't know how we'd pull that off.
TODO
Input redirection
While opening this PR, I realized that this probably doesn't cover input during stage-1. Only the last
console=
would be usable as an input in that case. This is important forboot.debug1*
use cases, and also useful if only to answerr
to reboot the machine.We probably can, could, and should merge this even without this being handled, as it would already be a net improvement compared to the current situation.
Killing bootlogd
Right now I haven't handled it at all. It gets culled at
Kill any remaining processes
, which means it will be missing all messages up to systemd starting in stage-2.Should we:
@
?Then, we can add a late
boot.postBootCommands
which includes${pkgs.procps}/bin/pkill -x bootlogd
to kill it. Ideally order it to happen last before weexec
into systemd.What even is
bootlogd
??It's a minified part of
sysvinit
. The main core hasn't been touched by me. Really the main thing I did was delete thesysvinit
around it. Then I added features that helps either Mobile NixOS or NixOS in some ways.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)This closes #42255.