Arch Linux Kernel Compilation - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Arch Linux Kernel Compilation Guide
Complete beginner-friendly guide to kernel compilation on Arch Linux, including downloading kernel source, configuring, compiling, and installing custom kernels.
Table of Contents
Preparing for Compilation
Install Tools
Install build tools:
# Install base-devel
sudo pacman -S base-devel
# Install kernel build tools
sudo pacman -S linux-headers
Downloading Source
Get Kernel Source
Download source:
# Get kernel source
asp update linux
asp checkout linux
# Or download from kernel.org
wget https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.1.tar.xz
tar xf linux-6.1.tar.xz
cd linux-6.1
Configuring Kernel
Kernel Configuration
Configure kernel:
# Copy existing config
cp /proc/config.gz .
gunzip config.gz
cp config .config
# Or use defaults
make defconfig
# Configure
make menuconfig
# Or use Arch config
zcat /proc/config.gz > .config
make olddefconfig
Compiling Kernel
Build Kernel
Compile:
# Get number of CPUs
nproc
# Compile (use all CPUs)
make -j$(nproc)
# Build modules
make modules
# Install modules
sudo make modules_install
Installing Kernel
Install Kernel
Install:
# Copy kernel
sudo cp arch/x86/boot/bzImage /boot/vmlinuz-linux-custom
# Update bootloader
sudo grub-mkconfig -o /boot/grub/grub.cfg
# Or systemd-boot
sudo cp arch/x86/boot/bzImage /boot/EFI/arch/vmlinuz-linux-custom
Summary
This guide covered kernel compilation preparation, source download, configuration, compilation, and installation.
Next Steps
- Arch Linux Kernel Management - Kernel management
- Arch Linux Bootloader Configuration - Bootloader
- ArchWiki Kernel Compilation: https://wiki.archlinux.org/title/Kernel#Compilation
This guide is based on the ArchWiki. For the most up-to-date information, always refer to the official ArchWiki.