1 |
howdy folks, |
2 |
i've had a bit of a hiatus of internet access and just catching up with |
3 |
mails i notice a recurring systemd related spark about boot times. |
4 |
please this message is not to recreate a flame but to suggest something |
5 |
that may benefit folks from all preferred init systems. |
6 |
|
7 |
kexec is a great little utility. when you run "/etc/init.d/kexec start" |
8 |
it creates references in the existing kernel for a soft reboot into a |
9 |
new kernel. you can then at a time of your choosing run "reboot" and |
10 |
the system will appear to go through a clean shutdown cycle, but instead |
11 |
of triggering the power cycle, it will access the referenced kernel and |
12 |
initram and load them into memory as though we are just coming from the |
13 |
grub boot menu. the kernel image and initramfs must be visible at the |
14 |
time you choose to reboot. |
15 |
|
16 |
from a forensics / debugging / kdump crash handling point of view this |
17 |
has great benefit because memory state remains the same when the system |
18 |
starts. (in fact for full access you need to use crash mode of "kexec |
19 |
-p" otherwise you overwrite bits when you boot and start services) |
20 |
|
21 |
from a "reboot a remote computer into a new (tested?) kernel and initram |
22 |
in very little time" point of view this means you do not need to wait |
23 |
for bios / uefi / raid bios / 24 disk raid spinup cycle / 24GB memory |
24 |
test to complete. sure if you are looking to reset faulty hardware like |
25 |
a stuck tape drive or graphics card this is not great. however, as the |
26 |
new kernel need not be identical to the existing kernel, it does mean |
27 |
you can upgrade then reboot a lot faster. |
28 |
|
29 |
using the tools manally is possible too -- /etc/init.d/kexec automounts |
30 |
boot and searches for the bits to use. you can do it manually by |
31 |
|
32 |
## load a kernel and initram |
33 |
kexec -l /boot/vmlinux --append=dolvm, root=/dev/vg/root |
34 |
--initrd=/boot/initrd |
35 |
|
36 |
## reboot hard and fast into new kernel (warning does not go through |
37 |
shutdown so mounted fs acts as though you hit the reset button) |
38 |
kexec -e |
39 |
|
40 |
let's say you have some remote or embedded systems that you want to |
41 |
upgrade the kernel for. if you have loadable modules you need to rsync |
42 |
/lib/modules/ otherwise you just need to scp the kernel and initram (if |
43 |
you have one) over then kexec it. no more waiting for device reset |
44 |
scans, just reload the operating system with #/etc/init.d/kexec restart |
45 |
followed by |
46 |
# reboot |
47 |
|
48 |
this is especially handy as grub2 has a few quirks regarding 'failsafe' |
49 |
menu choices, so doing things this way you can have grub2 still boot |
50 |
'actuallyworks-vmlinuz' and then from ssh run kexec to 'testing-vmlinuz' |
51 |
|
52 |
hope this has been interesting! |