Bootscript patches

Dan Nicholson dbn.lists at gmail.com
Sat Jun 16 11:35:16 PDT 2007


This adds the consolelog script and describes the configuration in the
book. The point of the script is to set the console kernel log level
early in boot to control the amount of kernel messages on the console.
This is controlled by the variable LOGLEVEL set
in /etc/sysconfig/console.

--
Dan

 BOOK/chapter01/changelog.xml      |   12 +++++++-
 BOOK/chapter07/console.xml        |   21 ++++++++++---
 BOOK/general.ent                  |    2 +-
 bootscripts/ChangeLog             |    3 ++
 bootscripts/Makefile              |    2 +
 bootscripts/lfs/init.d/consolelog |   61 +++++++++++++++++++++++++++++++++++++
 6 files changed, 94 insertions(+), 7 deletions(-)
 create mode 100755 bootscripts/lfs/init.d/consolelog

diff --git a/BOOK/chapter01/changelog.xml b/BOOK/chapter01/changelog.xml
index f8051cc..b60873f 100644
--- a/BOOK/chapter01/changelog.xml
+++ b/BOOK/chapter01/changelog.xml
@@ -36,6 +36,16 @@
     </listitem>
 -->
     <listitem>
+      <para>2007-06-16</para>
+      <itemizedlist>
+        <listitem>
+          <para>[dnicholson] - Described the configuration of the consolelog
+          bootscript.</para>
+        </listitem>
+      </itemizedlist>
+    </listitem>
+
+    <listitem>
       <para>2007-06-12</para>
       <itemizedlist>
         <listitem>
@@ -49,7 +59,7 @@
           <ulink url="&lfs-ticket-root;2025">#2025</ulink>.</para>
           <para>[ken] - Upgrade to tar-1.17, fixes
           <ulink url="&lfs-ticket-root;2029">#2029</ulink>.</para>
-	</listitem>
+        </listitem>
       </itemizedlist>
     </listitem>
 
diff --git a/BOOK/chapter07/console.xml b/BOOK/chapter07/console.xml
index be36fd8..cb7f541 100644
--- a/BOOK/chapter07/console.xml
+++ b/BOOK/chapter07/console.xml
@@ -16,14 +16,16 @@
   </indexterm>
 
   <para>This section discusses how to configure the <command>console</command>
-  bootscript that sets up the keyboard map and the console font. If non-ASCII
-  characters (e.g., the copyright sign, the British pound sign and Euro symbol)
-  will not be used and the keyboard is a U.S. one, skip this section. Without
+  and <command>consolelog</command> bootscripts that set up the keyboard map,
+  console font and console kernel log level. If non-ASCII characters (e.g.,
+  the copyright sign, the British pound sign and Euro symbol) will not be used
+  and the keyboard is a U.S. one, much of this section can be skipped. Without
   the configuration file, the <command>console</command> bootscript will do
   nothing.</para>
 
-  <para>The <command>console</command> script reads the
-  <filename>/etc/sysconfig/console</filename> file for configuration information.
+  <para>The <command>console</command>  and <command>consolelog</command>
+  script reads the <filename>/etc/sysconfig/console</filename> file for
+  configuration information.
   Decide which keymap and screen font will be used. Various language-specific
   HOWTOs can also help with this, see <ulink
   url="http://www.tldp.org/HOWTO/HOWTO-INDEX/other-lang.html"/>. If still in
@@ -38,6 +40,15 @@
   <variablelist>
 
     <varlistentry>
+      <term>LOGLEVEL</term>
+      <listitem>
+        <para>This variable specifies the log level for kernel messages sent
+        to the console as set by <command>dmesg</command>. Valid levels are
+        from "1" (no messages) to "8". The default level is "7".</para>
+      </listitem>
+    </varlistentry>
+
+    <varlistentry>
       <term>KEYMAP</term>
       <listitem>
         <para>This variable specifies the arguments for the
diff --git a/BOOK/general.ent b/BOOK/general.ent
index 074f5b3..e18241c 100644
--- a/BOOK/general.ent
+++ b/BOOK/general.ent
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!ENTITY version "SVN-20070612">
-<!ENTITY releasedate "June 12, 2007">
+<!ENTITY releasedate "June 16, 2007">
 <!ENTITY milestone "6.3">
 <!ENTITY generic-version "development"> <!-- Use "development", "testing", or "x.y[-pre{x}]" -->
 
