9

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.

sup
  • 4,862
  • So far, I found out that when I replace GRUB with systemd-boot, I can kexec with systemdctl kexec. But no matter what I try, I cannot make it the default action for reboot. – sup Jan 04 '21 at 13:51

2 Answers2

1

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

zx485
  • 2,426
4til7
  • 11
  • Please don't just post links. If you want to help out then please add some information on how to solve the problem. We ask this because if the pages you've linked to are taken down, then the answer will no longer be useful. – Jeremy Aug 07 '21 at 01:12
  • The Wiki specification is ten years old an irelevant. Also, on recent versoins of Ubuntu, one would need to use systemd. I modifiied the question, 18.04 is not really relevant that much. – sup Aug 12 '21 at 10:57
0

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/unmodeset.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/systemd.conf helped:

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

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

sup
  • 4,862