commit: d5f7d79bab1563c301e0722ede0d75549297a031 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Fri Mar 19 19:09:36 2021 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Sat Mar 20 00:12:35 2021 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=d5f7d79b
linuxrc: Refactor handling of console log level Closes: https://github.com/gentoo/genkernel/pull/24 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> defaults/initrd.defaults | 1 + defaults/initrd.scripts | 18 ------------------ defaults/linuxrc | 18 +++++++++++------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index 18e1382..8849539 100644 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -70,6 +70,7 @@ VERIFY=0 IP='dhcp' GK_BOOTFONT_DISABLED=0 +GK_CONSOLE_LOGLEVEL=3 GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled" GK_EMERGENCY_ACTION="halt -f" GK_HW_LOAD_ALL_MODULES=0 diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index ea66d9b..d68875b 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -2502,24 +2502,6 @@ sdelay() { fi } -quiet_kmsg() { - # if QUIET is set make the kernel less chatty - if [ -n "${QUIET}" ] - then - echo '0' > /proc/sys/kernel/printk \ - && log_msg "COMMAND: 'echo \"0\" > /proc/sys/kernel/printk'" - fi -} - -verbose_kmsg() { - # if QUIET is set make the kernel less chatty - if [ -n "${QUIET}" ] - then - echo '6' > /proc/sys/kernel/printk \ - && log_msg "COMMAND: 'echo \"6\" > /proc/sys/kernel/printk'" - fi -} - cdupdate() { if [ "${CDROOT}" = '1' ] then diff --git a/defaults/linuxrc b/defaults/linuxrc index 1861f23..dc34439 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -42,9 +42,6 @@ then chmod 0750 /run/initramfs fi -# Prevent superfluous printks from being printed to the console -echo 1 > /proc/sys/kernel/printk - if [ ! -s /etc/ld.so.cache ] then # Looks like we were unable to run ldconfig during initramfs generation @@ -54,6 +51,7 @@ fi # Set up symlinks run busybox --install -s +console_loglevel="$(cut -b1 /proc/sys/kernel/printk 2>/dev/null || echo 7)" gk_ver="$(cat /etc/build_id)" gk_build_date="$(cat /etc/build_date)" kernel_ver="$(uname -r)" @@ -467,6 +465,9 @@ do esac done +# Prevent superfluous printks from being printed to the console +echo ${GK_CONSOLE_LOGLEVEL} > /proc/sys/kernel/printk + good_msg "${gk_ver} (${gk_build_date}). Linux kernel ${kernel_ver}" if [ "${GK_BOOTFONT_DISABLED}" = '0' -a -e /lib/console/font ] @@ -480,8 +481,6 @@ then fi fi -quiet_kmsg - if [ "${CDROOT}" = '0' ] then if [ -z "${REAL_ROOT}" -a "${FAKE_ROOT}" != "/dev/ram0" ] @@ -1305,8 +1304,6 @@ then CHROOT="${CHROOT}/${SUBDIR}" fi -verbose_kmsg - if [ "${aufs}" = '1' ] then aufs_union_memory=${CHROOT}/.unions/memory @@ -1384,6 +1381,13 @@ do fi done +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 + good_msg "Switching to real root: switch_root ${CHROOT} ${init} ${init_opts}" exec switch_root "${CHROOT}" "${init}" ${init_opts}
