Kernel Management

Quick Reference

# Current kernel
uname -r

# Available kernels
pacman -Ss '^linux$'

# Install kernel
sudo pacman -S linux linux-headers

# Install LTS kernel
sudo pacman -S linux-lts linux-lts-headers

# Rebuild initramfs
sudo mkinitcpio -P

# DKMS rebuild
sudo dkms autoinstall

Available Kernels

Official Kernels

Kernel Description Use Case

linux

Latest stable mainline

Default, most hardware support

linux-lts

Long-term support

Stability, servers, older hardware

linux-zen

Optimized for desktop

Gaming, multimedia, responsiveness

linux-hardened

Security-focused

Security-sensitive systems

Install Multiple Kernels

# Install main kernel
sudo pacman -S linux linux-headers

# Install LTS as fallback
sudo pacman -S linux-lts linux-lts-headers

# Install Zen for desktop use
sudo pacman -S linux-zen linux-zen-headers

# Update bootloader entries
# (systemd-boot auto-detects, or create manual entries)

Why Multiple Kernels?

  • Fallback - If new kernel breaks, boot older one

  • Testing - Try new features safely

  • Hardware - Some hardware needs specific kernel

  • Use case - Gaming (Zen) vs stability (LTS)

Kernel Information

Current Kernel

# Kernel version
uname -r
# 6.7.1-arch1-1

# Kernel release
uname -a

# Detailed info
cat /proc/version

# Installed kernel packages
pacman -Q | grep -E '^linux(-lts|-zen|-hardened)?(-headers)? '

Kernel Modules

# List loaded modules
lsmod

# Module info
modinfo nvidia

# Load module
sudo modprobe nvidia

# Unload module
sudo modprobe -r nvidia

# Load with options
sudo modprobe nvidia NVreg_PreserveVideoMemoryAllocations=1

Module Configuration

# Create module config file
# /etc/modprobe.d/nvidia.conf
options nvidia NVreg_PreserveVideoMemoryAllocations=1
options nvidia_drm modeset=1

# Blacklist module
# /etc/modprobe.d/blacklist.conf
blacklist nouveau
blacklist pcspkr

# Rebuild initramfs after changes
sudo mkinitcpio -P

DKMS (Dynamic Kernel Module Support)

Understanding DKMS

DKMS automatically rebuilds out-of-tree modules when: * Kernel is upgraded * Module source is updated * Manually triggered

Common DKMS modules: * nvidia * nvidia-open * virtualbox-host-modules * broadcom-wl * zfs

Install DKMS

# Install DKMS
sudo pacman -S dkms

# Most drivers have DKMS variants
sudo pacman -S nvidia-dkms       # NVIDIA
sudo pacman -S nvidia-open-dkms  # NVIDIA open

DKMS Commands

# List DKMS modules
dkms status

# Build module for kernel
sudo dkms install nvidia/545.29.06 -k 6.7.1-arch1-1

# Remove module
sudo dkms remove nvidia/545.29.06 -k 6.7.1-arch1-1

# Rebuild all modules for current kernel
sudo dkms autoinstall

# Build module manually
sudo dkms build nvidia/545.29.06

DKMS Troubleshooting

# Check build logs
cat /var/lib/dkms/nvidia/545.29.06/build/make.log

# Force rebuild
sudo dkms remove nvidia/545.29.06 --all
sudo dkms install nvidia/545.29.06

# Missing kernel headers
sudo pacman -S linux-headers linux-lts-headers

Kernel Parameters

Temporary Parameters

# View current parameters
cat /proc/cmdline

# Set at boot time (in bootloader menu)
# Press 'e' to edit entry, add parameters to options line

Permanent Parameters

systemd-boot

# /boot/loader/entries/arch.conf
options root=UUID=xxx rw quiet nvidia_drm.modeset=1 mitigations=off

GRUB

# /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet nvidia_drm.modeset=1 mitigations=off"

# Regenerate config
sudo grub-mkconfig -o /boot/grub/grub.cfg

Common Parameters

Parameter Purpose

quiet

Suppress most boot messages

splash

Show splash screen

nvidia_drm.modeset=1

NVIDIA Wayland support

amd_iommu=on

Enable AMD IOMMU (for passthrough)

intel_iommu=on

Enable Intel IOMMU

iommu=pt

IOMMU passthrough mode

mitigations=off

Disable CPU vulnerability mitigations (performance)

nowatchdog

Disable watchdog (faster shutdown)

nmi_watchdog=0

Disable NMI watchdog

mem_sleep_default=deep

Prefer deep sleep (S3)

acpi_osi=Linux

ACPI compatibility

pcie_aspm=force

Force PCIe power management

Debugging Parameters

# Debug boot issues
debug systemd.log_level=debug

# Single user mode
single

# No splash, verbose boot
nosplash

