On 05/09/2017 at 01:51 PM, Ziyue Yang wrote:
Currently in Fedora/RedHat dracut installs its fedora.conf.example
as the default config file, in which sysloglvl is set 5. This leads
to maxloglvl=5 in dracut calls, making unnecessary lsinitrd calls
during initramfs builds.
This patch makes use of --conf and --confdir arguments of dracut,
creates temp config directory before mkdumprd(dracut) calls. It
appends sysloglvl=0 option by creating a 99-kdumpctl.conf file in
the temp config directory.
1) Before this patch
$ kdumpctl stop; touch /etc/kdump.conf; time kdumpctl start
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
/etc/kdump.conf
Rebuilding /boot/initramfs-4.10.10-200.fc25.x86_64kdump.img 4.10.10-200.fc25_x86_64
kexec: loaded kdump kernel
Starting kdump: [OK]
real 0m18.716s
user 0m13.863s
sys 0m3.269s
2) After this patch
$ kdumpctl stop; touch /etc/kdump.conf; time kdumpctl start
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
/etc/kdump.conf
Rebuilding /boot/initramfs-4.10.10-200.fc25.x86_64kdump.img 4.10.10-200.fc25_x86_64
kexec: loaded kdump kernel
Starting kdump: [OK]
real 0m13.665s
user 0m10.945s
sys 0m2.907s
Signed-off-by: Ziyue Yang <ziyang(a)redhat.com>
---
kdumpctl | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 4d6b3e8..a37db01 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -5,7 +5,6 @@ KDUMP_KERNELVER=""
KDUMP_COMMANDLINE=""
KEXEC_ARGS=""
KDUMP_CONFIG_FILE="/etc/kdump.conf"
-MKDUMPRD="/sbin/mkdumprd -f"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum"
@@ -20,6 +19,18 @@ DEFAULT_DUMP_MODE="kdump"
image_time=0
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
+
+# lower dracut's default sysloglvl to speedup initramfs build
+DRACUT_SYSLOGLVL="3"
+# make temp dir for dracut conf files
+[[ $dracutconfdir ]] || dracutconfdir=/tmp/kdumpctl.dracut.conf
+mkdir -p $dracutconfdir/dracut.conf.d
+[[ -e $dracutbasedir/dracut.conf.d ]] && cp -rf $dracutbasedir/dracut.conf.d
$dracutconfdir/
+[[ -e $dracutbasedir/dracut.conf ]] && cp -rf $dracutbasedir/dracut.conf
$dracutconfdir/
+echo "sysloglvl=$DRACUT_SYSLOGLVL" >
$dracutconfdir/dracut.conf.d/99-kdumpctl.conf
+
+MKDUMPRD="/sbin/mkdumprd --conf $dracutconfdir/dracut.conf --confdir
$dracutconfdir/dracut.conf.d -f"
According to /usr/bin/dracut implementation:
if [[ ! -d $confdir ]]; then
if [[ $allowlocal ]]; then
confdir="$dracutbasedir/dracut.conf.d"
else
confdir="/etc/dracut.conf.d"
fi
fi
# source our config file
[[ -f $conffile ]] && . "$conffile"
# source our config dir
for f in $(dropindirs_sort ".conf" "$confdir"
"$dracutbasedir/dracut.conf.d"); do
[[ -e $f ]] && . "$f"
done
So, "$dracutbasedir/dracut.conf.d" is always sourced, looks like it suffices to
create one
kdump config file(say 99-kdump-loglevel.conf, "99" will override the others)
with pre-defined
log levels(like sysloglvl=3, stdloglvl=3, etc), then pass it to dracut with
"--conf".
We also can place the file under "/etc/dracut.conf.d/" or
"/usr/lib/dracut/dracut.conf.d/"
directly when kexec-tools rpm is installed via kexec-tools.spec.
What do you think?
Regards,
Xunlei
+
. $dracutbasedir/dracut-functions.sh
. /lib/kdump/kdump-lib.sh
@@ -284,6 +295,9 @@ rebuild_initrd()
rebuild_kdump_initrd
fi
+ # delete tmp conf folder for dracut
+ rm -rf /tmp/kdumpctl.dracut.conf
+
return $?
}