Linux Kernel Fragments

I've switched to compiling my own kernel in the past few months and I think an option for handling kernel configuration that doesn't get enough praise is the kernel fragments merge_config.sh script included in the kernel sourcetree. This script let's you merge together two seperate sets of kernel configurations.

The reason why that's helpful is because often you don't want to sit there and manually go through every option to create your own kernel configuration but you'd rather just flip a few flags on.

For me, what I like to do is generate the defconfig and then use the kernel fragments script to merge a few custom options ontop to generate kernel configuration. This is essentially the layman (or lazyman's) customized kernel. You could achieve similar to results with gentoo's genkernel features; but using just the defconfig gives you a substantially smaller build and magnitudes faster build time.

My kernel build script looks something like:

#!/usr/bin/env sh
# Script assumes a file called config_overlay with one config option per-line exists
PAR=4

echo "Building the kernel"
time make defconfig # E.g. generates a new .config (or overwrites)
time ./scripts/kconfig/merge_config.sh .config config_overlay
time make -j$PAR
time make -j$PAR install
time make -j$PAR modules_install
grub-mkconfig -o /boot/grub/grub.cfg

Defconfig gives you some usable defaults and whatever flags you need you can just throw in a config file (which is what you actually keep track of / care about - instead moving around and tracking the multi-thousand line .config).