Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 788970 - quiet kernel parameter not working
Summary: quiet kernel parameter not working
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2021-05-08 18:24 UTC by Victor Costache
Modified: 2021-07-06 23:11 UTC (History)
1 user (show)

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


Attachments
quiet kernel boot parameter not working with initramfs (genkernel) (genkernel-quiet.webm,237.88 KB, video/webm)
2021-05-08 21:11 UTC, Victor Costache
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Costache 2021-05-08 18:24:53 UTC
Hello,

Although the "quiet" parameter is added to the kernel boot parameters, the kernel messages (printk) are still displayed in the console. Also, adding "loglevel=3" has not impact. 

cat /proc/sys/kernel/printk always returns "7 4 1 7" regardless of the kernel boot parameters.
Comment 1 Emily Rowlands 2021-05-08 18:35:53 UTC
What kernel are you using? Can you give emerge --info?
Comment 2 Thomas Deutschmann (RETIRED) gentoo-dev 2021-05-08 18:49:43 UTC
I think there is a misunderstanding regarding "quiet" mode.

Even if you enable "quiet" mode, you will run with loglevel 4 (see include/linux/printk.h).

Set loglevel kernel command-line argument is not supposed to alter values seen in /proc/sys/kernel/printk. It's an additional runtime value kernel compares against when executing printk function, see call_console_drivers() in kernel/printk/printk.c.