diff --git a/bootscripts/ChangeLog b/bootscripts/ChangeLog
index 05a9ce3..2499df5 100644
--- a/bootscripts/ChangeLog
+++ b/bootscripts/ChangeLog
@@ -2,6 +2,9 @@
 	* lfs/init.d/mountfs, lfs/init.d/mountkernfs, lfs/init.d/setclock:
 	  Don't suppress stderr during bootscripts unless necessary. This
 	  would prevent potentially critical messages from reaching the screen.
+	* Makefile, lfs/init.d/consolelog: New bootscript controlling the
+	  kernel log level on the console. This is controlled by the LOGLEVEL
+	  variable in /etc/sysconfig/console.
 
 2007-04-24	Dan Nicholson	<dnicholson at linuxfromscratch.org>
 	* lfs/init.d/functions: When killproc is executed, it checks that
diff --git a/bootscripts/Makefile b/bootscripts/Makefile
index 977b703..4c6bcca 100644
--- a/bootscripts/Makefile
+++ b/bootscripts/Makefile
@@ -27,6 +27,7 @@ install: create-dirs create-service-dir
 	install -m ${CONFMODE} lfs/init.d/functions ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/halt          ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/console       ${EXTDIR}/rc.d/init.d/
+	install -m ${MODE} lfs/init.d/consolelog    ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/localnet      ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/modules       ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/mountfs       ${EXTDIR}/rc.d/init.d/
@@ -67,6 +68,7 @@ install: create-dirs create-service-dir
 	ln -sf ../init.d/localnet    ${EXTDIR}/rc.d/rc6.d/S90localnet
 	ln -sf ../init.d/reboot      ${EXTDIR}/rc.d/rc6.d/S99reboot
 	ln -sf ../init.d/mountkernfs ${EXTDIR}/rc.d/rcsysinit.d/S00mountkernfs
+	ln -sf ../init.d/consolelog  ${EXTDIR}/rc.d/rcsysinit.d/S02consolelog
 	ln -sf ../init.d/modules     ${EXTDIR}/rc.d/rcsysinit.d/S05modules
 	ln -sf ../init.d/udev        ${EXTDIR}/rc.d/rcsysinit.d/S10udev
 	ln -sf ../init.d/swap        ${EXTDIR}/rc.d/rcsysinit.d/S20swap
diff --git a/bootscripts/lfs/init.d/consolelog b/bootscripts/lfs/init.d/consolelog
new file mode 100755
index 0000000..34b4161
--- /dev/null
+++ b/bootscripts/lfs/init.d/consolelog
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Begin $rc_base/init.d/consolelog
+
+########################################################################
+#
+# Description : Set the kernel log level for the console
+#
+# Authors     : Dan Nicholson - dnicholson at linuxfromscratch.org
+#
+# Version     : 00.00
+#
+# Notes       : /proc must be mounted before this can run
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+# set the default loglevel
+LOGLEVEL=7
+if [ -r /etc/sysconfig/console ]; then
+	. /etc/sysconfig/console
+fi
+
+case "${1}" in
+	start)
+		case "$LOGLEVEL" in
+		[1-8])
+			boot_mesg "Setting the console log level to ${LOGLEVEL}..."
+			dmesg -n $LOGLEVEL
+			evaluate_retval
+			;;
+		*)
+			boot_mesg "Console log level '${LOGLEVEL}' is invalid" ${FAILURE}
+			echo_failure
+			;;
+		esac
+		;;
+	status)
+		# Read the current value if possible
+		if [ -r /proc/sys/kernel/printk ]; then
+			read level line < /proc/sys/kernel/printk
+		else
+			boot_mesg "Can't read the current console log level" ${FAILURE}
+			echo_failure
+		fi
+
+		# Print the value
+		if [ -n "$level" ]; then
+			${ECHO} -e "${INFO}The current console log level" \
+				"is ${level}${NORMAL}"
+		fi
+		;;
+
+	*)
+		echo "Usage: ${0} {start|status}"
+		exit 1
+		;;
+esac
+
+# End $rc_base/init.d/consolelog
-- 
1.5.1.6






More information about the lfs-dev mailing list