Skip to content

Instantly share code, notes, and snippets.

@jdeathe
Last active September 17, 2023 20:37
Show Gist options
  • Select an option

  • Save jdeathe/402a76031bb8a625397d68e4d86ca16b to your computer and use it in GitHub Desktop.

Select an option

Save jdeathe/402a76031bb8a625397d68e4d86ca16b to your computer and use it in GitHub Desktop.

Revisions

  1. jdeathe revised this gist Sep 17, 2023. No changes.
  2. jdeathe revised this gist Sep 17, 2023. 1 changed file with 2 additions and 7 deletions.
    9 changes: 2 additions & 7 deletions kernel-update-with-fast-boot-via-kexec.md
    Original file line number Diff line number Diff line change
    @@ -7,13 +7,8 @@
    ## Identify the latest installed kernel
    ```
    # kernel_release_default="$(
    find /boot/ -name "$(
    grubby --default-kernel \
    | sed -r -e 's~^(/boot/)(vmlinuz-[0-9]+).*$~\2~'
    )"* \
    | sort -rg -t. -k 2 -k 3 -k 4 -k 5 -k 6 \
    | head -n1 \
    | sed -r -e 's~^/boot/vmlinuz-~~'
    grubby --default-kernel \
    | sed -r -e 's~^/boot/vmlinuz-(.*)$~\1~'
    )"
    ```

  3. jdeathe revised this gist Sep 17, 2023. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions kernel-update-with-fast-boot-via-kexec.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@

    ## Identify the latest installed kernel
    ```
    # kernel_default="$(
    # kernel_release_default="$(
    find /boot/ -name "$(
    grubby --default-kernel \
    | sed -r -e 's~^(/boot/)(vmlinuz-[0-9]+).*$~\2~'
    @@ -19,17 +19,17 @@

    ## Identify the running kernel
    ```
    # kernel_running="$(
    # kernel_release_running="$(
    uname -r
    )"
    ```

    ## Load new kernel if available and apply with fast-reboot
    ```
    # if [[ ${kernel_default} != ${kernel_running} ]]; then \
    # if [[ ${kernel_release_default} != ${kernel_release_running} ]]; then \
    kexec --reuse-cmdline --no-checks \
    --load /boot/vmlinuz-${kernel_default} \
    --initrd=/boot/initramfs-${kernel_default}.img && \
    --load /boot/vmlinuz-${kernel_release_default} \
    --initrd=/boot/initramfs-${kernel_release_default}.img && \
    systemctl kexec; \
    fi
    ```
  4. jdeathe revised this gist Sep 17, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions kernel-update-with-fast-boot-via-kexec.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@

    ## Identify the latest installed kernel
    ```
    # kernel_release="$(
    # kernel_default="$(
    find /boot/ -name "$(
    grubby --default-kernel \
    | sed -r -e 's~^(/boot/)(vmlinuz-[0-9]+).*$~\2~'
    @@ -26,10 +26,10 @@

    ## Load new kernel if available and apply with fast-reboot
    ```
    # if [[ ${kernel_release} != ${kernel_running} ]]; then \
    # if [[ ${kernel_default} != ${kernel_running} ]]; then \
    kexec --reuse-cmdline --no-checks \
    --load /boot/vmlinuz-${kernel_release} \
    --initrd=/boot/initramfs-${kernel_release}.img && \
    --load /boot/vmlinuz-${kernel_default} \
    --initrd=/boot/initramfs-${kernel_default}.img && \
    systemctl kexec; \
    fi
    ```
  5. jdeathe revised this gist Sep 16, 2023. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions kernel-update-with-fast-boot-via-kexec.md
    Original file line number Diff line number Diff line change
    @@ -8,12 +8,12 @@
    ```
    # kernel_release="$(
    find /boot/ -name "$(
    grubby --default-kernel \
    | sed -r -e 's~^(/boot/)(vmlinuz-[0-9]+).*$~\2~'
    )"* \
    | sort -rg -t. -k 2 -k 3 -k 4 -k 5 -k 6 \
    | head -n1 \
    | sed -r -e 's~^/boot/vmlinuz-~~'
    grubby --default-kernel \
    | sed -r -e 's~^(/boot/)(vmlinuz-[0-9]+).*$~\2~'
    )"* \
    | sort -rg -t. -k 2 -k 3 -k 4 -k 5 -k 6 \
    | head -n1 \
    | sed -r -e 's~^/boot/vmlinuz-~~'
    )"
    ```

  6. jdeathe revised this gist Sep 16, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion kernel-update-with-fast-boot-via-kexec.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@

    ## Load new kernel if available and apply with fast-reboot
    ```
    if [[ ${kernel_release} != ${kernel_running} ]]; then \
    # if [[ ${kernel_release} != ${kernel_running} ]]; then \
    kexec --reuse-cmdline --no-checks \
    --load /boot/vmlinuz-${kernel_release} \
    --initrd=/boot/initramfs-${kernel_release}.img && \
  7. jdeathe created this gist Sep 16, 2023.
    35 changes: 35 additions & 0 deletions kernel-update-with-fast-boot-via-kexec.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Kernel Update with Fast Boot via kexec

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

    ## Identify the latest installed kernel
    ```
    # kernel_release="$(
    find /boot/ -name "$(
    grubby --default-kernel \
    | sed -r -e 's~^(/boot/)(vmlinuz-[0-9]+).*$~\2~'
    )"* \
    | sort -rg -t. -k 2 -k 3 -k 4 -k 5 -k 6 \
    | head -n1 \
    | sed -r -e 's~^/boot/vmlinuz-~~'
    )"
    ```

    ## Identify the running kernel
    ```
    # kernel_running="$(
    uname -r
    )"
    ```

    ## Load new kernel if available and apply with fast-reboot
    ```
    if [[ ${kernel_release} != ${kernel_running} ]]; then \
    kexec --reuse-cmdline --no-checks \
    --load /boot/vmlinuz-${kernel_release} \
    --initrd=/boot/initramfs-${kernel_release}.img && \
    systemctl kexec; \
    fi
    ```