I want to use kexec to speed up reboots of my CentOS 7 machine. How can I do that in a way that nicely integrates with existing shutdown/reboot systemd targets? What’s the proper (official) way to do this?
This is pretty straightforward.
First stage the kernel to be booted:
kexec -l /boot/vmlinuz-3.10.0-123.6.3.el7.x86_64 --initrd=/boot/initramfs-3.10.0-123.6.3.el7.x86_64.img --command-line="root=/dev/mapper/centos-root ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet LANG=en_US.UTF-8"
These options having been swiped out of the generated grub configuration.
Now tell systemd to do its magic.
systemctl start kexec.target
A few seconds later, you will be up in your new kernel.
I’ve recently written a distribution-agnostic script to help automate this (bug reports welcome).
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.