Skip to content
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

WIP: Log stage-{1,2} output to secondary consoles #42255

Closed

Conversation

dezgeg
Copy link
Contributor

@dezgeg dezgeg commented Jun 19, 2018

Currently, if you pass multiple consoles to the kernel (e.g.console=ttyS0 console=tty0) you only get stage-1 and stage-2 output on the primary console (the last one specified on the command line). This change redirects them to the secondary consoles as well.

systemd's output is still only on the primary console. Need to look into that next.

Do this instead of parsing the kernel command line as the default
console might not be the virtual console, e.g. on platforms using Device
Tree can indicate a preferred serial console with the
/chosen/stdout-path property.

This matches what dracut and Debian's initramfs-tools is doing.
Currently, if you pass multiple consoles to the kernel (e.g.
'console=ttyS0 console=tty0') you only get kernel's output to the
primary console (the one specified last) until the boot is finished
and a getty is launched on the secondary consoles.

Let's explicitly write all stage-1 and stage-2 output to the secondary
consoles just as we additionally write them to kmsg.
@samueldr
Copy link
Member

samueldr commented Jun 19, 2018

sed dependency can be dropped if desired; proof-of-concept:

#!/usr/bin/env nix-shell
#!nix-shell -p busybox -i ash --pure
# shellcheck shell=ash
list_consoles() {
        # shellcheck disable=2046
        for console in $(echo "tty1 ttyS0 not-kept"); do echo "$console" ; done | head -n-1
        #                ^ replace with cat /sys/class/tty/console/active
}
for c in $(list_consoles); do
        echo "Logging to $c"
done

This relies on word-splitting, why SC2046 was disabled

(An earlier revision was using set while it isn't necessary; I initially overengineered it!)

@danbst
Copy link
Contributor

danbst commented Jun 20, 2018

or even cat /sys/class/tty/console/active | tr -s \ \\n|head -n-1

@dezgeg
Copy link
Contributor Author

dezgeg commented Jun 20, 2018

Another approaches that might be worth trying instead of implementing this in shell scripts:

The advantage of these would be that they hook /dev/console itself, so systemd's output would also go to other consoles.

@Ekleog
Copy link
Member

Ekleog commented Nov 8, 2018

(triage) @dezgeg If I read correctly, this is already working except it doesn't encompass the systemd output yet.

If so, maybe it'd make sense to merge this first, and when you find time to come back to systemd's output, do this one?

@mmahut
Copy link
Member

mmahut commented Aug 25, 2019

Are there any updates on this pull request, please?

@stale
Copy link

stale bot commented Jun 1, 2020

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 1, 2020
@ryantm ryantm marked this pull request as draft October 23, 2020 03:13
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 23, 2020
@samueldr samueldr mentioned this pull request May 14, 2021
13 tasks
samueldr added a commit to samueldr/nixpkgs that referenced this pull request May 14, 2021
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.
@stale
Copy link

stale bot commented Jul 21, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 21, 2021
@Artturin Artturin closed this May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants