Hi Hari,
it totally makes sense to have some functionality like this. What I'm
not sure about is if it would make more sense to include it into
60-kdump.install. With that the patch would reduce to something like
this
--- a/60-kdump.install
+++ b/60-kdump.install
@@ -22,6 +22,8 @@ else
KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
fi
+KDUMP_INITRD_BAK=".initramfs-${KERNEL_VERSION}.img.default"
+
ret=0
case "$COMMAND" in
add)
@@ -29,7 +31,8 @@ case "$COMMAND" in
# and managed by kdump service
;;
remove)
- rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD"
+ rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD" || exit
+ rm -f -- "$KDUMP_INITRD_DIR_ABS/$KDUMP_INITRD_BAK"
ret=$?
;;
esac
Does that work for you? Or is there a reason KDUMP_INITRD_DIR_ABS must
not be anything else than /boot?
One more thing I noticed was the handling of INITRD_CHECKSUM_LOCATION.
First I thought this should be removed as well. But then I noticed that
there is only one instance for the last kernel which gets overwritten
when a new kernel is installed. For example assume the following
1. install kernel1
2. boot kernel1 and enable fadump
3. install kernel2
4. boot kernel2 and enable fadump
5. boot kernel1 and disable fadump
In this scenario step 4 will create a backup initrd for kernel2 and
overwrites INITRD_CHECKSUM_LOCATION without removing the backup initrd
for kernel1. Consequently step 5 will try to restore the backup initrd
for kernel1 but will fail as the checksum no longer matches. Is that
correct? Or am I missing something?
If I'm correct I think it would make sense to make
INITRD_CHECKSUM_LOCATION version specific and remove it together with
the backup initrd.
Thanks
Philipp
On Fri, 11 Nov 2022 20:13:05 +0530
Hari Bathini <hbathini(a)linux.ibm.com> wrote:
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(a)linux.ibm.com>
---
60-fadump.install | 30 ++++++++++++++++++++++++++++++
kexec-tools.spec | 3 +++
2 files changed, 33 insertions(+)
create mode 100755 60-fadump.install
diff --git a/60-fadump.install b/60-fadump.install
new file mode 100755
index 0000000..70fcd27
--- /dev/null
+++ b/60-fadump.install
@@ -0,0 +1,30 @@
+#!/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_DIR_ABS="/boot"
+FADUMP_INITRD=".initramfs-${KERNEL_VERSION}.img.default"
+
+ret=0
+case "$COMMAND" in
+ add)
+ # Do nothing, fadump initramfs is strictly host only
+ # and managed by kdump service
+ ;;
+ remove)
+ rm -f -- "$FADUMP_INITRD_DIR_ABS/$FADUMP_INITRD"
+ ret=$?
+ ;;
+esac
+exit $ret
diff --git a/kexec-tools.spec b/kexec-tools.spec
index bfa7a5b..d4c3590 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -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
@@ -203,6 +204,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
@@ -365,6 +367,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