Eu descobri uma maneira de fazer um script de carregamento do kexec que funciona bem e irá carregar o kernel padrão no grub, o que significa que ele deve carregar o novo kernel após uma atualização do kernel.
File: /usr/bin/kexec-load
#!/usr/bin/env bash
GRUBBY_FILE="/var/log/grubby"
TMP=$(mktemp)
# Command "grubby --default-kernel" has a bug/feature that fsyncs
# after writting each line to a debug log file, making it slow (several seconds).
# Workaround is to write to /dev/null instead.
if [ -e $GRUBBY_FILE ]
then rm -f $GRUBBY_FILE
fi
ln -s /dev/null $GRUBBY_FILE
KERNEL_IMG=$(grubby --default-kernel)
unlink $GRUBBY_FILE
# Get the detailed information of the default kernel (as seen by grub)
# This will create a temporary file in /tmp
grubby --info=$KERNEL_IMG | grep -v title > $TMP
source $TMP
rm $TMP
# Simple log to see if this script gets executed
date --rfc-3339=seconds >> /var/log/kexec
# Load (prepare) the kernel for execution
kexec -l $kernel --initrd=$initrd --command-line="root=$root $args"
File: /etc/systemd/system/kexec-load.service
[Unit]
Description=loads the kernel
Documentation=man:kexec(8)
DefaultDependencies=no
Before=shutdown.target umount.target final.target
[Service]
Type=oneshot
ExecStart=/usr/bin/kexec-load
[Install]
WantedBy=kexec.target
$ chmod +x /usr/bin/kexec-load
$ systemctl enable kexec-load.service
$ systemctl kexec