fadump: add a kernel install hook to clean up fadump initramfs

Kdump service will create fadump initramfs when needed, but it won't
clean up the fadump initramfs on kernel uninstall. So create a kernel
install hook to do the clean up job.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Hari Bathini 2022-12-02 18:46:51 +05:30 committed by Coiby Xu
parent 25411da966
commit 4a2dcab26a
2 changed files with 34 additions and 0 deletions

31
60-fadump.install Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/bash
COMMAND="$1"
KERNEL_VERSION="$2"
if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
exit 0
fi
# Currently, fadump is supported only in environments with
# writable /boot directory.
if [[ ! -w "/boot" ]]; then
exit 0
fi
FADUMP_INITRD="/boot/.initramfs-${KERNEL_VERSION}.img.default"
FADUMP_INITRD_CHECKSUM="$FADUMP_INITRD.checksum"
ret=0
case "$COMMAND" in
add)
# Do nothing, fadump initramfs is strictly host only
# and managed by kdump service
;;
remove)
rm -f -- "$FADUMP_INITRD"
rm -f -- "$FADUMP_INITRD_CHECKSUM"
ret=$?
;;
esac
exit $ret

View File

@ -38,6 +38,7 @@ Source33: 92-crashkernel.install
Source34: crashkernel-howto.txt
Source35: kdump-migrate-action.sh
Source36: kdump-restart.sh
Source37: 60-fadump.install
#######################################
# These are sources for mkdumpramfs
@ -204,6 +205,7 @@ install -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules
%endif
%ifarch ppc64 ppc64le
install -m 644 %{SOURCE14} $RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules
install -m 755 -D %{SOURCE37} $RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-fadump.install
%endif
install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5
install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service
@ -366,6 +368,7 @@ fi
%endif
%ifarch ppc64 ppc64le
/usr/sbin/mkfadumprd
%{_prefix}/lib/kernel/install.d/60-fadump.install
%endif
/usr/sbin/mkdumprd
/usr/sbin/vmcore-dmesg