User:Anthumchris:How to build the Alpine Linux kernel: Difference between revisions

From Alpine Linux
No edit summary
No edit summary
Line 1: Line 1:
== How build the Alpine Linux kernel ==
== How build the Alpine Linux kernel ==
A customized Alpine Linux kernel may be needed if you are experimenting with adding/removing kernel features and modules. For example, Alpine releases multiple [[Kernels|kernels]] that vary in features and file sizes.  Alpine kernels extend the standard [https://www.kernel.org/linux.html Linux kernel] and build within a few minutes to a few hours (depending on the speed of your system) using <code>[[abuild]]</code>, [https://gitlab.alpinelinux.org/alpine/aports aports], and [https://pkgs.alpinelinux.org/package/edge/main/x86_64/alpine-sdk alpine-sdk].
A customized Alpine Linux kernel may be needed if you are experimenting with adding/removing kernel modules/features. For example, Alpine releases multiple [[Kernels|kernels]] that vary in features and file sizes.  Alpine kernels extend the standard [https://www.kernel.org/linux.html Linux kernel] and build within a few minutes to a few hours (depending on the speed of your system) using <code>[[abuild]]</code>, [https://gitlab.alpinelinux.org/alpine/aports aports], and [https://pkgs.alpinelinux.org/package/edge/main/x86_64/alpine-sdk alpine-sdk].


== Before you start ==
== Before you start ==
Line 19: Line 19:
time abuild -crK
time abuild -crK
</pre>
</pre>
=== Identify backup ===
Identify the package name of your current kernel (e.g. linux-lts, linux-virt). This example shows that '''linux-lts''' is the current package that we would revert to as a backup.
<pre>
echo "kernel: $(uname -r)"
apk list --installed linux-*
</pre>
[[File:Alpine-kernel-package2.png|600px]]


=== Install ===
=== Install ===
Find the newly-build kernel file to install. This example shows how to install a newly-built x86_64 LTS kernel:
<pre>
apk add FILENAME
reboot
</pre>


Identify the package name of your current kernel. This example shows that <code>linux-lts</code> is the current package that we will later revert to.
[[File:Alpine-kernel-install.png|600px]]


After rebooting, verify the newly-installed kernel version:
<pre>
<pre>
echo "kernel: $(uname -r)"
echo "kernel: $(uname -r)"
apk list --installed linux-*
</pre>
</pre>


[[File:Alpine-kernel-package.png|600px]]
[[File:Alpine-kernel-new.png|320px]]


==== Install new kernel ====
=== Revert ===
If needed, revert to the previous '''alpine-lts''' kernel we identified earlier:
<pre>
<pre>
apk add /home/USERNAME/packages/.....................................
apk list linux-lts            # newly-compiled kernel installed
doas apk del linux-lts        # newly-compiled kernel from file
doas apk add linux-lts        # previous kernel from Alpine repo
apk list linux-lts            # previous kernel installed
reboot
</pre>
</pre>
[[File:Alpine-kernel-revert.png|465px]]


== See Also ==
== See Also ==

Revision as of 21:52, 3 December 2024

How build the Alpine Linux kernel

A customized Alpine Linux kernel may be needed if you are experimenting with adding/removing kernel modules/features. For example, Alpine releases multiple kernels that vary in features and file sizes. Alpine kernels extend the standard Linux kernel and build within a few minutes to a few hours (depending on the speed of your system) using abuild, aports, and alpine-sdk.

Before you start

A running instance of Alpine Linux and a non-root user with doas (wheel group) privileges are required to use abuild.

Build & install the kernel

Build

doas apk add alpine-sdk
doas addgroup USERNAME abuild         # your non-root user

git clone --depth 1 https://gitlab.alpinelinux.org/alpine/aports.git
abuild-keygen --append --install
doas chmod a+r /etc/apk/keys/*        # ensure keys are readable

cd aports/main/linux-lts/
time abuild -crK

Identify backup

Identify the package name of your current kernel (e.g. linux-lts, linux-virt). This example shows that linux-lts is the current package that we would revert to as a backup.

echo "kernel: $(uname -r)"
apk list --installed linux-*

Install

Find the newly-build kernel file to install. This example shows how to install a newly-built x86_64 LTS kernel:

apk add FILENAME
reboot

After rebooting, verify the newly-installed kernel version:

echo "kernel: $(uname -r)"

Revert

If needed, revert to the previous alpine-lts kernel we identified earlier:

apk list linux-lts            # newly-compiled kernel installed
doas apk del linux-lts        # newly-compiled kernel from file
doas apk add linux-lts        # previous kernel from Alpine repo
apk list linux-lts            # previous kernel installed
reboot

See Also