* [gentoo-user] kexec
@ 2014-11-17 1:52 thegeezer
2014-11-17 3:25 ` wraeth
0 siblings, 1 reply; 4+ messages in thread
From: thegeezer @ 2014-11-17 1:52 UTC (permalink / raw
To: gentoo-user
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!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] kexec
2014-11-17 1:52 [gentoo-user] kexec thegeezer
@ 2014-11-17 3:25 ` wraeth
2014-11-17 3:36 ` Rich Freeman
2014-11-17 19:38 ` thegeezer
0 siblings, 2 replies; 4+ messages in thread
From: wraeth @ 2014-11-17 3:25 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1918 bytes --]
On Mon, Nov 17, 2014 at 01:52:28AM +0000, thegeezer wrote:
> 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.
I've heard a little about this and have been curious to try it, but
haven't had the opportunity to dig into it yet.
> 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
/etc/init.d/kexec - is this a SysV/OpenRC-based init script? How does it
play with systemd, do you know?
> ## 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
Would I be correct in guessing that this is dependant on
sys-apps/kexec-tools being installed and CONFIG_KEXEC being enabled in
the kernel? And, with CONFIG_KEXEC, is that required for the old kernel,
new kernel or both?
Also, how would one go about manually using kexec while still adhearing
to a clean shutdown (going down through init, rather than just "reset"
into the new kernel)?
> hope this has been interesting!
It has, and having read this I'm going to try and play around with it in
the next couple of days.
Thanks for the info on it.
Cheers.
--
wraeth <wraeth@wraeth.id.au>
GnuPG Key: B2D9F759
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] kexec
2014-11-17 3:25 ` wraeth
@ 2014-11-17 3:36 ` Rich Freeman
2014-11-17 19:38 ` thegeezer
1 sibling, 0 replies; 4+ messages in thread
From: Rich Freeman @ 2014-11-17 3:36 UTC (permalink / raw
To: gentoo-user
On Sun, Nov 16, 2014 at 10:25 PM, wraeth <wraeth@wraeth.id.au> wrote:
> On Mon, Nov 17, 2014 at 01:52:28AM +0000, thegeezer wrote:
>
>> 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
>
> /etc/init.d/kexec - is this a SysV/OpenRC-based init script? How does it
> play with systemd, do you know?
Kexec is a generic tool. The init.d script is openrc-specific. If
you have a kernel loaded, you can reboot to it in systemd by just
running systemctl kexec - that will shutdown the system and run the
new kernel. You can also set up a systemd unit to load the kernel at
boot time - kexec-tools installs one such unit already, and arch has
an example of an instance-based one.
>
> Would I be correct in guessing that this is dependant on
> sys-apps/kexec-tools being installed and CONFIG_KEXEC being enabled in
> the kernel? And, with CONFIG_KEXEC, is that required for the old kernel,
> new kernel or both?
Yes, and I believe it is needed for the running kernel (though you'd
probably want it on the new one too).
>
> Also, how would one go about manually using kexec while still adhearing
> to a clean shutdown (going down through init, rather than just "reset"
> into the new kernel)?
kexec -e is the command you want to run when you're ready to reboot.
Obviously you don't want to run that until you're shut down. How to
shut down is a function of your init implementation.
--
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] kexec
2014-11-17 3:25 ` wraeth
2014-11-17 3:36 ` Rich Freeman
@ 2014-11-17 19:38 ` thegeezer
1 sibling, 0 replies; 4+ messages in thread
From: thegeezer @ 2014-11-17 19:38 UTC (permalink / raw
To: gentoo-user
On 17/11/14 03:25, wraeth wrote:
> Would I be correct in guessing that this is dependant on
> sys-apps/kexec-tools being installed and CONFIG_KEXEC being enabled in
> the kernel?
correct.
> And, with CONFIG_KEXEC, is that required for the old kernel, new
> kernel or both?
just the one you are kexec'ing from. the new one could be a buntu kernel
with completely different root=
> Also, how would one go about manually using kexec while still
> adhearing to a clean shutdown (going down through init, rather than
> just "reset" into the new kernel)?
don't know in systemd but in openrc it would be stop all running services.
umount everything except root
remount root with option readonly
kexec -e
>> hope this has been interesting!
> It has, and having read this I'm going to try and play around with it in
> the next couple of days.
please do let us know how you get on :)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-17 19:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-17 1:52 [gentoo-user] kexec thegeezer
2014-11-17 3:25 ` wraeth
2014-11-17 3:36 ` Rich Freeman
2014-11-17 19:38 ` thegeezer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox