How can I make Ubuntu default to reboot using kexec (with EFI)?

What would be the proper way to make Ubuntu reboot using kexec by default (especially when the reboot is initiated from the GUI)?

I found this kexec reboot script, that when downloaded and run with sudo kexec-reboot -l -r reboots the kernel with kexec (does not go through EFI).

How can I make it so that choosing reboot from a GUI results in a kexec reboot? I am using Unity 7. It used to work just by installing the package and configuring it with dpkg, but that says it is System-V only and now we are using systemd.

1

2 Answers

This (unanswered) askubuntu still comes up high in the search results.
Here are several howtos from good sources that address this question:


And, it appears that an effort to make it part of Ubuntu itself is in the specification stage. In can function as both a supplemental how-to and points out several unresolved issues:

2

So, as of 21.10 (and Kubuntu), it works as long as one starts using systemd-boot instead of GRUB2 to start up the machine - that will also likely speed up boot by several seconds. Details are here: How to replace grub with bootloader "systemd-boot" in ubuntu 20.04?

Once that is ready, sudo systemctl kexec just works.

It might be necessary to create a new systemd unit in case you are using Nvidia card and several monitors (and maybe even if not).

sudo gedit /usr/lib/systemd/system/umodeset.service

[Unit]
Description=Unload nvidia modesetting modules from kernel
Documentation=man:modprobe(8)fi
DefaultDependencies=no
After=umount.target
Before=kexec.target
[Service]
Type=oneshot
ExecStart=modprobe -r nvidia_drm

In my case, some jobs took 90 seconds to shut down. Tinkering with these values in /etc/systemd/system.conf helped:

DefaultTimeoutStartSec=3s
DefaultTimeoutStopSec=3s
DefaultStartLimitIntervalSec=2s

To make it the default reboot action when invoked from GNOME seems to be impossible. Per they call logind directly, so without patching the software this is impossible. Good luck convincing GNOME developers about this. In KDE, the feature to override reboot action is in SDDM, but is broken right now:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like