Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 473128 - sys-kernel/genkernel-3.4.47 does not output to serial console
Summary: sys-kernel/genkernel-3.4.47 does not output to serial console
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-12 18:23 UTC by Matthew Thode ( prometheanfire )
Modified: 2021-03-08 21:54 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Thode ( prometheanfire ) archtester Gentoo Infrastructure gentoo-dev Security 2013-06-12 18:23:32 UTC
when setting kernel paramaters as follows, genkernel is not accessable from the command line (up to initram data is output to ttys specified).

console=tty0 console=ttyS0,115200 console=ttyS2,115200 console=ttyS2,115200

This also disables kernel logging to these interfaces when within the initram (reenabled when exiting it).  Hurts debugging, I can't enter the luks/gpg passphrase for instance.

Reproducible: Always

Steps to Reproduce:
1. add 'console=tty0 console=ttyS0,115200 console=ttyS2,115200 console=ttyS2,115200' to the kernel command line.
2. watch the serial console (as it stops at loading the initram)
3. watch as it resumes after the initram
Actual Results:  
no output to serial console when within the initram

Expected Results:  
output (at least kernel debug messages) when within the initram
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2017-01-03 05:19:55 UTC
To properly fix this, we need to make every thing in the linuxrc/initramfs scope write to ALL consoles and take input from all consoles.

Dracut and other systems can do this I think, so it's just a matter of figuring out HOW they do it, and replicating it in genkernel.
Comment 2 Larry the Git Cow gentoo-dev 2019-08-07 15:46:08 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=f49a899ce13f9e41bdf592187e0d157b071bf82d

commit f49a899ce13f9e41bdf592187e0d157b071bf82d
Author:     Thomas Deutschmann <whissi@gentoo.org>
AuthorDate: 2019-08-06 15:43:40 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2019-08-06 20:40:32 +0000

    linuxrc: Fix console support
    
    - Make sure we set console after processing CMDLINE so that we will
      use last set console which matches kernel documentation.
    
    - Strip any set option from console= value.
    
    - Regain control after spawning a shell.
    
    Bug: https://bugs.gentoo.org/473128
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>

 defaults/initrd.scripts | 15 ++++++++++++---
 defaults/linuxrc        | 25 +++++++++++++++++++++----
 2 files changed, 33 insertions(+), 7 deletions(-)
Comment 3 Thomas Deutschmann (RETIRED) gentoo-dev 2019-08-07 16:52:31 UTC
Serial console should now work in >=sys-kernel/genkernel-4.0.0_beta11. Please file a new bug if you still experience problems.
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2021-03-08 21:54:00 UTC
Let me add some additional information to this bug in case this will ever come up again:

(In reply to Robin Johnson from comment #1)
> To properly fix this, we need to make every thing in the linuxrc/initramfs
> scope write to ALL consoles and take input from all consoles.
> 
> Dracut and other systems can do this I think, so it's just a matter of
> figuring out HOW they do it, and replicating it in genkernel.
No! This is not possible -- at least by default:

Kernel code which calls printk() will write to a buffer. Any console which will get added to /dev/console will receive this buffer. This is handled by the kernel.

User space will only write to the so called "preferred console" aka CONSDEV (console which show up with "C" in /proc/consoles for example).

By default, the last set console becomes the preferred console. Going back to Matthew's example (console=tty0 console=ttyS0,115200 console=ttyS2,115200) that means that he will get kernel output on tty0, ttyS0 and ttyS2 BUT ttyS2 will become the CONSDEV (preferred console). So cryptsetup will prompt to enter LUKS passphrase on ttyS2. If he wants to use tty0, he will have to change order of console kernel command-line arguments (=putting console=tty0 last).
Same is true for genkernel's initramfs output (or for OpenRC/systemd when real system will take control) -- tty0 and ttyS0 will not show it. Only preferred console ttyS2 will get it.

It's not possible to output to or receive input from multiple consoles at the same time.

There's a misunderstanding that systemd is capable of doing that, see https://github.com/systemd/systemd/issues/3403#issuecomment-239690447 -- but notice that the quote is missing the important end from original comment,

> echo foo > /dev/console" still goes to serial only, though

So what's happening here? Some distributions are shipping systemd (dracut) with plymouth for example which will 'mirror' output to all registered consoles. Debian did this even for sysvinit in the past via https://salsa.debian.org/debian/sysvinit/-/blob/a4f7babb3e09d3ff8b65e1612df9e6d59369316e/debian/patches/96_allow_multiple_console_output.patch as part of https://bugs.debian.org/181756 (SuSE did something similar with their blogd).

A good summary with additional references is https://github.com/systemd/systemd/issues/9899.