In Arch Linux, there are two ways to compile custom kernels:
Using the Arch Build System (ABS)
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).
First and foremost, please take a snapshot of your VM before you get started.
Upgrade your Arch Linux by typing
sudo pacman -Syu.
Reboot and make sure that your system is all good.
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
Follow the “Fetching source” section of KCT with the following selections/changes:
Grab the same kernel version as the Arch LTS package kernel that you are
currently running. If it is
3.14.35-1-lts, then download:
kernel.org site keeps an archive of every kernel revision,
dating back to 1.0 (and even 0.01 in their historic section).
You will build the kernel as a non-root user (i.e. as the user that you
normally log in as). KCT suggests
~/kernelbuild as your work
directory. It can be any place under your home directory.
Don’t forget to run
makefails and you didn’t run this command, it’s probably because of that.
Follow the “Build configuration” section of KCT with the following selections/changes:
.config file from the running kernel:
zcat /proc/config.gz > .config
Change the kernel version in
.config by running
make menuconfig as
described in KCT. The new kernel version should be
After you changed the kernel version, the original
.config will be
.config.old. Verify your changes like this:
jae@vm04 ~/kb/linux-3.14.35 $ diff .config.old .config 3c3 < # Linux/x86 3.14.35-1 Kernel Configuration --- > # Linux/x86 3.14.35 Kernel Configuration 52c52 < CONFIG_LOCALVERSION="-lts" --- > CONFIG_LOCALVERSION="-jwl3"
Follow the “Compilation and installation” section of KCT with the following selections/changes:
Compiling kernel takes a long time–it can take over an hour on a slow
machine. If your computer has multiple CPU cores, configure your VM to
use them all. Then, instead of
N is the number of jobs you would like make to spawn. Use the
number of CPUs * 2 for
N. So for a 8-core machine, you would run
Whenever KCT says “YourKernelName” or “FullKernelName”,
use your kernel version string:
Don’t forget to copy System.map file, which will be useful for debugging later:
sudo cp System.map /boot/System.map-3.14.35-UNI
Some old programs look for /boot/System.map instead of /boot/System.map-<kernel_version>, so let’s create /boot/System.map as a symlink:
sudo ln -fs /boot/System.map-3.14.35-UNI /boot/System.map
Verify that you have the following 3 files and 1 symlink in
/boot (with your UNI instead of mine, of course):
vmlinuz-3.10.34-jwl3 initramfs-3.10.34-jwl3.img System.map-3.10.34-jwl3 System.map (a symlink to /boot/System.map-3.14.35-jwl3)
Now, you need to add your kernel to the boot menu. Regenerate
sudo grub-mkconfig -o /boot/grub/grub.cfg
GRUB will automatically find and add to the boot menu all kernels in /boot.
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.
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.
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.
Reboot and verify that you’re running your own custom kernel by typing
Last updated: 2015–03–20