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.10.34-1-lts #1 SMP Mon Mar 24 09:00:59 UTC 2014 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.10.34-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.10.34 $ diff .config.old .config 3c3 < # Linux/x86 3.10.34-1 Kernel Configuration --- > # Linux/x86 3.10.34 Kernel Configuration 50c50 < CONFIG_LOCALVERSION="-lts" --- > CONFIG_LOCALVERSION="-abc1234"
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”, use you 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.10.34-UNI
After copying the files, verify that you have the following 3 files in
/boot (with your UNI instead of mine, of course):
initramfs-3.10.34-jwl3.img System.map-3.10.34-jwl3 vmlinuz-3.10.34-jwl3
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
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 System.map-3.10.34-jwl3 System.map
(We also create System.map symlinks while we’re doing symlinks; some old programs look for System.map instead of the specific one for the running kernel.)
Then, we can simply regenerate
sudo grub-mkconfig -o /boot/grub/grub.cfg
GRUB will automatically find and add to the boot menu all kernels matching
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 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.
Reboot and verify that you’re running your own custom kernel by typing
Last updated: 2014–03–29