howdy folks,
i've had a bit of a hiatus of internet access and just catching up with mails i notice a recurring systemd related spark about boot times. please this message is not to recreate a flame but to suggest something that may benefit folks from all preferred init systems.

kexec is a great little utility. when you run "/etc/init.d/kexec start" it creates references in the existing kernel for a soft reboot into a new kernel. you can then at a time of your choosing run "reboot" and the system will appear to go through a clean shutdown cycle, but instead of triggering the power cycle, it will access the referenced kernel and initram and load them into memory as though we are just coming from the grub boot menu. the kernel image and initramfs must be visible at the time you choose to reboot.

from a forensics / debugging / kdump crash handling point of view this has great benefit because memory state remains the same when the system starts. (in fact for full access you need to use crash mode of "kexec -p" otherwise you overwrite bits when you boot and start services)

from a "reboot a remote computer into a new (tested?) kernel and initram in very little time" point of view this means you do not need to wait for bios / uefi / raid bios / 24 disk raid spinup cycle / 24GB memory test to complete. sure if you are looking to reset faulty hardware like a stuck tape drive or graphics card this is not great. however, as the new kernel need not be identical to the existing kernel, it does mean you can upgrade then reboot a lot faster.

using the tools manally is possible too -- /etc/init.d/kexec automounts boot and searches for the bits to use. you can do it manually by

## load a kernel and initram
kexec -l /boot/vmlinux --append=dolvm, root=/dev/vg/root --initrd=/boot/initrd

## reboot hard and fast into new kernel (warning does not go through shutdown so mounted fs acts as though you hit the reset button)
kexec      -e

let's say you have some remote or embedded systems that you want to upgrade the kernel for. if you have loadable modules you need to rsync /lib/modules/ otherwise you just need to scp the kernel and initram (if you have one) over then kexec it. no more waiting for device reset scans, just reload the operating system with #/etc/init.d/kexec restart
followed by
# reboot

this is especially handy as grub2 has a few quirks regarding 'failsafe' menu choices, so doing things this way you can have grub2 still boot 'actuallyworks-vmlinuz' and then from ssh run kexec to 'testing-vmlinuz'

hope this has been interesting!

Reply via email to