# Disable specific module
modprobe.blacklist=nouveau

Sysctl Kernel Tuning

View Parameters

# List all
sysctl -a

# Specific parameter
sysctl vm.swappiness

# Search
sysctl -a | grep dirty

Set Parameters

# Temporary (until reboot)
sudo sysctl vm.swappiness=10

# Permanent - create file in /etc/sysctl.d/
# /etc/sysctl.d/99-custom.conf
vm.swappiness=10
vm.vfs_cache_pressure=50
kernel.nmi_watchdog=0

Common Tuning

# /etc/sysctl.d/99-performance.conf

# Reduce swappiness for desktop
vm.swappiness=10

# Improve SSD performance
vm.dirty_ratio=10
vm.dirty_background_ratio=5

# Disable watchdog
kernel.nmi_watchdog=0

# Network performance
net.core.rmem_max=16777216
net.core.wmem_max=16777216

Custom Kernel Compilation

Get Source

# Official PKGBUILD
asp checkout linux
cd linux

# Or download from kernel.org
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.7.tar.xz
tar xf linux-6.7.tar.xz
cd linux-6.7

Configure

# Copy current config
zcat /proc/config.gz > .config

# Or use Arch's config
cp /usr/src/linux/.config .

# Configure with menuconfig
make menuconfig

# Or just update for new version
make olddefconfig

Build

# Build kernel (parallel jobs = CPU cores)
make -j$(nproc)

# Install modules
sudo make modules_install

# Install kernel
sudo make install
# Or manually:
sudo cp arch/x86/boot/bzImage /boot/vmlinuz-linux-custom
sudo cp System.map /boot/System.map-linux-custom

# Create initramfs
sudo mkinitcpio -k 6.7.0-custom -g /boot/initramfs-linux-custom.img

# Add boot entry

Using ABS

# Install asp
sudo pacman -S asp

# Get linux PKGBUILD
asp checkout linux
cd linux/trunk

# Modify PKGBUILD or config
vim config
vim PKGBUILD

# Build package
makepkg -s

# Install
sudo pacman -U linux-custom-6.7-1-x86_64.pkg.tar.zst

Kernel Module Signing

Check Signing Status

# Module signing enforced?
cat /proc/sys/kernel/module_sig_enforce

# View module signature
modinfo -F sig_hashalgo nvidia

Secure Boot with Custom Modules

# Generate signing key
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -days 36500 -subj "/CN=My Module Signing Key/"

# Enroll key
sudo mokutil --import MOK.der

# Sign module
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 MOK.priv MOK.der /path/to/module.ko

Switching Kernels

At Boot Time

With systemd-boot: 1. Boot menu appears (or press Space) 2. Select desired kernel entry 3. Press Enter to boot

Permanent Default

# systemd-boot
# /boot/loader/loader.conf
default arch-lts.conf

# Or use bootctl
bootctl set-default arch-lts.conf

# GRUB - set default entry number
# /etc/default/grub
GRUB_DEFAULT=2
sudo grub-mkconfig -o /boot/grub/grub.cfg

Troubleshooting

Kernel Panic

# Boot older kernel from menu
# Check what changed
journalctl -b -1 -p err

# Common causes:
# - Missing modules in initramfs
# - Wrong root= parameter
# - Filesystem corruption

Module Not Loading

# Check if blacklisted
grep module_name /etc/modprobe.d/*

# Check kernel log
dmesg | grep module_name

# Try loading manually
sudo modprobe -v module_name

DKMS Build Failed

# Check kernel headers installed
pacman -Q | grep headers

# Install missing headers
sudo pacman -S linux-headers

# Check build log
cat /var/lib/dkms/module/version/build/make.log

# Rebuild
sudo dkms autoinstall

After Kernel Update

# If system breaks after update

# 1. Boot older kernel from menu
# 2. Check what updated
cat /var/log/pacman.log | tail -50

# 3. Downgrade if needed
sudo pacman -U /var/cache/pacman/pkg/linux-6.6.10...pkg.tar.zst

# 4. Hold package
# /etc/pacman.conf
IgnorePkg = linux linux-headers

Quick Reference

# Kernel info
uname -r                          # Version
cat /proc/cmdline                 # Boot parameters
cat /proc/config.gz | zcat        # Kernel config

# Install kernels
sudo pacman -S linux linux-headers
sudo pacman -S linux-lts linux-lts-headers
sudo pacman -S linux-zen linux-zen-headers

# DKMS
dkms status
sudo dkms autoinstall

# Modules
lsmod
modinfo module_name
sudo modprobe module_name
sudo modprobe -r module_name

# Rebuild initramfs
sudo mkinitcpio -P

# Sysctl
sysctl -a
sysctl parameter=value
# Permanent: /etc/sysctl.d/99-custom.conf