Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] kexec
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Sun Feb 13, 2005 4:16 pm    Post subject: [HOWTO] kexec Reply with quote

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).

Code:
rc


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

  1. Enable kexec in your kernel.
  2. Install kexec-tools.
  3. Configure kexec-tools.
  4. Optionally add kexec to the boot runlevel.
  5. Hack /init.d/reboot.sh.
  6. 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
View user's profile Send private message
mayday147
l33t
l33t


Joined: 22 Mar 2004
Posts: 825
Location: Bucharest, Romania

PostPosted: Sun Feb 13, 2005 4:43 pm    Post subject: Reply with quote

I get an error from that link:
Code:
Error loading stylesheet: (null)http://nullref.se/xslt/config.xslt.xslt

_________________
gentoo.ro
Back to top
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Sun Feb 13, 2005 5:32 pm    Post subject: Reply with quote

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 :/

And you can try one of these links instead:

http://nullref.se/article/2005-02-13-howto-kexec.html
http://nullref.se/article/2005-02-13-howto-kexec.xhtml
http://nullref.se/article/2005-02-13-howto-kexec.txt
Back to top
View user's profile Send private message
j-m
Retired Dev
Retired Dev


Joined: 31 Oct 2004
Posts: 975

PostPosted: Sun Feb 13, 2005 5:37 pm    Post subject: Reply with quote

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). :wink:
Back to top
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Sun Feb 13, 2005 6:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
cato`
Guru
Guru


Joined: 03 Jun 2002
Posts: 430
Location: Norway, Trondheim

PostPosted: Sun Feb 13, 2005 6:16 pm    Post subject: Reply with quote

No formating, how about using good old HTML?
_________________
Don't mess with the Penguin.
Back to top
View user's profile Send private message
j-m
Retired Dev
Retired Dev


Joined: 31 Oct 2004
Posts: 975

PostPosted: Sun Feb 13, 2005 6:25 pm    Post subject: Reply with quote

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. :lol:
Back to top
View user's profile Send private message
Titeuf
l33t
l33t


Joined: 19 Jun 2004
Posts: 759
Location: Middelkerke, Belgium

PostPosted: Sun Feb 13, 2005 7:23 pm    Post subject: Reply with quote

Looks interesting, does it keep your uptime ?
Back to top
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Sun Feb 13, 2005 9:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
Titeuf
l33t
l33t


Joined: 19 Jun 2004
Posts: 759
Location: Middelkerke, Belgium

PostPosted: Sun Feb 13, 2005 10:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 16090
Location: Colorado

PostPosted: Mon Feb 14, 2005 4:27 am    Post subject: Reply with quote

DT&T is not intended for threads only linking to offsite documentation.
_________________
lolgov. 'cause where we're going, you don't have civil liberties.

In Loving Memory
1787 - 2008
Back to top
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Mon Feb 14, 2005 12:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Tue Feb 22, 2005 4:03 pm    Post subject: Reply with quote

Yay, I figured out the FFox bug. XSLT stylesheets must be named *.xsl, not *.xslt.
Back to top
View user's profile Send private message
idl
Retired Dev
Retired Dev


Joined: 24 Dec 2002
Posts: 1728
Location: Nottingham, UK

PostPosted: Wed Mar 02, 2005 7:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
localghost
Apprentice
Apprentice


Joined: 28 Oct 2004
Posts: 185
Location: Sint-Niklaas, Belgium

PostPosted: Tue Mar 08, 2005 11:48 am    Post subject: Reply with quote

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
View user's profile Send private message
Leffe
Tux's lil' helper
Tux's lil' helper


Joined: 07 Apr 2004
Posts: 145
Location: Sweden

PostPosted: Thu Mar 10, 2005 5:20 pm    Post subject: Reply with quote

localghost wrote:
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?


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
View user's profile Send private message
dylan_stark
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2005
Posts: 132
Location: Belgrade, Serbia

PostPosted: Sat Aug 02, 2008 7:08 am    Post subject: Reply with quote

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
View user's profile Send private message
nixnut
Administrator
Administrator


Joined: 09 Apr 2004
Posts: 10973
Location: the dutch mountains

PostPosted: Sat Aug 02, 2008 11:15 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum