Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 415359

Summary: [systemd overlay] sys-apps/systemd-units: Support kexec
Product: Gentoo Linux Reporter: Dennis Schridde <dschridde+gentoobugs>
Component: [OLD] Core systemAssignee: Henry Gebhardt <hsggebhardt>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: kexec-load@.service
kernel/postinst.d hook

Description Dennis Schridde 2012-05-10 11:56:04 UTC
sys-apps/kexec-tools provides /etc/init.d/kexec which greatly speeds up reboots. It would be nice if systemd would have similar support.

Reproducible: Always
Comment 1 Henry Gebhardt 2012-05-10 19:21:09 UTC
I think the "systemctl kexec" option has this already implemented in terms of a kexec.target, at least with version systemd-44-r1. I haven't actually tried it. Does that do what you want?
Comment 2 Dennis Schridde 2012-05-10 19:56:02 UTC
(In reply to comment #1)
> I think the "systemctl kexec" option has this already implemented in terms
> of a kexec.target, at least with version systemd-44-r1. I haven't actually
> tried it. Does that do what you want?
Do you know how it works? I.e. whether it mounts /boot, how it finds the kernel to execute, etc? Is it installed via "systemctl enable kexec.target"?
Comment 3 Dennis Schridde 2012-05-10 20:02:16 UTC
See for example: http://lists.freedesktop.org/archives/systemd-devel/2012-March/004760.html
It appears that the issue is not entirely solved within systemd, but needs a service file to load the kernel as an additional step.
Comment 4 Henry Gebhardt 2012-05-10 21:40:31 UTC
Also see: http://lists.freedesktop.org/archives/systemd-devel/2012-March/004782.html
The solution discussed there does not seem to be implemented in systemd git yet, since I cannot find any reference to kexec-load in the repo.

In any case it seems you need to customize the service file for your particular kernel. I guess it is best to ask on the systemd (or kexec) mailing list for help on this.
Comment 5 Dennis Schridde 2012-05-10 21:56:37 UTC
(In reply to comment #4)
> In any case it seems you need to customize the service file for your
> particular kernel.
/etc/init.d/kexec did this pretty well and automatic. Can't we just continue to use that script?
Comment 6 Henry Gebhardt 2012-05-10 23:45:09 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > In any case it seems you need to customize the service file for your
> > particular kernel.
> /etc/init.d/kexec did this pretty well and automatic. Can't we just continue
> to use that script?

Since I have virtually no idea about kexec, you are probably better off discussing this on the systemd or kexec mailing lists, and with the gentoo kexec-tools maintainer (feel free to cc me). The script could be used as the basis for two new command-line options to kexec (or a wrapper). The first to try to determine the kernel image and initrd automatically. The second to read these from a configuration file.

Also note that the script is an openrc script, not sysvinit, so it is most likely incompatible with systemd.
Comment 7 Dennis Schridde 2013-04-21 11:20:34 UTC
Created attachment 346182 [details]
kexec-load@.service

kexec-load@.service file, copied from Arch [1] and adapted to Gentoo.

[1] https://wiki.archlinux.org/index.php/Kexec#Systemd
Comment 8 Dennis Schridde 2013-04-21 11:23:45 UTC
Created attachment 346184 [details]
kernel/postinst.d hook

I use attached hook to enable the last-built kernel version for kexec-load. Since only one kernel can be loaded, the script disables all previously installed kexec-load@.services.

Place this file in /etc/kernel/postinst.d/90_kexec, mark it executable (chmod +x) and run "make install" in your kernel sources.
Comment 9 Dennis Schridde 2013-04-21 11:30:17 UTC
(In reply to comment #7)
> adapted to Gentoo

Gentoo has kexec in /usr/sbin instead of /sbin and the -gentoo suffix to kernel names requires %i (raw instance name) to be used instead of %I (unescaped instance name) -- otherwise a version like 3.8.8-gentoo ends up as 3.8.8/gentoo when systemd unescapes it for the ExecStart commandline.

* If you do not want to use the kernel/postinst.d hook, you can run following command manually instead:
  # systemctl enable kexec-load@3.8.8-gentoo
* This requires /boot/vmlinuz-3.8.8-gentoo and /boot/initramfs-3.8.8-gentoo.img to exist (adapt accordingly for other kernel versions).
* You have to ensure yourself that only one such service is enabled at a time. No idea what happens otherwise -- probably a random kernel is loaded instead of the one you expect (the one whose service file systemd executes last).
Comment 10 Henry Gebhardt 2013-04-21 15:52:33 UTC
Thanks! I committed your changes.
Comment 11 Dennis Schridde 2013-04-21 16:13:50 UTC
(In reply to comment #10)
> Thanks! I committed your changes.

Thanks a bunch! Good idea warning the user in pkg_postinst about the kernel/postinst.d file and not making it executable by default. :)