And I am sorry, I don't get the reference to genkernel. Could you please explain why you filed this bug against genkernel and what you are expecting from genkernel to do?
Comment 3 Victor Costache 2021-05-08 18:57:21 UTC
(In reply to Thomas Deutschmann from comment #2)
> I think there is a misunderstanding regarding "quiet" mode.
> 
> Even if you enable "quiet" mode, you will run with loglevel 4 (see
> include/linux/printk.h).
> 
> Set loglevel kernel command-line argument is not supposed to alter values
> seen in /proc/sys/kernel/printk. It's an additional runtime value kernel
> compares against when executing printk function, see call_console_drivers()
> in kernel/printk/printk.c.
> 
> And I am sorry, I don't get the reference to genkernel. Could you please
> explain why you filed this bug against genkernel and what you are expecting
> from genkernel to do?

I expect that all the console messages to be suppressed when adding "quiet" to the kernel boot parameters. According to the linuxrc script, the printk loglevel is restored to 7.

The kernel messages are only suppressed priors the linuxrc script.

Please check this code from the linuxrc script:

if [[ "${CONSOLE_LOGLEVEL}" != "${GK_CONSOLE_LOGLEVEL}" ]]
then
        good_msg "Restoring console log level (${CONSOLE_LOGLEVEL}) ..."
        echo ${CONSOLE_LOGLEVEL} > /proc/sys/kernel/printk \
                && log_msg "COMMAND: 'echo \"${CONSOLE_LOGLEVEL}\" > /proc/sys/kernel/printk'"
fi

The console log level is restored regardless of the "quiet" kernel boot parameter.
Comment 4 Victor Costache 2021-05-08 18:58:36 UTC
The expected behavior is to get a fully silent console.
Comment 5 Thomas Deutschmann (RETIRED) gentoo-dev 2021-05-08 19:04:04 UTC
OK, then this report is invalid.

Like said, quiet mode will not alter printk values. It is a runtime value kernel checks against in addition when calling the console driver.

Genkernel only sets printk during genkernel initramfs execution and will restore previous value before transfering control to real system.
Comment 6 Victor Costache 2021-05-08 20:27:44 UTC
The point is that "quiet" should suppress all the console kernel messages but genkernel (i.e. initramfs execution) prevents that. 

Could you please let me know how can I get a completely silence console having the ramdisk generated by genkernel?
Comment 7 Thomas Deutschmann (RETIRED) gentoo-dev 2021-05-08 20:51:08 UTC
I don't understand about what you are talking. When I boot a genkernel system with "quiet" kernel command-line parameter set, I have zero output until genkernel transfers control to real system and init will be started.
Comment 8 Victor Costache 2021-05-08 21:11:48 UTC
Created attachment 706662 [details]
quiet kernel boot parameter not working with initramfs (genkernel)

(In reply to Thomas Deutschmann from comment #7)
> I don't understand about what you are talking. When I boot a genkernel
> system with "quiet" kernel command-line parameter set, I have zero output
> until genkernel transfers control to real system and init will be started.

Yes, this should be the normal behavior: zero output. However, it is not my case. See the attached screen recording from VirtualBox. The kernel version I am using is 4.2.1-r1.
Comment 9 Victor Costache 2021-05-08 21:14:27 UTC
I meant the genkernel version is 4.2.1-r1.
Comment 10 Thomas Deutschmann (RETIRED) gentoo-dev 2021-05-08 21:40:17 UTC
No, what you are seeing in video is systemd (i.e. the real system which takes control). This is *after* genkernel initramfs.
Comment 11 Victor Costache 2021-05-09 13:01:22 UTC
(In reply to Thomas Deutschmann from comment #10)
> No, what you are seeing in video is systemd (i.e. the real system which
> takes control). This is *after* genkernel initramfs.

It is *after* genkernel initramfs but it is *because of* the linuxrc script which is "restoring" the kernel loglevel (see the /usr/share/genkernel/defaults/linuxrc code snippet below):

---
if [[ "${CONSOLE_LOGLEVEL}" != "${GK_CONSOLE_LOGLEVEL}" ]]
then
        good_msg "Restoring console log level (${CONSOLE_LOGLEVEL}) ..."
        echo ${CONSOLE_LOGLEVEL} > /proc/sys/kernel/printk \
                && log_msg "COMMAND: 'echo \"${CONSOLE_LOGLEVEL}\" > /proc/sys/kernel/printk'"
fi
---

If I generate the ramdisk either with dracut or a custom linuxrc script genkernel, the "quite" kernel boot parameter works as it should (completely blank console). Furthermore, downgrading the genkernel to 4.1.2-r3 also works (i.e. suppressing the console kernel messages when passing "quiet" to the kernel command line).
Comment 12 Thomas Deutschmann (RETIRED) gentoo-dev 2021-05-10 00:40:33 UTC
Needs investigation, but I can confirm with something like

> diff --git a/defaults/linuxrc b/defaults/linuxrc
> index 932df46..6ede740 100644
> --- a/defaults/linuxrc
> +++ b/defaults/linuxrc
> @@ -452,8 +452,11 @@ do
>         esac
>  done
> 
> -# Prevent superfluous printks from being printed to the console
> -echo ${GK_CONSOLE_LOGLEVEL} > /proc/sys/kernel/printk
> +if ! is_quiet
> +then
> +       # Prevent superfluous printks from being printed to the console
> +       echo ${GK_CONSOLE_LOGLEVEL} > /proc/sys/kernel/printk
> +fi
> 
>  good_msg "${GK_META_VERSION} (${GK_META_BUILD_DATE}). Linux kernel ${KV}"
> 
> @@ -1370,7 +1373,7 @@ do
>         fi
>  done
> 
> -if [[ "${CONSOLE_LOGLEVEL}" != "${GK_CONSOLE_LOGLEVEL}" ]]
> +if ! is_quiet && [[ "${CONSOLE_LOGLEVEL}" != "${GK_CONSOLE_LOGLEVEL}" ]]
>  then
>         good_msg "Restoring console log level (${CONSOLE_LOGLEVEL}) ..."
>         echo ${CONSOLE_LOGLEVEL} > /proc/sys/kernel/printk \
> 

Thank you for the report.
Comment 13 Larry the Git Cow gentoo-dev 2021-07-06 00:25:14 UTC
The bug has been referenced in the following commit(s):

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

commit f80b81da305f1f782043d31751f81264be6f2ecd
Author:     Thomas Deutschmann <whissi@gentoo.org>
AuthorDate: 2021-06-23 22:42:13 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2021-07-05 22:44:45 +0000

    linuxrc: Don't mess with console log level in quiet mode
    
    Fixes: d5f7d79b ("linuxrc: Refactor handling of console log level")
    Bug: https://bugs.gentoo.org/788970
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>

 defaults/linuxrc | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
Comment 14 Thomas Deutschmann (RETIRED) gentoo-dev 2021-07-06 23:11:11 UTC
Fixed in >=sys-kernel/genkernel-4.2.2!