From ebf5507a5e92e5fa80394ec2d57e33247e2aed8c Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Tue, 6 Aug 2024 12:04:21 +0800 Subject: [PATCH] Add kdump dracut config In some cases, we need to change dracut [omit_]dracutmodules to customize the first kernel's initrd to meet the needs, such as bootc and CoreOS. In most cases kdump does not use these modules, but the change of [omit]_dracutmodules may break existing functionality. For example, if we set omit_dracutmodules='nfs', the nfs module cannot be added even if we use "dracut_args --force-add 'nfs'". It is better to maintain its own dracut config for kdump. As the first try, we start by keeping [omit_]dracutmodules empty. Dracut will support --add-confdir start by 104, kdump can use this option when building kdump initramfs. If --add-confdir is not available in your system, kdump will use --confdir, in this case, the default confdir "/etc/dracut.conf.d" will not work while generating kdump initrd. Suggested-by: Dave Young Suggested-by: Colin Walters Signed-off-by: Lichen Liu --- 99-kdump.conf | 2 ++ Makefile | 3 ++- mkdumprd | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 99-kdump.conf diff --git a/99-kdump.conf b/99-kdump.conf new file mode 100644 index 00000000..a222bab2 --- /dev/null +++ b/99-kdump.conf @@ -0,0 +1,2 @@ +dracutmodules='' +omit_dracutmodules='' diff --git a/Makefile b/Makefile index 538e4f49..66cece49 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ manpages: install -D -m 644 kdump.conf.5 $(DESTDIR)$(mandir)/man5/kdump.conf.5 install: dracut-modules kdump-conf kdump-sysconfig manpages - mkdir -p $(DESTDIR)$(pkglibdir) + mkdir -p $(DESTDIR)$(pkglibdir)/dracut.conf.d mkdir -p -m755 $(DESTDIR)$(sysconfdir)/kdump/pre.d mkdir -p -m755 $(DESTDIR)$(sysconfdir)/kdump/post.d mkdir -p -m755 $(DESTDIR)$(localstatedir)/crash @@ -59,6 +59,7 @@ install: dracut-modules kdump-conf kdump-sysconfig manpages install -D -m 644 kdump.conf $(DESTDIR)$(sysconfdir) install -D -m 644 kdump.sysconfig $(DESTDIR)$(sysconfdir)/sysconfig/kdump install -D -m 755 kdump-lib.sh kdump-lib-initramfs.sh kdump-logger.sh -t $(DESTDIR)$(pkglibdir) + install -D -m 644 99-kdump.conf -t $(DESTDIR)$(pkglibdir)/dracut.conf.d ifeq ($(ARCH), $(filter ppc64le ppc64,$(ARCH))) install -m 755 mkfadumprd $(DESTDIR)$(sbindir) diff --git a/mkdumprd b/mkdumprd index 27eed5e3..962e9d16 100644 --- a/mkdumprd +++ b/mkdumprd @@ -414,4 +414,12 @@ if ! is_fadump_capable; then fi fi +_dracut_add_confdir_option="--add-confdir" + +# dracut doesn't support --add-confdir before 104, use --confdir instead. +dracut --help | grep "add-confdir" -q +[[ $? -eq 0 ]] || _dracut_add_confdir_option="--confdir" +[[ $kdumpdracutconfdir ]] || kdumpdracutconfdir=/lib/kdump/dracut.conf.d +[ -d "$kdumpdracutconfdir" ] && add_dracut_arg "$_dracut_add_confdir_option" "$kdumpdracutconfdir" + dracut "${dracut_args[@]}" "$@"