-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux Kernel Compilation
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to kernel compilation on Linux, covering Arch Linux, CachyOS, and other distributions including downloading kernel source, configuring, compiling, and installing custom kernels.
- Preparing for Compilation
- Downloading Source
- Configuring Kernel
- Compiling Kernel
- Installing Kernel
- Troubleshooting
Install build tools:
# Arch/CachyOS
sudo pacman -S base-devel linux-headers
# Debian/Ubuntu
sudo apt install build-essential linux-headers-$(uname -r)
# Fedora
sudo dnf groupinstall "Development Tools"
sudo dnf install kernel-develVerify tools:
# Check GCC
gcc --version
# Check Make
make --version
# Check kernel headers
ls /usr/src/linux-headers-*Arch/CachyOS:
# Get kernel source using asp
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.1Debian/Ubuntu:
# Download kernel source
apt source linux-sourceFedora:
# Download kernel source
dnf download --source kernelConfigure kernel:
# Copy existing config
cp /proc/config.gz .
gunzip config.gz
cp config .config
# Or use defaults
make defconfig
# Configure (menu-based)
make menuconfig
# Or use existing config
zcat /proc/config.gz > .config
make olddefconfigCommon options:
- menuconfig: Text-based menu
- xconfig: X11 GUI (requires Qt)
- gconfig: GTK GUI
- oldconfig: Use existing config
Compile:
# Get number of CPUs
nproc
# Compile (use all CPUs)
make -j$(nproc)
# Build modules
make modules
# Install modules
sudo make modules_installWhat it does:
- Compiles kernel image
- Builds kernel modules
- Takes time (30 minutes to hours)
Arch/CachyOS:
# Copy kernel
sudo cp arch/x86/boot/bzImage /boot/vmlinuz-linux-custom
# Update bootloader (GRUB)
sudo grub-mkconfig -o /boot/grub/grub.cfg
# Or systemd-boot
sudo cp arch/x86/boot/bzImage /boot/EFI/arch/vmlinuz-linux-customDebian/Ubuntu:
# Install kernel
sudo make install
# Update bootloader
sudo update-grubFedora:
# Install kernel
sudo make install
# Update bootloader
sudo grub2-mkconfig -o /boot/grub2/grub.cfgCommon issues:
# Check errors
make -j$(nproc) 2>&1 | tee build.log
# Clean build
make clean
# Reconfigure
make menuconfigIf kernel doesn't boot:
# Boot from previous kernel
# Select from GRUB menu
# Check logs
journalctl -k
# Verify kernel
uname -rThis guide covered kernel compilation for Arch Linux, CachyOS, and other distributions, including preparation, source download, configuration, compilation, and installation.
- Kernel Management - Kernel management
- Bootloader Configuration - Bootloader
- ArchWiki Kernel Compilation: https://wiki.archlinux.org/title/Kernel#Compilation
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.