kexec with kernel-preempt?

Hi,

I’d like to restart the system via kexec. While I was using kernel-default, all I had to do was to install kexec-tools, enable kexec-load.service and then run sudo systemctl kexec to restart with kexec at will.

But now, I moved from kernel-default to kernel-preempt which causes problem. When running sudo systemctl kexec, I’m getting:

david@atronach-opensuse:~> sudo systemctl kexec
No boot loader entry suitable as default, refusing to guess.

…It looks like the service still expects kernel-default.

So I tried to modify /usr/lib/systemd/system/kexec-load.service with* sudo* systemctl edit kexec-load and put a drop-in snippet to /etc/systemd/system/kexec-load.service.d/override.conf with the following content:

david@atronach-opensuse:~> cat /etc/systemd/system/kexec-load.service.d/override.conf
[Unit]
Description=load kernel into the current kernel


[Service]
ExecStart=/sbin/kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initrd-$(uname -r) --reuse-cmdline

After enabling kexec-load.service and running sudo systemctl kexec, I’m getting the same error again:

david@atronach-opensuse:~> sudo systemctl kexec
No boot loader entry suitable as default, refusing to guess.

Strangely enough, when running kexec directly without the *.service unit, it acomplishes successfully:

david@atronach-opensuse:~> sudo kexec -l /boot/vmlinuz-$(uname -r) --initrd=/boot/initrd-$(uname -r) --reuse-cmdline
david@atronach-opensuse:~> sudo kexec -e

…After that, my system restarts itself while skipping the POST phase and the bootloader during booting which is what is expected with kexec.

Do you please know wow can I integrate kexec into systemd while using kernel-preempt? Thanks.

ExecStart accepts multiple values, so your drop-in adds, not replaces it. To replace value of ExecStart in drop-in you should first clear it (ExecStart=).

You may also be interested in systemctl kexec appears to be non-functional / too strict requirements · Issue #15029 · systemd/systemd · GitHub

Yup, that was it, partially. I also had to wrap the whole command in:

/bin/bash -c "<previous cmd>"

…so the $(uname -r) variable would get expanded.

However, I’ve found out there’s nothing wrong with the default kexec-load.service. All it needed to have was to set the -preempt kernel in YaST Boot Loader as the default one. Previously, I had set the Windows item as the default one so kexec-bootloader script specified in the kexec-load.service was choking on that. After setting the default item to the preempt kernel, kexec-load successfully starts and loads the kernel-preempt into memory.