Update from V2: - Add more sanitize checking and add warn to let the user aware of the risk - Split into multiple patches
Kairui Song (3): earlykdump: generate symlink with stable name to kernel image and iniramfs earlykdump: add more sanitize check when generating initramfs earlykdump: warn when installed kernel version differs from dracut target
dracut-early-kdump-module-setup.sh | 21 ++++++++++++++++++++- dracut-early-kdump.sh | 13 ++----------- 2 files changed, 22 insertions(+), 12 deletions(-)
There is currently a problem with earlykdump image building, when a user is upgrading kernel, dracut will generate new initramfs for the new kernel, and earlykdump will install currently running version of kernel into the initramfs, and remain the version based kernel image naming untouched. But after a reboot the new kernel is running, and it will try to load the image corresponding to the new kernel version by file naming.
This patch fixes the problem by creating a symlink with unified stable naming to the installed kernel image and initramfs, and use the symlink instand so it will always work despite the kernel version number change.
Signed-off-by: Kairui Song kasong@redhat.com --- dracut-early-kdump-module-setup.sh | 3 +++ dracut-early-kdump.sh | 13 ++----------- 2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index 7613fbc..c583937 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -41,4 +41,7 @@ install() { prepare_kernel_initrd inst_binary "$KDUMP_KERNEL" inst_binary "$KDUMP_INITRD" + + ln_r "$KDUMP_KERNEL" "${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}" + ln_r "$KDUMP_INITRD" "${KDUMP_BOOTDIR}/initramfs-earlykdump.img" } diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh index 34a9909..69a34eb 100755 --- a/dracut-early-kdump.sh +++ b/dracut-early-kdump.sh @@ -18,17 +18,8 @@ prepare_parameters() EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}") KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
- #make early-kdump kernel string - if [ -z "$KDUMP_KERNELVER" ]; then - EARLY_KDUMP_KERNELVER=`uname -r` - else - EARLY_KDUMP_KERNELVER=$KDUMP_KERNELVER - fi - - EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${EARLY_KDUMP_KERNELVER}${KDUMP_IMG_EXT}" - - #make early-kdump initrd string - EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${EARLY_KDUMP_KERNELVER}kdump.img" + EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}" + EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-earlykdump.img" }
early_kdump_load()
Currently when earlykdump failed to install required kernel image or initramfs, it will still install the earlykdump hook and other utils. But it won't work due to the absent of kernel image or kdump initramfs, so the hook and installed utils is meanless.
We can't simply fail dracut building, as if earlykdump is included by dracut config file, this may fail kernel update, where kernel image is installed but initramfs failed to generate, and then it will fail booting.
So this patch let it skip earlydkump install if anything is missing and give a clean error message to let the user better ware of the situation.
Signed-off-by: Kairui Song kasong@redhat.com --- dracut-early-kdump-module-setup.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index c583937..b93cc6a 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -32,13 +32,25 @@ prepare_kernel_initrd() { }
install() { + prepare_kernel_initrd + if [ ! -f "$KDUMP_KERNEL" ]; then + derror "Could not find required kernel for earlykdump," \ + "earlykdump will not work!" + return 1 + fi + if [ ! -f "$KDUMP_INITRD" ]; then + derror "Could not find required kdump initramfs for earlykdump," \ + "please ensure kdump initramfs is generated first," \ + "earlykdump will not work!" + return 1 + fi + inst_multiple tail find cut dirname hexdump inst_simple "/etc/sysconfig/kdump" inst_binary "/usr/sbin/kexec" inst_binary "/usr/bin/gawk" "/usr/bin/awk" inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh" inst_hook cmdline 00 "$moddir/early-kdump.sh" - prepare_kernel_initrd inst_binary "$KDUMP_KERNEL" inst_binary "$KDUMP_INITRD"
Previously we handled the case when the installed kernel version for early kdump is different from dracut target, it's will be better to print a warning even if installation successed, to let the user know that an different kernel is used.
No warn message will be given if the user specified a KDUMP_KERNELVER value, as in such case a different kernel version is used on purpose.
--- dracut-early-kdump-module-setup.sh | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh index b93cc6a..4e716c6 100755 --- a/dracut-early-kdump-module-setup.sh +++ b/dracut-early-kdump-module-setup.sh @@ -24,6 +24,10 @@ prepare_kernel_initrd() { KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}") if [ -z "$KDUMP_KERNELVER" ]; then kdump_kver=`uname -r` + if [ "$kernel" != "$kdump_kver" ]; then + dwarn "Using current kernel version '$kdump_kver' for early kdump," \ + "but the initrmafs is generated for kernel version '$kernel'" + fi else kdump_kver=$KDUMP_KERNELVER fi
On 01/10/19 at 04:54pm, Kairui Song wrote:
Update from V2:
- Add more sanitize checking and add warn to let the user aware of the risk
- Split into multiple patches
Kairui Song (3): earlykdump: generate symlink with stable name to kernel image and iniramfs earlykdump: add more sanitize check when generating initramfs earlykdump: warn when installed kernel version differs from dracut target
dracut-early-kdump-module-setup.sh | 21 ++++++++++++++++++++- dracut-early-kdump.sh | 13 ++----------- 2 files changed, 22 insertions(+), 12 deletions(-)
-- 2.20.1
Hi Kairui,
Still missing one patch to update early kdump howto to mention that it is not recommended to add earlykdump dracut module in dracut.conf But that can be sent out separately.
Other than that, the patches looks good.
ACK
Thanks Dave