Kernel Compilation in Arch Linux

Overview

In Arch Linux, there are two ways to compile custom kernels:

  1. Using the Arch Build System (ABS)

  2. The traditional method

We will use the traditional method because it applies to all Linux distributions, not just Arch Linux. In this document, we will refer to the ArchWiki page on the traditional method as KCT (for Kernels/Compilation/Traditional).

Preparation

  1. First and foremost, please take a snapshot of your VM before you get started.

  2. Upgrade your Arch Linux by typing sudo pacman -Syu.

  3. Reboot and make sure that your system is all good.

  4. Type uname -a to make sure that you are running the kernel from the latest Arch LTS kernel package. At the time of this writing, my system reports the following:

    Linux vm04 3.14.35-1-lts #1 SMP Sat Mar 7 19:49:44 CET 2015 i686 GNU/Linux
    

Grab the kernel source

Follow the “Fetching source” section of KCT with the following selections/changes:

Configure your kernel build

Follow the “Build configuration” section of KCT with the following selections/changes:

Build and install a new kernel

Follow the “Compilation and installation” section of KCT with the following selections/changes:

Add a boot menu

Now, you need to add your kernel to the boot menu. Regenerate grub.cfg:

sudo grub-mkconfig -o /boot/grub/grub.cfg

GRUB will automatically find and add to the boot menu all kernels in /boot.

Recompile VirtualBox guest module

We need to do one more thing before we reboot to our new kernel. We have to recompile the VirtualBox guest module so that things like screen resizing will still work when we reboot to the new kernel.

  1. First, make sure you have the virtualbox-guest-dkms package installed:

    sudo pacman -S virtualbox-guest-dkms
    

    If you have it installed already, pacman will ask you if you want to reinstall. Say no, but note the version number of the module.

  2. Recompile the VirtualBox guest module by running:

    sudo dkms remove  vboxguest/4.3.26 -k 3.14.35-jwl3
    sudo dkms install vboxguest/4.3.26 -k 3.14.35-jwl3
    

    Substitute your vboxguest version number and your kernel version string.

Boot to the new kernel

Reboot and verify that you’re running your own custom kernel by typing uname -a!


Last updated: 2015–03–20