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 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).


  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.10.34-1-lts #1 SMP Mon Mar 24 09:00:59 UTC 2014 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, let’s add your kernel to the boot menu. The easiest way seems to be to trick grub that there is an Arch kernel package named linux-UNI by providing vmlinuz-linux-UNI and initramfs-linux-UNI.img. They can be symlinks to the real files we just copied. Create the symlinks:

cd /boot
sudo ln -s vmlinuz-3.10.34-jwl3 vmlinuz-linux-jwl3
sudo ln -s initramfs-3.10.34-jwl3.img initramfs-linux-jwl3.img 
sudo ln -s

(We also create symlinks while we’re doing symlinks; some old programs look for instead of the specific one for the running kernel.)

Then, we can simply regenerate grub.cfg:

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

GRUB will automatically find and add to the boot menu all kernels matching vmlinuz-linux-*.

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 uninstall vboxguest/4.3.10 -k 3.10.34-jwl3
    sudo dkms install vboxguest/4.3.10 -k 3.10.34-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: 2014–03–29