Skip to content

Instantly share code, notes, and snippets.

@jdeathe
Last active September 17, 2023 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdeathe/402a76031bb8a625397d68e4d86ca16b to your computer and use it in GitHub Desktop.
Save jdeathe/402a76031bb8a625397d68e4d86ca16b to your computer and use it in GitHub Desktop.
Kernel Update with Fast-Boot via kexec

Kernel Update with Fast Boot via kexec

# <-- NOTE: This represents the command prompt of a root user

Identify the latest installed kernel

# kernel_release_default="$(
  grubby --default-kernel \
    | sed -r -e 's~^/boot/vmlinuz-(.*)$~\1~'
)"

Identify the running kernel

# kernel_release_running="$(
  uname -r
)"

Load new kernel if available and apply with fast-reboot

# if [[ ${kernel_release_default} != ${kernel_release_running} ]]; then \
  kexec --reuse-cmdline --no-checks \
    --load /boot/vmlinuz-${kernel_release_default} \
    --initrd=/boot/initramfs-${kernel_release_default}.img && \
  systemctl kexec; \
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment