# Kexec

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Kexec
> Markdown URL: https://mediated.wiki/source/Kexec.md
> Source: https://en.wikipedia.org/wiki/Kexec
> Source revision: 1276493958
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Linux kernel mechanism}}
{{Use mdy dates|date=August 2015}}
{{Lowercase title}}
'''kexec''' ('''kernel execute'''), analogous to the Unix/Linux kernel call [exec](/source/Exec_(system_call)), is a mechanism of the [Linux kernel](/source/Linux_kernel) that allows booting of a new [kernel](/source/kernel_(operating_system)) from the currently running one.

==Details==
Essentially, kexec skips the [bootloader](/source/bootloader) stage and [hardware](/source/computer_hardware) initialization phase performed by the system [firmware](/source/firmware) ([BIOS](/source/BIOS) or [UEFI](/source/UEFI)), and directly loads the new kernel into [main memory](/source/main_memory) and starts executing it immediately. This avoids the long times associated with a full reboot, and can help systems to meet high-availability requirements by minimizing [downtime](/source/downtime).<ref>{{cite web
 |url=http://www.ibm.com/developerworks/linux/library/l-kexec/index.html 
 |archive-url=https://web.archive.org/web/20130121033946/http://www.ibm.com/developerworks/linux/library/l-kexec/index.html 
 |title=Reboot Linux faster using kexec 
 |date=May 4, 2004 
 |access-date=December 5, 2013 
 |archive-date=January 21, 2013 
 |author=Hariprasad Nellitheertha 
 |publisher=[IBM](/source/IBM) 
}}</ref><ref>{{cite web
 | url = https://www.linux.com/feature/150202
 | title = Reboot like a racecar with kexec
 | date = August 16, 2008
 | access-date = December 5, 2013
 | author = David Pendell
 | website = linux.com
 | archive-url = https://web.archive.org/web/20090214210229/http://www.linux.com/feature/150202
 | archive-date = February 14, 2009
 }}</ref>

While feasible, implementing a mechanism such as kexec raises two major challenges:

* Memory of the currently running kernel is overwritten by the new kernel, while the old one is still executing.
* The new kernel will usually expect all hardware devices to be in a well defined state, in which they are after a system reboot because the system firmware resets them to a "sane" state.  Bypassing a real reboot may leave devices in an unknown state, and the new kernel will have to recover from that.

Support for allowing only [signed](/source/Digital_signature) kernels to be booted through kexec was merged into version 3.17 of the [Linux kernel mainline](/source/Linux_kernel_mainline), which was released on October 5, 2014.<ref>{{cite web
 | url = http://kernelnewbies.org/Linux_3.17#head-021e2397db399ec42f5af49df263627bed81a6d5
 | title = Linux kernel 3.17, Section 1.10. Signed kexec kernels
 | date = October 5, 2014 | access-date = November 3, 2014
 | website = kernelnewbies.org
}}</ref>  This disallows a [root user](/source/root_user) to load arbitrary code via kexec and execute it, complementing the [UEFI secure boot](/source/UEFI_secure_boot) and in-kernel security mechanisms for ensuring that only signed [Linux kernel module](/source/Linux_kernel_module)s can be inserted into the running kernel.<ref>{{cite web
 | url = https://lwn.net/Articles/603116/
 | title = Reworking kexec for signatures
 | date = June 25, 2014 | access-date = August 9, 2014
 | author = Jake Edge | publisher = [LWN.net](/source/LWN.net)
}}</ref><ref>{{cite web
 | url = http://mjg59.dreamwidth.org/28746.html
 | title = Subverting security with kexec
 | date = December 3, 2013 | access-date = December 5, 2013
 | author = Matthew Garrett | website = dreamwidth.org
}}</ref><ref>{{cite web
 | url = http://www.outflux.net/blog/archives/2013/12/10/live-patching-the-kernel/
 | title = Live patching the kernel
 | date = December 10, 2013 | access-date = December 12, 2013
 | author = Kees Cook | website = outflux.net
}}</ref>

Kexec is used by [LinuxBoot](/source/LinuxBoot) to boot the main kernel from the Linux kernel located in the firmware.

== See also ==
{{Portal|Linux}}
* [kdump (Linux)](/source/kdump_(Linux)){{snd}} Linux kernel's crash dump mechanism, which internally uses kexec
* [kGraft](/source/kGraft){{snd}} Linux kernel live patching technology developed by SUSE
* [kpatch](/source/kpatch){{snd}} Linux kernel live patching technology developed by Red Hat
* [Ksplice](/source/Ksplice){{snd}} Linux kernel live patching technology developed by Ksplice, Inc. and later bought by Oracle

== References ==
{{Reflist|30em}}

{{Linux}}
{{Linux kernel}}

Category:Linux kernel features
Category:Linux kernel live patching

---
Adapted from the Wikipedia article [Kexec](https://en.wikipedia.org/wiki/Kexec) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Kexec?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
