Kernel Compilation in Arch Linux


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

  1. Using the Arch Build System (ABS)

  2. The traditional method

We’ll 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).


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

  2. Install dependencies:

    • Make sure you have the following kernel configuration/compilation dependencies installed:

      base-devel bc python
    • Also make sure that you have virtualbox-guest-dkms installed; this will be needed to recompile your VirtualBox Guest Additions after you build your new kernel.

      • You don’t really need this if you never installed any virtualbox-guest- packages and are running your virtual machine without a GUI.
  3. Upgrade your Arch Linux by running sudo pacman -Syu.

    • If you’ve followed the Arch Downgrade guide make sure restore your /etc/pacman.d/mirrorlist to the default, up-to-date mirror list (if you had backed up). Alternatively, you may restore it from this sample mirrorlist, which has the Columbia mirror at the top.
  4. Reboot and make sure that your system is all good.

  5. Type uname -r 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 4.14.19-lts.

Obtain Kernel Source

Instead of fetching the Linux source code from as directed in the “Download the kernel source” section of KCT, you’re going to be compiling from the kernel source code provided in your GitHub skeleton repo.

Configure Kernel Build

Complete the following selected instructions, adapted from the “Configuration” section of KCT:

Build and Install a New Kernel

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

Update Bootloader Menu

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

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

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

Recompile VirtualBox Guest Module

If we’re using VirtualBox Guest Additions, 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 after we reboot.

  1. Find your vboxguest module version:

    $ dkms status -m vboxguest

    You may see multiple similar rows, one for each kernel version. The vboxguest version number is in the second comma-separated column. For example, mine is 5.2.6_OSE at time of running.

  2. Recompile the vboxguest module by running:

    # dkms remove vboxguest/<vboxguest_version> -k <kernel_version>
    # dkms install vboxguest/<vboxguest_version> -k <kernel_version>

    where <vboxguest_version> is what you found in the previous step (e.g. 5.2.6_OSE) and <kernel_version> is your kernel version string from the previous section (e.g. 4.9.81-cs4118). Keep in mind that if you didn’t have vboxguest previously installed, the dkms remove step will throw an error.

Boot to the New Kernel

Reboot by running:

# reboot

and make sure to pick your custom kernel from the bootloader menu.

Now verify that you’re running your own custom kernel by running:

$ uname -a

Instead of 4.14.19-lts, you should now see your kernel version string, 4.9.81-cs4118!

Last updated: 2018-02-24