Skip to content

Custom Kernel

You'll download the Linux source, trim the configuration to your own hardware, compile it, boot it, and keep the stock kernel ready in case it doesn't.

About

The kernel is the part of Linux that is actually Linux, and compiling your own is the way to see it as a thing you can change rather than a thing that arrives. The distro kernel supports every piece of hardware ever made, and yours only needs to support what's in front of you, so a trimmed config boots faster and builds in a fraction of the time. You need about 25 GB of free disk, a few hours of CPU, and the sense to keep the old kernel in the boot menu. Nothing here can hurt the hardware, and plenty of it can leave you booting the old entry, which is the plan.

At a glance

Per requirement
35 XP
Completion bonus
300 XP
Requirements
6
Takes
Two weekends
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own
Locked for now
Earn two more Uncommon badges in Linux to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Fetch the source and verify the signature. Download the latest stable tarball from kernel.org along with its .sign file and import the kernel developers' keys. The signature is on the uncompressed tar, not the .xz, so run unxz first and then gpg --verify the .sign against the .tar. Take a photo of the verification output saying the signature is good. Photo
  2. 2
    Start from your running kernel's config and trim it with localmodconfig. Copy /proc/config.gz or the config from /boot, then run make localmodconfig, which drops every module that isn't currently loaded. Plug in anything you ever use first (USB drives, webcam, headphones) so their modules are loaded and kept. Take a photo of the line count of the config before and after. Photo
  3. 3
    Change three options on purpose in menuconfig and say why. Open make menuconfig, find the local version suffix and set it to your name, then pick two more, like the preemption model, the timer frequency, or a driver you know you'll never need. Take a photo of menuconfig with one of your changes visible, and list the three. Photo
  4. 4
    Build it with every core and time the build. Run make -j with the number of CPUs you have, then make modules_install and make install, or build a distro package if your distro supports it. The first build is the long one, and a laptop will get hot, so put it on a hard surface. Take a photo of the terminal showing the time the build took and the new files in /boot. Photo
  5. 5
    Boot the new kernel, with the old one still in the menu. Regenerate the bootloader config, check both kernels are listed, and boot yours. Run uname -r to see your name in the version string. If it panics, boot the old one and compare dmesg for what's missing. Take a photo of uname -r on the running custom kernel. Photo
  6. 6
    Apply one upstream patch or a one-line change of your own and rebuild. Change a message in a driver you have, bump a timeout, or apply a small patch from the mailing list. The rebuild should take minutes, not hours, because make only rebuilds what changed. Take a photo of the diff and the dmesg line that shows your change took effect. Photo