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

From Alpine Linux
(Created page with "== How To Do Something == Summarize your article here so readers can decide quickly whether to read it. == Before You Start Title == Your readers might need to get ready before they can do the work. If so explain those prerequisites first. This section might alternatively contain background information readers need to know before they can make sense of your example or carry out your instructions. == Doing Something Title == Write the steps of how to do something in...")
 
mNo edit summary
 
(33 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== How To Do Something ==
== How to build the Alpine Linux kernel ==
This [[Tutorials and Howtos|Howto]] quickly demonstrates building/compiling the default Alpine Linux [[Kernels|kernels]]. Kernel customizations (not covered here) allow you to experiment by 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].


Summarize your article here so readers can decide
== Before you start ==
quickly whether to read it.
A running instance of Alpine Linux and a non-root user with [https://pkgs.alpinelinux.org/package/edge/main/x86_64/doas doas] privileges (i.e. sudo, wheel group) are required to use <code>[[abuild]]</code>.


== Before You Start Title ==
== Build & install the kernel ==
Your readers might need to get ready before they can do the work.
If so explain those prerequisites first. This section might alternatively
contain background information readers need to know before they can make
sense of your example or carry out your instructions.


== Doing Something Title ==
=== Build ===
Write the steps of how to do something in this section.
<pre>
If possible, show an example first, then tell your readers the steps.
doas apk add alpine-sdk
Break this procedure into separate procedures to avoid more than
doas addgroup USERNAME abuild        # your non-root user
about 7-9 steps per procedure.


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


#Answer the following three questions, at least in your head.
cd aports/main/linux-lts/
##What do I explain how to do?
time abuild -crK
##How do I do that?
</pre>
##What do HOWTO readers already know about doing that?
 
#Write up a good example. This ensures you can do it.
=== Identify backup ===
#Write up the steps to do it.
 
#Write the background info/prerequisites readers need.
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.
#Write the summary.
 
#Clean up your work.
<pre>
# Add relevant category to your page, as every page should be assigned at least one Category.
echo "kernel: $(uname -r)"
#Revise, revise, revise.
apk list --installed linux-*
</pre>
 
[[File:Alpine-kernel-package2.png|600px]]
 
=== Install ===
Find the newly-built kernel file to install. This example shows how to install a newly-built x86_64 LTS kernel:
 
<pre>
ls -r ~/packages/main/*
doas apk add FILENAME
doas reboot
</pre>
 
[[File:Alpine-kernel-install.png|600px]]
 
After rebooting, verify the newly-installed kernel version:
<pre>
echo "kernel: $(uname -r)"
</pre>
 
[[File:Alpine-kernel-new.png|320px]]
 
=== Revert ===
If needed, revert to the previous backup kernel package we identified earlier. This example shows how to revert to the previous "alpine-lts" package after removing the newly-installed "alpine-lts" (both are named "alpine-lts" yet refer to different versions/locations):
<pre>
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
doas reboot
</pre>
 
[[File:Alpine-kernel-revert.png|465px]]


== See Also ==
== See Also ==
If you ought to point your readers to related information
 
they no doubt need but that does not fit in your HOWTO, add links here.
* [[Kernels]]
* [[Custom Kernel|Custom Kernel (2018-present)]]

Latest revision as of 22:57, 3 December 2024

How to build the Alpine Linux kernel

This Howto quickly demonstrates building/compiling the default Alpine Linux kernels. Kernel customizations (not covered here) allow you to experiment by 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 privileges (i.e. sudo, wheel group) 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 new 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-built kernel file to install. This example shows how to install a newly-built x86_64 LTS kernel:

ls -r ~/packages/main/*
doas apk add FILENAME
doas reboot

After rebooting, verify the newly-installed kernel version:

echo "kernel: $(uname -r)"

Revert

If needed, revert to the previous backup kernel package we identified earlier. This example shows how to revert to the previous "alpine-lts" package after removing the newly-installed "alpine-lts" (both are named "alpine-lts" yet refer to different versions/locations):

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
doas reboot

See Also