From 6d119257201146ea39435fadcb9334e15bae101f Mon Sep 17 00:00:00 2001 From: Lichen Liu Date: Fri, 11 Oct 2024 10:40:55 +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'". Some dracut conf may override dracutmodules variable, this also may break the building of kdump img. We need to keep it empty. It is better to maintain its own dracut config for kdump. This patch moved the hardcoded dracut modules and omit modules to the new conf dir /lib/kdump/dracut.conf.d/99-kdump.conf. 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 | 3 +++ Makefile | 3 ++- mkdumprd | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 99-kdump.conf diff --git a/99-kdump.conf b/99-kdump.conf new file mode 100644 index 00000000..4d0c49fd --- /dev/null +++ b/99-kdump.conf @@ -0,0 +1,3 @@ +dracutmodules='' +add_dracutmodules+='kdumpbase' +omit_dracutmodules+='rdma plymouth resume ifcfg earlykdump' diff --git a/Makefile b/Makefile index 5029a59c..5e402f03 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,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 @@ -46,6 +46,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 19333a0c..cfa2e786 100644 --- a/mkdumprd +++ b/mkdumprd @@ -29,7 +29,6 @@ SSH_KEY_LOCATION=$DEFAULT_SSHKEY SAVE_PATH=$(get_save_path) declare -a dracut_args -dracut_args+=(--add kdumpbase) dracut_args+=(--quiet) dracut_args+=(--hostonly) dracut_args+=(--hostonly-cmdline) @@ -37,7 +36,6 @@ dracut_args+=(--hostonly-i18n) dracut_args+=(--hostonly-mode strict) dracut_args+=(--hostonly-nics '') dracut_args+=(--aggressive-strip) -dracut_args+=(--omit "rdma plymouth resume ifcfg earlykdump") MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)" [ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed." @@ -441,4 +439,18 @@ elif ! is_fadump_capable && \ add_mount "$status_target" fi +# Use kdump managed dracut profile. +_dracut_add_confdir_option="--confdir" +if dracut --help | grep -q "add-confdir" ; then + _dracut_add_confdir_option="--add-confdir" +fi + +[[ $kdumpdracutconfdir ]] || kdumpdracutconfdir=/lib/kdump/dracut.conf.d +if [ -d "$kdumpdracutconfdir" ]; then + dracut_args+=("$_dracut_add_confdir_option" "$kdumpdracutconfdir") +else + dracut_args+=(--add kdumpbase) + dracut_args+=(--omit "rdma plymouth resume ifcfg earlykdump") +fi + dracut "${dracut_args[@]}" "$@"