This set tries to do a few improvements to fadump. The 1st patch makes 'zstd' as the default compression method for fadump. The next patch fixes the default initrd backup/restore logic. The 3rd patch ensures fadump initramfs is cleaned up on kernel uninstall.
Changes in v3: * Patch#1: Added Ack-by from Tao. * Patch#2: Updated the patch according to Philipp's inputs. * Patch#3: Updated the patch in accordance to changes in patch#2.
Changes in v2: * Improve changelog on why 'zstd' is used for fadump in patch#1. * Patch#2: A new patch to fix default initrd backup/restore logic. * Patch#3: Cleaning up kernel version based checksum file.
Hari Bathini (3): fadump: use 'zstd' as the default compression method fadump: fix default initrd backup and restore logic fadump: add a kernel install hook to clean up fadump initramfs
60-fadump.install | 31 +++++++++++++++++++++++++++++++ kdumpctl | 6 ++++-- kexec-tools.spec | 3 +++ mkfadumprd | 6 ++---- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100755 60-fadump.install
If available, use 'zstd' compression method to optimize the size of the initrd built with fadump support. Also, 'squash+zstd' is not preferred because more disk space is consumed with 'squash+zstd' due to the additional binaries needed for fadump with squash case.
Signed-off-by: Hari Bathini hbathini@linux.ibm.com Acked-by: Tao Liu ltao@redhat.com ---
Changes in v3: * Added Ack-by from Tao.
Changes in v2: * Updated changelog with why 'zstd' is used for fadump.
mkfadumprd | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/mkfadumprd b/mkfadumprd index 36ad645..2fc396c 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -62,11 +62,9 @@ _dracut_isolate_args=( /usr/lib/dracut/fadump-kernel-modules.txt )
-# Same as setting zstd in mkdumprd +# Use zstd compression method, if available if ! have_compression_in_dracut_args; then - if is_squash_available && dracut_have_option "--squash-compressor"; then - _dracut_isolate_args+=(--squash-compressor zstd) - elif is_zstd_command_available; then + if is_zstd_command_available; then _dracut_isolate_args+=(--compress zstd) fi fi
In case of fadump, default initrd is rebuilt with dump capturing capability, as the same initrd is used for booting production kernel as well as capture kernel.
The original initrd file is backed up with a checksum, to restore it as the default initrd when fadump is disabled. As the checksum file is not kernel version specific, switching between different kernel versions and kdump/fadump dump mode breaks the default initrd backup/restore logic. Fix this by having a kernel version specific checksum file.
Also, if backing up initrd fails, retaining the checksum file isn't useful. Remove it.
Signed-off-by: Hari Bathini hbathini@linux.ibm.com ---
Changes in v3: * Updated the patch based on Philipp's inputs.
Changes in v2: * New patch to fix default initrd backup/restore logic.
kdumpctl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kdumpctl b/kdumpctl index abfb352..af93202 100755 --- a/kdumpctl +++ b/kdumpctl @@ -9,9 +9,9 @@ KDUMP_LOG_PATH="/var/log" MKDUMPRD="/sbin/mkdumprd -f" MKFADUMPRD="/sbin/mkfadumprd" DRACUT_MODULES_FILE="/usr/lib/dracut/modules.txt" -INITRD_CHECKSUM_LOCATION="/boot/.fadump_initrd_checksum" DEFAULT_INITRD="" DEFAULT_INITRD_BAK="" +INITRD_CHECKSUM_LOCATION="" KDUMP_INITRD="" TARGET_INITRD="" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" @@ -166,7 +166,8 @@ backup_default_initrd() sha1sum "$DEFAULT_INITRD" > "$INITRD_CHECKSUM_LOCATION" if ! cp "$DEFAULT_INITRD" "$DEFAULT_INITRD_BAK"; then dwarn "WARNING: failed to backup $DEFAULT_INITRD." - rm -f "$DEFAULT_INITRD_BAK" + rm -f -- "$INITRD_CHECKSUM_LOCATION" + rm -f -- "$DEFAULT_INITRD_BAK" fi fi } @@ -317,6 +318,7 @@ setup_initrd() fi
DEFAULT_INITRD_BAK="$KDUMP_BOOTDIR/.$(basename "$DEFAULT_INITRD").default" + INITRD_CHECKSUM_LOCATION="$DEFAULT_INITRD_BAK.checksum" if [[ $DEFAULT_DUMP_MODE == "fadump" ]]; then TARGET_INITRD="$DEFAULT_INITRD"
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 ---
* Could have had 60-kdump.install.ppc64 that takes care of both kdump & fadump cleanup for ppc64 but that needs kdump cleanup code to be maintained in two files. So, preferred to go with a separate install file (60-fadump.install) instead.
Changes in v3: * Updated the checksum file cleanup according to changes in patch#2.
Changes in v2: * Added cleanup of kernel version based checksum file.
60-fadump.install | 31 +++++++++++++++++++++++++++++++ kexec-tools.spec | 3 +++ 2 files changed, 34 insertions(+) create mode 100755 60-fadump.install
diff --git a/60-fadump.install b/60-fadump.install new file mode 100755 index 0000000..75318ff --- /dev/null +++ b/60-fadump.install @@ -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 diff --git a/kexec-tools.spec b/kexec-tools.spec index ec8cc68..e863e7c 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 @@ -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
Hi Hari,
On Fri, 2 Dec 2022 18:46:48 +0530 Hari Bathini hbathini@linux.ibm.com wrote:
This set tries to do a few improvements to fadump. The 1st patch makes 'zstd' as the default compression method for fadump. The next patch fixes the default initrd backup/restore logic. The 3rd patch ensures fadump initramfs is cleaned up on kernel uninstall.
v3 looks good to me. Thanks a lot for your contribution.
For the series Reviewed-by: Philipp Rudo prudo@redhat.com
Changes in v3:
- Patch#1: Added Ack-by from Tao.
- Patch#2: Updated the patch according to Philipp's inputs.
- Patch#3: Updated the patch in accordance to changes in patch#2.
Changes in v2:
- Improve changelog on why 'zstd' is used for fadump in patch#1.
- Patch#2: A new patch to fix default initrd backup/restore logic.
- Patch#3: Cleaning up kernel version based checksum file.
Hari Bathini (3): fadump: use 'zstd' as the default compression method fadump: fix default initrd backup and restore logic fadump: add a kernel install hook to clean up fadump initramfs
60-fadump.install | 31 +++++++++++++++++++++++++++++++ kdumpctl | 6 ++++-- kexec-tools.spec | 3 +++ mkfadumprd | 6 ++---- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100755 60-fadump.install
Hi Philipp,
On 05/12/22 6:52 pm, Philipp Rudo wrote:
Hi Hari,
On Fri, 2 Dec 2022 18:46:48 +0530 Hari Bathini hbathini@linux.ibm.com wrote:
This set tries to do a few improvements to fadump. The 1st patch makes 'zstd' as the default compression method for fadump. The next patch fixes the default initrd backup/restore logic. The 3rd patch ensures fadump initramfs is cleaned up on kernel uninstall.
v3 looks good to me. Thanks a lot for your contribution.
For the series Reviewed-by: Philipp Rudo prudo@redhat.com
Thanks for the review!
Changes in v3:
- Patch#1: Added Ack-by from Tao.
- Patch#2: Updated the patch according to Philipp's inputs.
- Patch#3: Updated the patch in accordance to changes in patch#2.
Changes in v2:
- Improve changelog on why 'zstd' is used for fadump in patch#1.
- Patch#2: A new patch to fix default initrd backup/restore logic.
- Patch#3: Cleaning up kernel version based checksum file.
Hari Bathini (3): fadump: use 'zstd' as the default compression method fadump: fix default initrd backup and restore logic fadump: add a kernel install hook to clean up fadump initramfs
60-fadump.install | 31 +++++++++++++++++++++++++++++++ kdumpctl | 6 ++++-- kexec-tools.spec | 3 +++ mkfadumprd | 6 ++---- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100755 60-fadump.install
Patch set merged, thanks to Hari, Philipp and Tao!
On Fri, Dec 02, 2022 at 06:46:48PM +0530, Hari Bathini wrote:
This set tries to do a few improvements to fadump. The 1st patch makes 'zstd' as the default compression method for fadump. The next patch fixes the default initrd backup/restore logic. The 3rd patch ensures fadump initramfs is cleaned up on kernel uninstall.
Changes in v3:
- Patch#1: Added Ack-by from Tao.
- Patch#2: Updated the patch according to Philipp's inputs.
- Patch#3: Updated the patch in accordance to changes in patch#2.
Changes in v2:
- Improve changelog on why 'zstd' is used for fadump in patch#1.
- Patch#2: A new patch to fix default initrd backup/restore logic.
- Patch#3: Cleaning up kernel version based checksum file.
Hari Bathini (3): fadump: use 'zstd' as the default compression method fadump: fix default initrd backup and restore logic fadump: add a kernel install hook to clean up fadump initramfs
60-fadump.install | 31 +++++++++++++++++++++++++++++++ kdumpctl | 6 ++++-- kexec-tools.spec | 3 +++ mkfadumprd | 6 ++---- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100755 60-fadump.install
-- 2.38.1