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.
This (unanswered) askubuntu still comes up high in the search results.
Here are several howtos from good sources that address this question:
https://www.tomica.net/blog/2019/03/reboot-with-kexec-on-ubuntu-18-04/
https://www.linux.com/news/reboot-racecar-kexec/
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:
https://wiki.ubuntu.com/RapidReboot
So, as of 21.10 (and Kubuntu), it works as long as one starts using
systemd-boot
instead ofGRUB2
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/unmodeset.service
In my case, some jobs took 90 seconds to shut down. Tinkering with these values in
/etc/systemd/systemd.conf
helped:To make it the default reboot action when invoked from GNOME seems to be impossible. Per https://github.com/systemd/systemd/issues/15029#issuecomment-981781792 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: https://github.com/sddm/sddm/issues/434