SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-04-11 06:56:48

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

[Updated] Make the "quiet" boot parameter REALLY quiet

Ever wished the "quiet" boot parameter applied to the entire boot process, not just kernel messages?  Well now it can, without using plymouth or any other special package.

Add the following line to the "configuration" file /etc/default/rcS to make the "quiet" boot parameter apply to all startup messages:

[ "$init" ] && grep -qw quiet /proc/cmdline && exec >>/run/rc.log 2>&1 || true

Or use this version to create a separate boot parameter "hush" for just the init startup messages:

[ "$init" ] && grep -qw hush /proc/cmdline && exec >>/run/rc.log 2>&1 || true

How does this work?  Technically, /etc/default/rcS is not a bunch of configuration variables but an include file "sourced" by the init runlevel script called /etc/init.d/rc.  So valid shell commands in the file are executed as PART OF THE SCRIPT.  This is a feature (or weakness) of nearly all configuration files in /etc/default.

If you are not a veteran shell programmer, you may find these one liners terse.  An equivalent "long" version with comments:

# If the "init" shell variable is set (true when rc is run by /sbin/init)
if [ "$init" != "" ] ; then
    # If the kernel command line contains the word "quiet"
    if grep -qw quiet /proc/cmdline ; then
        # Modify the stdout and stderr output of the script to file /run/rc.log
        exec >>/run/rc.log 2>&1
    fi
else
    # Make sure the last command returns exit code 0 (true)
    true
fi

The "init" test is necessary as some scripts in /etc/init.d ALSO source /etc/default/rcS directly.  We don't want them to redirect output again or do so if NOT called as part of /etc/init.d/rc.  While "exec" is most commonly used to start another program or script in place of the current one, it has a secondary function to redirect the output of the script (and all other scripts it starts).  The startup messages are available for inspection in /run/rc.log.  You can change the name of the logfile, but do not use a directory on the root filesystem; it is read-only at the start of init and your log will be empty.

The result is not quite a perfectly blank screen as /bin/init issues a message at each runlevel change (rcS and rc2) - but otherwise all output is captured unless you have an unusual script or process that explicitly opens and writes to /dev/console instead of using stdout or stderr.

This has been tested with waldorf and wheezy, but should work for any distro using sysvinit scripts (like statler and squeeze).

Updated 30 June 2013:

The one-liners above have been augmented with "|| true".  Since /etc/default/rcS is technically a sourced script, it has a return value.  Without an explicitly set return value, the return value matches the result of the last command.  If the one-liner is the last command WITHOUT "|| true" and the test for $init fails (when starting/stopping services for other reasons) it technically sets a  non-zero return code.  For init scripts that use "set -e", this causes them to fail. 

The "|| true" executes the command "true" when other commands in the chain fail and explicitly has a zero return value.  The problem could also be solved without "|| true" by placing a "return 0" statement at the end of /etc/default/rcS OR having at least one variable assignment after the one-liner (assignments also have a zero return value).  My original tests had the one-liner before my assignments and I missed the possibility for failure.  Apologies if this caused you problems.

Last edited by cpoakes (2013-06-30 22:35:20)


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

Help fund CrunchBang, donate to the project!

#2 2013-04-11 11:59:00

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,943
Website

Re: [Updated] Make the "quiet" boot parameter REALLY quiet

Thank you cpoakes - a nice alternative for those struggling to make Plymouth work!


John     Please help us keep your forums manageable.   Don't Break Debian
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Offline

#3 2013-04-12 00:56:42

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Re: [Updated] Make the "quiet" boot parameter REALLY quiet

^Exactly why I researched and created this solution.  But I also have working plymouth configurations for my principal machines (plymouth + MDM).


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

#4 2013-06-30 23:00:34

cpoakes
#! CrunchBanger
From: Tucson, Arizona
Registered: 2012-05-19
Posts: 202

Re: [Updated] Make the "quiet" boot parameter REALLY quiet

Update added to first post.


programming and administering unix since 1976 (BSD, System III, Xenix, System V, Linux)

Offline

#5 2013-07-02 11:37:39

Anakinholland
#! CrunchBanger
Registered: 2011-11-30
Posts: 210

Re: [Updated] Make the "quiet" boot parameter REALLY quiet

nice one, thanks! smile


Use what you like. If you don't like it, improve it. If you can't, look for something else. || **Please read before posting** || Edit the first post in a topic and mark it [solved] if it has been.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo