Kernel Configuration and the .config Workflow

Updated

October 30, 2026

Kernel Configuration and the .config Workflow

The Linux kernel contains over 15,000 configurable options defined in a domain-specific language called Kconfig. The entire state of a build is recorded in a single plaintext file at the root of the kernel tree named .config.

Anatomy of .config

Inside .config, options follow a simple key-value format:

# A boolean option enabled statically in kernel:
CONFIG_BINFMT_ELF=y

# A tri-state option built as a loadable module:
CONFIG_EXT4_FS=m

# A disabled option (not compiled):
# CONFIG_EXT2_FS is not set

# An integer configuration parameter:
CONFIG_NR_CPUS=64

# A string parameter (e.g., custom distro kernel release tag):
CONFIG_LOCALVERSION="-byol-v1"

Mandatory Options for a Bootable Modern Distro

When building a distribution kernel from scratch, disabling certain options will cause immediate boot failures:

  1. Executable Formats:
    • CONFIG_BINFMT_ELF=y: Essential for running standard Linux binaries.
    • CONFIG_BINFMT_SCRIPT=y: Essential for interpreting #!/bin/sh scripts.
  2. Virtual Filesystems:
    • CONFIG_DEVTMPFS=y and CONFIG_DEVTMPFS_MOUNT=y: Tells the kernel to mount /dev automatically at boot.
    • CONFIG_PROC_FS=y and CONFIG_SYSFS=y.
  3. Storage & Controller Drivers:
    • CONFIG_BLK_DEV_SD=y: SCSI/SATA disk support.
    • CONFIG_ATA=y and CONFIG_ATA_GENERIC=y.
    • CONFIG_NVME_CORE=y: Modern NVMe SSD support.
    • CONFIG_VIRTIO_PCI=y and CONFIG_VIRTIO_BLK=y: Essential for QEMU/KVM virtual machine testing.
  4. Filesystem Drivers:
    • CONFIG_EXT4_FS=y or CONFIG_BTRFS_FS=y: Compiled as =y (built-in) if booting without an initramfs, or =m if the initramfs contains the driver.

Compiling the Kernel Image

Once .config is validated:

# Build the compressed kernel image and modules (-j$(nproc) uses all CPU cores):
$ make -j$(nproc) bzImage
$ make -j$(nproc) modules

# Install kernel modules into the target sysroot:
$ make INSTALL_MOD_PATH=/mnt/target modules_install

# Copy the kernel image into the boot directory:
$ cp arch/x86/boot/bzImage /mnt/target/boot/vmlinuz-byol