Skip to content

Commit

Permalink
Add kdump dracut config
Browse files Browse the repository at this point in the history
In some cases, customizing the first kernel's initrd is necessary by
modifying the dracut `omit_dracutmodules` options, such as in Bootc
or CoreOS scenarios [1]. However, these changes can unintentionally
break existing functionality in kdump. For instance, setting
`omit_dracutmodules='nfs'` prevents the `nfs` module from being added.

Additionally, some dracut configurations [2] use
`dracutmodules+='some modules'` instead of
`add_dracutmodules+='some modules'`. When `dracutmodules` is non-empty,
dracut includes only the specified modules, which can result in an
initrd that lacks necessary modules, causing kdump to fail.

Dracut upstream support --add-confdir now, kdump can use this
option when building kdump initramfs.

This patch moved the hardcoded dracutmodules from mkdumprd to the new
conf file /lib/kdump/dracut.conf.d/99-kdump.conf, it is easier to check
and modify to omit or add certain modules. This patch also initialize
dracutmodules to empty to avoid the influence of other configurations.

See also:
[1] rhkdump#11
[2] https://issues.redhat.com/browse/RHEL-49590?focusedId=25197134&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-25197134

Suggested-by: Dave Young <[email protected]>
Suggested-by: Colin Walters <[email protected]>
Signed-off-by: Lichen Liu <[email protected]>
  • Loading branch information
licliu committed Nov 21, 2024
1 parent ca6da9b commit 73f04a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions 99-kdump.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dracutmodules=''
add_dracutmodules=' kdumpbase '
omit_dracutmodules=' rdma plymouth resume ifcfg earlykdump '
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
11 changes: 9 additions & 2 deletions mkdumprd
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ 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)
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."
Expand Down Expand Up @@ -441,4 +439,13 @@ elif ! is_fadump_capable && \
add_mount "$status_target"
fi

# Use kdump managed dracut profile.
[[ $kdump_dracut_confdir ]] || kdump_dracut_confdir=/lib/kdump/dracut.conf.d
if [[ "$(dracut --help)" == *--add-confdir* ]] && [[ -d "$kdump_dracut_confdir" ]]; then
dracut_args+=("--add-confdir" "$kdump_dracut_confdir")
else
dracut_args+=(--add kdumpbase)
dracut_args+=(--omit "rdma plymouth resume ifcfg earlykdump")
fi

dracut "${dracut_args[@]}" "$@"

0 comments on commit 73f04a3

Please sign in to comment.