Difference between revisions of "Kexec"

From ArchWiki
Jump to: navigation, search
(Systemd)
(discourage sysvinit)
Line 23: Line 23:
  
 
===Sysvinit===
 
===Sysvinit===
 +
 +
{{Note|The {{ic|kexec}} initscript does not use /proc/cmdline unlike the {{ic|kexec-load}} unit file in the next section.}}
  
 
First enable kexec  
 
First enable kexec  
Line 67: Line 69:
 
{{bc|1=# kexec -l /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --reuse-cmdline}}
 
{{bc|1=# kexec -l /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --reuse-cmdline}}
  
== References ==
+
==References==
  
 
<span id="Foot1">1. [http://lists.freedesktop.org/archives/systemd-devel/2012-March/004760.html <nowiki>[systemd-devel]</nowiki> Right way to do kexec]</span>
 
<span id="Foot1">1. [http://lists.freedesktop.org/archives/systemd-devel/2012-March/004760.html <nowiki>[systemd-devel]</nowiki> Right way to do kexec]</span>

Revision as of 09:43, 10 October 2012

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Kexec is a system call that enables you to load and boot into another kernel from the currently running kernel. This is useful for kernel developers or other people who need to reboot very quickly without waiting for the whole BIOS boot process to finish. Note that there may appear some problems and kexec may not work correctly for you because the devices won't fully reinitiate when using this method.

Installation

To install kexec, install the kexec-tools package which is available in the official repositories.

Rebooting using kexec

Sysvinit

Note: The kexec initscript does not use /proc/cmdline unlike the kexec-load unit file in the next section.

First enable kexec

# rc.d start kexec

To kexec, simply reboot as usual:

# init 6

Add kexec to the DAEMONS array in /etc/rc.conf to enable kexec on every reboot.

Systemd

You will need to create a new unit file, kexec-load.service, that will load the new kernel to be kexec'ed[1].

# vim /usr/lib/systemd/system/kexec-load.service
[Unit]
DefaultDependencies=no
Before=shutdown.target umount.target final.target

[Service]
Type=oneshot
ExecStart=/sbin/kexec -l /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --reuse-cmdline

[Install]
WantedBy=kexec.target

Then enable the service file

# systemctl enable kexec-load
ln -s '/usr/lib/systemd/system/kexec-load.service' '/etc/systemd/system/kexec.target.wants/kexec-load.service'

Ensure that the shutdown hook is not part of your initramfs image by removing it from the HOOKS array in /etc/mkinitcpio.conf. If it is, remove it and rebuild your initrd image with mkinitcpio -p linux.

To kexec, simply

# systemctl kexec

Manually

It is also perfectly legal to invoke kexec manually:

# kexec -l /boot/vmlinuz-linux --initrd=/boot/initramfs-linux.img --reuse-cmdline

References

1. [systemd-devel] Right way to do kexec

See also