Good suggestion, will update and include it in this patch.
On Thu, Jan 10, 2019 at 2:07 PM lijiang <lijiang(a)redhat.com> wrote:
在 2019年01月10日 13:47, Kairui Song 写道:
> 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(a)redhat.com>
> ---
> Update from V1:
>
> - Use a symlink as stable reference of installed kernel and initramfs
> and keep the installation naming same untouched, so user could know
> the installed kernel version easily.
>
> dracut-early-kdump-module-setup.sh | 5 +++++
> dracut-early-kdump.sh | 13 ++-----------
> 2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/dracut-early-kdump-module-setup.sh
b/dracut-early-kdump-module-setup.sh
> index 7613fbc..bd83ad6 100755
> --- a/dracut-early-kdump-module-setup.sh
> +++ b/dracut-early-kdump-module-setup.sh
> @@ -22,11 +22,13 @@ depends() {
>
> prepare_kernel_initrd() {
> KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
> +
> if [ -z "$KDUMP_KERNELVER" ]; then
> kdump_kver=`uname -r`
> else
> kdump_kver=$KDUMP_KERNELVER
> fi
> +
>
KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}"
> KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img"
> }
> @@ -41,4 +43,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"
> }
Thank you, Kairui.
Can we add more check conditions to this function? For example:
install() {
@@ -39,6 +44,6 @@ install() {
inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
inst_hook cmdline 00 "$moddir/early-kdump.sh"
prepare_kernel_initrd
+ if [ ! -f "$KDUMP_KERNEL" ]; then
+ derror "The file $KDUMP_KERNEL is not present."
+ exit 1
+ fi
- inst_binary "$KDUMP_KERNEL"
- inst_binary "$KDUMP_INITRD"
+ inst_binary "$KDUMP_KERNEL" "$KDUMP_KERNEL_INST_DEST"
+ inst_binary "$KDUMP_INITRD" "$KDUMP_INITRD_INST_DEST"
}
Thanks.
Lianbo
> 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()
>
--
Best Regards,
Kairui Song