<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bro</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bro"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Bro"/>
	<updated>2026-05-06T13:35:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Kexec&amp;diff=26103</id>
		<title>Kexec</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Kexec&amp;diff=26103"/>
		<updated>2024-01-02T14:10:10Z</updated>

		<summary type="html">&lt;p&gt;Bro: fix wiki link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:kexec}}&lt;br /&gt;
[https://en.wikipedia.org/wiki/Kexec kexec] is a system call that enables loading and booting into another kernel. This is useful for faster reboots that skip the firmware initialisation process and the bootloader.&lt;br /&gt;
&lt;br /&gt;
==Installing kexec-tools==&lt;br /&gt;
The userspace tools required to use it can be installed via {{cmd|apk add {{pkg|kexec-tools}} {{pkg|kexec-tools-doc}}}} The tools are not available on all flavors of Alpine, additionally not all kernels are compiled with the kexec syscall enabled. You will most likely want to check your {{path|/boot/config-*}} file for {{codeline|CONFIG_KEXEC&amp;amp;equals;y}}&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
===Manually===&lt;br /&gt;
&lt;br /&gt;
{{note|Currently multiple initrd (e.g. for loading CPU microcode) is not supported}}&lt;br /&gt;
On a typical Alpine setup, it can be used via:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# kexec -l /boot/vmlinuz-edge --initrd \&lt;br /&gt;
    /boot/initramfs-edge --reuse-cmdline \&lt;br /&gt;
&amp;amp;&amp;amp; openrc shutdown &lt;br /&gt;
&amp;amp;#35; kexec -e}}&lt;br /&gt;
&lt;br /&gt;
Current Alpine kernels have been [https://gitlab.alpinelinux.org/alpine/aports/-/commit/909d020b81c09bf0df649f8aa6b7da10377a0667 hardened] and return&lt;br /&gt;
&amp;lt;code&amp;gt;kexec_load failed: Operation not permitted&amp;lt;/code&amp;gt;&lt;br /&gt;
if kexec is called without unlocking it with the kernel boot parameter&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;kexec_load_disabled=0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Without it the [https://linux.die.net/man/8/sysctl sysctl setting] &amp;lt;code&amp;gt;kernel.kexec_load_disabled&amp;lt;/code&amp;gt; defaults to 1 and it can&#039;t be turned off in the running kernel, so you need to add the parameter to your [[Bootloaders|bootloader]] configuration and reboot.&lt;br /&gt;
&lt;br /&gt;
There are no other Alpine-specific considerations for Kexec. Please review the man page and existing references below for more details. This page is deliberately kept short in order to avoid duplicating existing documentation.&lt;br /&gt;
&lt;br /&gt;
===Automatically on every reboot/shutdown===&lt;br /&gt;
kexec can be set to run automatically for faster rebooting. This is very useful on servers.&lt;br /&gt;
&lt;br /&gt;
First create two openrc services and edit the &amp;lt;code&amp;gt;BOOTPART&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;KERNEL&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;INITRD&amp;lt;/code&amp;gt; variables if not using the defaults:&lt;br /&gt;
{{cat|/etc/init.d/kexec-load|&amp;lt;nowiki&amp;gt;#!/sbin/openrc-run&lt;br /&gt;
description=&amp;quot;kexec for faster reboot&amp;quot;&lt;br /&gt;
# Define defaults&lt;br /&gt;
: &amp;quot;${BOOTPART:=/boot}&amp;quot;&lt;br /&gt;
: &amp;quot;${KERNEL:=vmlinuz-edge}&amp;quot;&lt;br /&gt;
: &amp;quot;${INITRD:=initramfs-edge}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
	need localmount&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start() {&lt;br /&gt;
	:&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
stop() {&lt;br /&gt;
	if ! yesno ${RC_GOINGDOWN}; then&lt;br /&gt;
		einfo &amp;quot;kexec-load: Not rebooting or powering off; not loading kernel&amp;quot;&lt;br /&gt;
		exit&lt;br /&gt;
	fi&lt;br /&gt;
	ebegin &amp;quot;kexec-load: loading kernel for faster reboot&amp;quot;&lt;br /&gt;
	kexec -l &amp;quot;${BOOTPART}/${KERNEL}&amp;quot; \&lt;br /&gt;
		--initrd &amp;quot;${BOOTPART}/${INITRD}&amp;quot; \&lt;br /&gt;
		--reuse-cmdline&lt;br /&gt;
	ewend $? Failed.&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
{{cat|/etc/init.d/kexec-exec|&amp;lt;nowiki&amp;gt;#! /sbin/openrc-run&lt;br /&gt;
description=&amp;quot;kexec for faster reboot&amp;quot;&lt;br /&gt;
depend() {&lt;br /&gt;
	after killprocs savecache mount-ro&lt;br /&gt;
}&lt;br /&gt;
start() {&lt;br /&gt;
	ebegin &amp;quot;kexec-exec: Using kexec for faster reboot&amp;quot; &lt;br /&gt;
	kexec -e&lt;br /&gt;
	ewend $? &amp;quot;kexec-exec No kernel loaded.&amp;quot;&lt;br /&gt;
	return 0&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Now give these services execute permission and assign them to the appropriate runlevels:&lt;br /&gt;
{{cmd|chmod a+x /etc/init.d/kexec-load&lt;br /&gt;
chmod a+x /etc/init.d/kexec-exec&lt;br /&gt;
rc-update add kexec-load default&lt;br /&gt;
rc-update add kexec-exec shutdown&lt;br /&gt;
rc-service kexec-load start&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
kexec will run on your next &amp;lt;code&amp;gt;reboot&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;poweroff&amp;lt;/code&amp;gt; enjoy!&lt;br /&gt;
&lt;br /&gt;
{{Note|With both of the above service enabled, the system will reboot via kexec even if you are attempting to &amp;lt;code&amp;gt;poweroff&amp;lt;/code&amp;gt;. To temporarily restore default &amp;lt;code&amp;gt;poweroff&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;reboot&amp;lt;/code&amp;gt; behavior, simply run &amp;lt;code&amp;gt;rc-service kexec-load stop&amp;lt;/code&amp;gt; beforehand.}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/log/ kexec-tools changelog]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Kexec Gentoo Wiki: Kexec]&lt;br /&gt;
* [https://wiki.archlinux.org/title/Kexec ArchWiki: Kexec]&lt;br /&gt;
[[Category: Booting]]&lt;br /&gt;
[[Category: Kernel]]&lt;/div&gt;</summary>
		<author><name>Bro</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Kexec&amp;diff=26102</id>
		<title>Kexec</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Kexec&amp;diff=26102"/>
		<updated>2024-01-02T14:03:38Z</updated>

		<summary type="html">&lt;p&gt;Bro: Explain the boot parameter kexec_load_disabled=0 which unlocks kexec in current (hardened) Alpine kernels.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:kexec}}&lt;br /&gt;
[https://en.wikipedia.org/wiki/Kexec kexec] is a system call that enables loading and booting into another kernel. This is useful for faster reboots that skip the firmware initialisation process and the bootloader.&lt;br /&gt;
&lt;br /&gt;
==Installing kexec-tools==&lt;br /&gt;
The userspace tools required to use it can be installed via {{cmd|apk add {{pkg|kexec-tools}} {{pkg|kexec-tools-doc}}}} The tools are not available on all flavors of Alpine, additionally not all kernels are compiled with the kexec syscall enabled. You will most likely want to check your {{path|/boot/config-*}} file for {{codeline|CONFIG_KEXEC&amp;amp;equals;y}}&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
===Manually===&lt;br /&gt;
&lt;br /&gt;
{{note|Currently multiple initrd (e.g. for loading CPU microcode) is not supported}}&lt;br /&gt;
On a typical Alpine setup, it can be used via:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|# kexec -l /boot/vmlinuz-edge --initrd \&lt;br /&gt;
    /boot/initramfs-edge --reuse-cmdline \&lt;br /&gt;
&amp;amp;&amp;amp; openrc shutdown &lt;br /&gt;
&amp;amp;#35; kexec -e}}&lt;br /&gt;
&lt;br /&gt;
Current Alpine kernels have been [https://gitlab.alpinelinux.org/alpine/aports/-/commit/909d020b81c09bf0df649f8aa6b7da10377a0667 hardened] and return&lt;br /&gt;
&amp;lt;code&amp;gt;kexec_load failed: Operation not permitted&amp;lt;/code&amp;gt;&lt;br /&gt;
if kexec is called without unlocking it with the kernel boot parameter&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;kexec_load_disabled=0&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Without it the [https://linux.die.net/man/8/sysctl sysctl setting] &amp;lt;code&amp;gt;kernel.kexec_load_disabled&amp;lt;/code&amp;gt; defaults to 1 and it can&#039;t be turned off in the running kernel, so you need to add the parameter to your [[#Bootloaders|bootloader]] configuration and reboot.&lt;br /&gt;
&lt;br /&gt;
There are no other Alpine-specific considerations for Kexec. Please review the man page and existing references below for more details. This page is deliberately kept short in order to avoid duplicating existing documentation.&lt;br /&gt;
&lt;br /&gt;
===Automatically on every reboot/shutdown===&lt;br /&gt;
kexec can be set to run automatically for faster rebooting. This is very useful on servers.&lt;br /&gt;
&lt;br /&gt;
First create two openrc services and edit the &amp;lt;code&amp;gt;BOOTPART&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;KERNEL&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;INITRD&amp;lt;/code&amp;gt; variables if not using the defaults:&lt;br /&gt;
{{cat|/etc/init.d/kexec-load|&amp;lt;nowiki&amp;gt;#!/sbin/openrc-run&lt;br /&gt;
description=&amp;quot;kexec for faster reboot&amp;quot;&lt;br /&gt;
# Define defaults&lt;br /&gt;
: &amp;quot;${BOOTPART:=/boot}&amp;quot;&lt;br /&gt;
: &amp;quot;${KERNEL:=vmlinuz-edge}&amp;quot;&lt;br /&gt;
: &amp;quot;${INITRD:=initramfs-edge}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
depend() {&lt;br /&gt;
	need localmount&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
start() {&lt;br /&gt;
	:&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
stop() {&lt;br /&gt;
	if ! yesno ${RC_GOINGDOWN}; then&lt;br /&gt;
		einfo &amp;quot;kexec-load: Not rebooting or powering off; not loading kernel&amp;quot;&lt;br /&gt;
		exit&lt;br /&gt;
	fi&lt;br /&gt;
	ebegin &amp;quot;kexec-load: loading kernel for faster reboot&amp;quot;&lt;br /&gt;
	kexec -l &amp;quot;${BOOTPART}/${KERNEL}&amp;quot; \&lt;br /&gt;
		--initrd &amp;quot;${BOOTPART}/${INITRD}&amp;quot; \&lt;br /&gt;
		--reuse-cmdline&lt;br /&gt;
	ewend $? Failed.&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
{{cat|/etc/init.d/kexec-exec|&amp;lt;nowiki&amp;gt;#! /sbin/openrc-run&lt;br /&gt;
description=&amp;quot;kexec for faster reboot&amp;quot;&lt;br /&gt;
depend() {&lt;br /&gt;
	after killprocs savecache mount-ro&lt;br /&gt;
}&lt;br /&gt;
start() {&lt;br /&gt;
	ebegin &amp;quot;kexec-exec: Using kexec for faster reboot&amp;quot; &lt;br /&gt;
	kexec -e&lt;br /&gt;
	ewend $? &amp;quot;kexec-exec No kernel loaded.&amp;quot;&lt;br /&gt;
	return 0&lt;br /&gt;
}&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Now give these services execute permission and assign them to the appropriate runlevels:&lt;br /&gt;
{{cmd|chmod a+x /etc/init.d/kexec-load&lt;br /&gt;
chmod a+x /etc/init.d/kexec-exec&lt;br /&gt;
rc-update add kexec-load default&lt;br /&gt;
rc-update add kexec-exec shutdown&lt;br /&gt;
rc-service kexec-load start&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
kexec will run on your next &amp;lt;code&amp;gt;reboot&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;poweroff&amp;lt;/code&amp;gt; enjoy!&lt;br /&gt;
&lt;br /&gt;
{{Note|With both of the above service enabled, the system will reboot via kexec even if you are attempting to &amp;lt;code&amp;gt;poweroff&amp;lt;/code&amp;gt;. To temporarily restore default &amp;lt;code&amp;gt;poweroff&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;reboot&amp;lt;/code&amp;gt; behavior, simply run &amp;lt;code&amp;gt;rc-service kexec-load stop&amp;lt;/code&amp;gt; beforehand.}}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/log/ kexec-tools changelog]&lt;br /&gt;
* [https://wiki.gentoo.org/wiki/Kexec Gentoo Wiki: Kexec]&lt;br /&gt;
* [https://wiki.archlinux.org/title/Kexec ArchWiki: Kexec]&lt;br /&gt;
[[Category: Booting]]&lt;br /&gt;
[[Category: Kernel]]&lt;/div&gt;</summary>
		<author><name>Bro</name></author>
	</entry>
</feed>