View previous topic :: View next topic |
Author |
Message |
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Sun Feb 13, 2005 4:16 pm Post subject: [HOWTO] kexec |
|
|
HOWTO kexec
kexec is a feature in some kernels (-mm for sure) that allows for
warm reboots, i.e. you do not have to go through the BIOS and
can load a kernel instantly. This HOWTO describes how to install,
setup and use kexec on a Gentoo system.
What is kexec?
kexec is a part of the Linux kernel that allows the running kernel to reboot into a new kernel. It can also be used to set up fallback kernels if a kernel panics, panic logging, and other things. This guide only covers rebooting.
Why kexec?
Rebooting using kexec is faster than rebooting normally because you do not have to go through the BIOS.
Installation
First of all, you will need a kernel with kexec support. The -mm patch series has that for example. The Gentoo package for the -mm kernel is sys-kernel/mm-sources. If you wanted to you could go and patch a kernel of your own by downloading patches from the kexec page.
To enable the kexec support in the kernel you must set the following options in the kernel menuconfig:
Code: | Code maturity level options ---> Prompt for development and/or incomplete code/drivers [y]
Processor type and features ---> kexec system call [y] |
After doing that, compile the kernel, install it, and reboot.
Now you will need the userland kexec-tools package, it is currently ~x86 masked, so you will have to unmask it. These commands will unmask and install the package:
Code: | echo sys-apps/kexec-tools ~x86 >> /etc/portage/package.keywords
emerge -av sys-apps/kexec-tools |
This will install the kexec binary, an init.d script and a conf.d configuration file.
Configuration
You might have to change some options in the configuration file, open up /etc/conf.d/kexec in your favorite editor. The defaults are (not what is commented out, see /etc/init.d/kexec):
Code: | BOOTPART="/boot"
BOOTMOUNT=1
KNAME="bzImage"
KPARAM=""
INITRD="" |
ROOTPART is autodetected by scanning your /etc/fstab for the root partition. You will want to change the KPARAM to what you boot your kernel with from /etc/boot/grub/grub.conf, and perhaps put something in the INITRD variable too if you want/need that. (I have no experience with that.)
To have kexec automatically load your current kernel at boot, add kexec to the boot runlevel.
Code: | rc-update add kexec boot |
To load the kernel run rc to let the initscripts handle everything (it will start all services you have manually stopped too).
Or alternatively just launch it directly using the script.
Code: | /etc/init.d/kexec start |
Loading a kernel does not actually boot it, it just loads it somewhere in memory. To actually load the kernel you can do kexec -e. Do not do that though, it will reboot right away without unmounting or killing processes. What you want to do is change /etc/init.d/reboot.sh to use kexec when rebooting. My script contains this:
Code: | /sbin/kexec -e
/sbin/reboot -idp |
It uses the normal /sbin/reboot as a fallback if no kernel has been loaded. Your system is now ready to reboot using kexec, just issue the reboot command and your system will reboot using kexec!
You might want to know how to change the loaded kernel, for example if you want to reboot into a new kernel instead of what was loaded at boot. That is easy, just install the new kernel and restart kexec, /etc/init.d/kexec restart.
If you encounter any bugs in kexec, send them to the author ;)
Quick installation
- Enable kexec in your kernel.
- Install kexec-tools.
- Configure kexec-tools.
- Optionally add kexec to the boot runlevel.
- Hack /init.d/reboot.sh.
- reboot
--edited link to link to server processed xhtml document instead.
--added phpbb marked up version
--added FFox 1.0 bug workaround
Last edited by Leffe on Tue Feb 22, 2005 4:02 pm; edited 3 times in total |
|
Back to top |
|
|
mayday147 l33t
Joined: 22 Mar 2004 Posts: 825 Location: Bucharest, Romania
|
Posted: Sun Feb 13, 2005 4:43 pm Post subject: |
|
|
I get an error from that link:
Code: | Error loading stylesheet: (null)http://nullref.se/xslt/config.xslt.xslt |
_________________ gentoo.ro |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
|
Back to top |
|
|
j-m Retired Dev
Joined: 31 Oct 2004 Posts: 975
|
Posted: Sun Feb 13, 2005 5:37 pm Post subject: |
|
|
Leffe wrote: | mayday147 wrote: | I get an error from that link:
Code: | Error loading stylesheet: (null)http://nullref.se/xslt/config.xslt.xslt |
|
What browser might you be using? I've only tried the site in ELinks (Linux), Internet Explorer (Windows), Firefox (Windows) and Opera (Windows).
No, wait, I will make a guess (from the logs), Konqueror? Hm, I must investigate. Google suggests Firefox :/
|
Firefox 1.0 does not work for me (same error). |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Sun Feb 13, 2005 6:14 pm Post subject: |
|
|
Okay, I dropped IE support for this article and serve it as text/xml instead of the (nonstandard but working) text/xsl.
If this doesn't work I'll blame the users using more than 2 days old browsers :p |
|
Back to top |
|
|
cato` Guru
Joined: 03 Jun 2002 Posts: 430 Location: Norway, Trondheim
|
Posted: Sun Feb 13, 2005 6:16 pm Post subject: |
|
|
No formating, how about using good old HTML? _________________ Don't mess with the Penguin. |
|
Back to top |
|
|
j-m Retired Dev
Joined: 31 Oct 2004 Posts: 975
|
Posted: Sun Feb 13, 2005 6:25 pm Post subject: |
|
|
Leffe wrote: | Okay, I dropped IE support for this article and serve it as text/xml instead of the (nonstandard but working) text/xsl.
If this doesn't work I'll blame the users using more than 2 days old browsers :p |
Regarding the original link, no - it is still broken. |
|
Back to top |
|
|
Titeuf l33t
Joined: 19 Jun 2004 Posts: 759 Location: Middelkerke, Belgium
|
Posted: Sun Feb 13, 2005 7:23 pm Post subject: |
|
|
Looks interesting, does it keep your uptime ? |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Sun Feb 13, 2005 9:49 pm Post subject: |
|
|
Titeuf wrote: | Looks interesting, does it keep your uptime ? |
I'm sorry to say it does not :p
I'm sure it could be hacked somehow though. |
|
Back to top |
|
|
Titeuf l33t
Joined: 19 Jun 2004 Posts: 759 Location: Middelkerke, Belgium
|
Posted: Sun Feb 13, 2005 10:29 pm Post subject: |
|
|
Too bad.
But the better boot times will make it good, that's now one of the reasons I don't update my kernel much: too lazy to reboot |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20496
|
Posted: Mon Feb 14, 2005 4:27 am Post subject: |
|
|
DT&T is not intended for threads only linking to offsite documentation. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Mon Feb 14, 2005 12:01 pm Post subject: |
|
|
pjp wrote: | DT&T is not intended for threads only linking to offsite documentation. |
Quote: | # Provide detailed information about what your tip or trick does, and how it works.
Note: Please do not merely link to another website. | === (equ) Quote: | # Provide detailed information about what your tip or trick does and how it works if you merely link to another website. |
:/
Oh well, I ported it. |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Tue Feb 22, 2005 4:03 pm Post subject: |
|
|
Yay, I figured out the FFox bug. XSLT stylesheets must be named *.xsl, not *.xslt. |
|
Back to top |
|
|
idl Retired Dev
Joined: 24 Dec 2002 Posts: 1728 Location: Nottingham, UK
|
Posted: Wed Mar 02, 2005 7:13 pm Post subject: |
|
|
TIP: Don't build kexec-tools with a hardened toolchain, it won't work. _________________ a.k.a port001
Found a bug? Please report it: Gentoo Bugzilla |
|
Back to top |
|
|
localghost Apprentice
Joined: 28 Oct 2004 Posts: 185 Location: Sint-Niklaas, Belgium
|
Posted: Tue Mar 08, 2005 11:48 am Post subject: |
|
|
I run an AMD64 and have a gentoo-dev-sources 2.6.11-r2 kernel.
What file(s) should I download from http://www.xmission.com/~ebiederm/files/kexec/ and how do I apply them?
EDIT: never mind, I'm in the process of installing a pure 32 bit x86 installation on my AMD64. _________________ 411 /0µr 84$3 4r3 8310n9 70 µ$.
Last edited by localghost on Tue May 03, 2005 10:22 am; edited 1 time in total |
|
Back to top |
|
|
Leffe Tux's lil' helper
Joined: 07 Apr 2004 Posts: 145 Location: Sweden
|
Posted: Thu Mar 10, 2005 5:20 pm Post subject: |
|
|
I would imagine that <a href="http://www.xmission.com/~ebiederm/files/kexec/2.6.8.1-kexec3/">this</a> is your best choice. It seems to have support for x86_64 and ppc!
As for applying... put the file in your kernel directory, issue gzcat patch_file_name | patch -p1 --dry-run and pray that everything applies without problems, if that somehow is the case you can run that command again but without the --dry-run to actually apply the patch.
If you get problems... time to start hacking the kernel ;) I can't help you with that.
Using the -mm kernel is really the best idea. (you could try applying one of the <a href="http://www.xmission.com/~ebiederm/files/kexec/2.6.10-mm2-kexec3.tgz">-mm kexec patches</a>, but I would assume that they use -mm-specific functions) |
|
Back to top |
|
|
dylan_stark Tux's lil' helper
Joined: 30 Aug 2005 Posts: 135 Location: Belgrade, Serbia
|
Posted: Sat Aug 02, 2008 7:08 am Post subject: |
|
|
When I execute "kexec -e" I get message "kexec image is not loaded"???
I configured /etc/conf.d/kexec like this
Code: | # Boot partition
BOOTPART="/boot"
# Kernel name
KNAME="kernel-2.6.20"
# Root partition (should be autodetected)
ROOTPART="/dev/hda4"
# Kernel parameters (should be autodetected)
#KPARAM="splash=silent,theme:emergence"
# Initrd
#INITRD="/boot/fbsplash-emergence-1024x768"
# Load kexec kernel image into memory during shutdown instead of bootup
# (default: yes)
LOAD_DURING_SHUTDOWN="yes"
|
|
|
Back to top |
|
|
nixnut Bodhisattva
Joined: 09 Apr 2004 Posts: 10974 Location: the dutch mountains
|
Posted: Sat Aug 02, 2008 11:15 am Post subject: |
|
|
Moved from Gentoo Chat to Documentation, Tips & Tricks. _________________ Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered
talk is cheap. supply exceeds demand |
|
Back to top |
|
|
Lok n00b
Joined: 23 Mar 2006 Posts: 34
|
Posted: Sat Sep 16, 2017 2:25 pm Post subject: |
|
|
How to get dump kernel /proc/vmcore ?
# kexec -l /boot/kernel-genkernel-x86_64-4.12.12-gentoo --initrd=/boot/initramfs-genkernel-x86_64-4.12.12-gentoo --append="root=/dev/sda3 1 irqpoll maxcpus=1 reset_devices"
# kexec -e
load new kernel.
# cat /proc/cmdline
root=/dev/sda3 1 irqpoll maxcpus=1 reset_devices
But,
# kexec -p /boot/kernel-genkernel-x86_64-4.12.12-gentoo --initrd=/boot/initramfs-genkernel-x86_64-4.12.12-gentoo --append="root=/dev/sda3 1 irqpoll maxcpus=1 reset_devices"
Alt+SysRq+c = my system is freezing
if run
# kexec -p /boot/kernel-genkernel-x86_64-4.12.12-gentoo --initrd=/boot/initramfs-genkernel-x86_64-4.12.12-gentoo --append="root=/dev/sda3 1 irqpoll reset_devices"
Alt+SysRq+c = system will reboot with grub2
/proc/vmcore missing. |
|
Back to top |
|
|
|