On Mon, Aug 3, 2020 at 7:20 PM Dave Young dyoung@redhat.com wrote:
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@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
Hi Dave, thanks for your review.
Where does the KERNEL_INSTALL_MACHINE_ID come from? Does this check mean only handle the machine-id-is-used case?
Hi, it's set in environment, when being called by kernel-install.
We handle both case. And when KERNEL_INSTALL_MACHINE_ID is set, but empty, it's a special case, see: https://github.com/systemd/systemd/commit/9d8813b3
It's used for "stateless systems", I'm not very sure what is a "stateless system", but if we check 20-grub.install, 50-dracut.install in /usr/lib/kernel/install.d/, they all just exit when it's set but empty, so I think we can also just exit, just consider we don't support that kind of system for now.
But I do not understand why -x
${variable-value} means If variable not set, return value, else variable
So the if here return true, if KERNEL_INSTALL_MACHINE_ID is not set, or not empty. (the special case is only when KERNEL_INSTALL_MACHINE_ID is set, but empty, looks very strange indeed)
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?
Atomic don't allow that, but it have an early hook starts with 00-*, which stop the kernel-install from executing, to avoid removing anything, so it's OK.