Hi Kairui,
On 07/31/20 at 05:32pm, Kairui Song wrote:
Kdump service will create kdump initramfs when needed, but it
won't
clean up the kdump initramfs on kernel uninstall. So create a kernel
install hook to do the clean up job.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
60-kdump.install | 30 ++++++++++++++++++++++++++++++
kexec-tools.spec | 3 +++
2 files changed, 33 insertions(+)
create mode 100755 60-kdump.install
diff --git a/60-kdump.install b/60-kdump.install
new file mode 100755
index 0000000..0a3b40e
--- /dev/null
+++ b/60-kdump.install
@@ -0,0 +1,30 @@
+#!/usr/bin/bash
+
+COMMAND="$1"
+KERNEL_VERSION="$2"
+BOOT_DIR_ABS="$3"
+KERNEL_IMAGE="$4"
+
+if ! [[ ${KERNEL_INSTALL_MACHINE_ID-x} ]]; then
Where does the KERNEL_INSTALL_MACHINE_ID come from? Does this check
mean only handle the machine-id-is-used case?
But I do not understand why -x
I think we should also clean up the non-machine-id case, eg. delete
the /boot/initramfs-${ver}kdump.img.
BTW, does the atomic/CoreOS allow to remove a kernel?
+ exit 0
+fi
+
+if [[ -d "$BOOT_DIR_ABS" ]]; then
+ KDUMP_INITRD="initrdkdump"
+else
+ BOOT_DIR_ABS="/boot"
+ KDUMP_INITRD="initramfs-${KERNEL_VERSION}kdump.img"
+fi
+
+ret=0
+case "$COMMAND" in
+ add)
+ # Do nothing, kdump initramfs is strictly host only
+ # and managed by kdump service
+ ;;
+ remove)
+ rm -f -- "$BOOT_DIR_ABS/$KDUMP_INITRD"
+ ret=$?
+ ;;
+esac
+exit $ret
diff --git a/kexec-tools.spec b/kexec-tools.spec
index bec38f4..42b31fb 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -36,6 +36,7 @@ Source26: live-image-kdump-howto.txt
Source27: early-kdump-howto.txt
Source28: kdump-udev-throttler
Source29: kdump.sysconfig.aarch64
+Source30: 60-kdump.install
#######################################
# These are sources for mkdumpramfs
@@ -203,6 +204,7 @@ install -m 644 %{SOURCE14}
$RPM_BUILD_ROOT%{_udevrulesdir}/98-kexec.rules
install -m 644 %{SOURCE15} $RPM_BUILD_ROOT%{_mandir}/man5/kdump.conf.5
install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service
install -m 755 -D %{SOURCE22}
$RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh
+install -m 755 -D %{SOURCE30}
$RPM_BUILD_ROOT%{_prefix}/lib/kernel/install.d/60-kdump.install
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
install -m 755 makedumpfile-%{mkdf_ver}/makedumpfile
$RPM_BUILD_ROOT/usr/sbin/makedumpfile
@@ -343,6 +345,7 @@ done
%{_mandir}/man5/*
%{_unitdir}/kdump.service
%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh
+%{_prefix}/lib/kernel/install.d/60-kdump.install
%doc News
%license COPYING
%doc TODO
--
2.26.2
_______________________________________________
kexec mailing list -- kexec(a)lists.fedoraproject.org
To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org