diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/10coreos-printk/coreos-printk-quiet.service b/overlay.d/05core/usr/lib/dracut/modules.d/10coreos-printk/coreos-printk-quiet.service new file mode 100644 index 0000000000..1d1ddddd68 --- /dev/null +++ b/overlay.d/05core/usr/lib/dracut/modules.d/10coreos-printk/coreos-printk-quiet.service @@ -0,0 +1,11 @@ +[Unit] +Description=CoreOS: Quiet printk after initramfs setup +Documentation=https://github.com/coreos/fedora-coreos-tracker/issues/1244 +ConditionPathExists=/etc/initrd-release +After=initrd.target + +[Service] +Type=oneshot +RemainAfterExit=yes +# Change the kernel to default to warning level +ExecStart=/bin/sh -c 'echo 4 > /proc/sys/kernel/printk' diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/10coreos-printk/module-setup.sh b/overlay.d/05core/usr/lib/dracut/modules.d/10coreos-printk/module-setup.sh new file mode 100644 index 0000000000..a954348733 --- /dev/null +++ b/overlay.d/05core/usr/lib/dracut/modules.d/10coreos-printk/module-setup.sh @@ -0,0 +1,25 @@ +# See https://issues.redhat.com/browse/RFE-2977 and +# https://github.com/coreos/fedora-coreos-tracker/issues/1244 +# Basically, the current Fedora kernel log level is "7" which is quite +# high. We could change the kernel, and it's tempting to do so but +# there's some nontrivial potential fallout from that. +# As a compromise, we keep the default log level for the initramfs, +# but quiet it before switching to the real root. This will ensure +# we'll get most useful logging of bootup configuration. + +check() { + return 0 +} + +install_unit() { + unit="$1"; shift + target="$1"; shift + inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit" + # note we `|| exit 1` here so we error out if e.g. the units are missing + # see https://github.com/coreos/fedora-coreos-config/issues/799 + systemctl -q --root="$initdir" add-requires "$target" "$unit" || exit 1 +} + +install() { + install_unit coreos-printk-quiet.service initrd.target +} diff --git a/tests/kola/logging/printk.sh b/tests/kola/logging/printk.sh new file mode 100644 index 0000000000..656baabea1 --- /dev/null +++ b/tests/kola/logging/printk.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# kola: { "exclusive": false } + +# Verify fix for https://github.com/coreos/fedora-coreos-tracker/issues/1244 + +set -xeuo pipefail + +. $KOLA_EXT_DATA/commonlib.sh + +printk=$(cat /proc/sys/kernel/printk) + +if ! [[ "$printk" =~ '^4' ]]; then + fatal "printk: expected console log level 4, found ${printk}" +fi + +ok "Found expected printk value "