summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2022-08-02 10:15:36 +0200
committer Eric Hameleers <alien@slackware.com>2022-08-02 10:15:36 +0200
commitfb08fcc819828d885f6e90f06fc4cd78f46842ac (patch)
treeb551f644f96d6e69926ff1e756125265ea0ac4e6
parentdc12c8f285c0637d8ee414e58ba10f3f26c2c5d2 (diff)
downloadliveslak-fb08fcc819828d885f6e90f06fc4cd78f46842ac.tar.gz
liveslak-fb08fcc819828d885f6e90f06fc4cd78f46842ac.tar.xz
liveinit: start ash bash-compatible and save init debug output to file
When the value of 'debug' parameter is equal to or greater than '2', the init script enables 'set -x' which results in verbose output of init script execution. When the 'ash' shell is started as '/bin/sh' instead of '/bin/ash', it enables bash-compatible mode. Then the script can use 'BASH_XTRACEFD' to log the verbose script output to a file '/debug_init.log'. This is extremely useful for init debugging. Logging to file is enabled when the value of 'debug' is '4' or higher. When you boot with 'debug=4, you will end up in the rescue shell of the initrd. You can then inspect '/debug_init.log' to diagnose issues with the boot-up, and you can copy that logfile for instance to /mnt/overlay/root/ if you want to preserve it. After typing 'exit', the live init will hand-over to the Slackware OS initialization and after logging in you can copy the logfile to a network location if you want.
-rw-r--r--liveinit.tpl14
1 files changed, 12 insertions, 2 deletions
diff --git a/liveinit.tpl b/liveinit.tpl
index a5a7e9c..d00650d 100644
--- a/liveinit.tpl
+++ b/liveinit.tpl
@@ -1,4 +1,4 @@
-#!/bin/ash
+#!/bin/sh
#
# Copyright 2004 Slackware Linux, Inc., Concord, CA, USA
# Copyright 2007, 2008, 2009, 2010, 2012 Patrick J. Volkerding, Sebeka, MN, USA
@@ -305,7 +305,17 @@ for ARG in $(cat /proc/cmdline); do
done
# Verbose boot script execution:
-[ $DEBUG -ge 2 ] && set -x
+if [ $DEBUG -ge 2 ]; then
+ if [ $DEBUG -ge 4 ]; then
+ # We save (verbose) shell output to local file;
+ # These busybox compile options make it possible:
+ # CONFIG_SH_IS_ASH=y
+ # CONFIG_ASH_BASH_COMPAT=y
+ exec 5> debug_init.log
+ export BASH_XTRACEFD="5"
+ fi
+ set -x
+fi
debugit () {
if [ $DEBUG -eq 0 -o $DEBUG -gt 3 ]; then