leyvi wrote:... What I really want to do is this: with one command, hot-swap the kernel currently in RAM for a different one.
Not a problem that I need solving per-se, but I'd like some advice.
As others have said, it's not hot-swap, it's reboot without the BIOS/EFI stage. The new kernel does not have to be the same as the previous one, but it does have to be Linux.
On my desktop that's something between 5 and 10 seconds off a 20-40 second boot (I'm guessing, on another box, and no stop watch...). It's useful when running "git bisect", when the time saved accumulates!
To change kernels, using the Gentoo setup for OpenRc (I think it should also work for Systemd, but I don't use that), you configure /etc/kexec.conf, start the kexec service, and then reboot. I think there's some way to pass the name of the desired new kernel in the service start, but I've not tried it.
Alternatively, you should be able to load a new kernel with "kexec -l <kernelname> ...." with other appropriate parameters, and then issue "reboot -k".