Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/deelerdev/linux/llms.txt

Use this file to discover all available pages before exploring further.

The Linux kernel build system uses Kconfig to describe every configurable feature as a symbol with a type, default value, and dependency tree. Before you compile the kernel you must produce a .config file that sets every required symbol. The Kconfig front-ends — menuconfig, xconfig, nconfig, and others — let you browse and edit those symbols interactively, while batch targets such as defconfig and localmodconfig generate a baseline automatically.

Configuration targets

Run make help from the kernel source root to list every available target. The most commonly used ones are:
TargetDescription
menuconfigText-based curses UI; runs in any terminal
xconfigQt5-based graphical UI
nconfigAlternative ncurses UI with function-key shortcuts
gconfigGTK-based graphical UI (limited help text)
defconfigGenerate a .config from the architecture default
localmodconfigTrim the config to only modules loaded on the running system
oldconfigUpdate an existing .config to a new kernel version, prompting for new symbols
olddefconfigSame as oldconfig but answers new symbols with their defaults silently
listnewconfigPrint new symbols introduced since the last .config
allmodconfigEnable every symbol that can be built as a module
allyesconfigEnable every symbol that can be built in
allnoconfigDisable every optional symbol
randconfigSet symbols to random values (useful for CI testing)
savedefconfigWrite a minimal defconfig to defconfig

Using make menuconfig

1

Install build dependencies

Install the packages your distribution requires before running any configuration front-end.
sudo apt-get install bc binutils bison flex gcc git libelf-dev libssl-dev make pahole perl
2

Start from a baseline

Use the architecture default as your starting point, or copy your running kernel’s config if it is available.
# Use the architecture default
make defconfig

# Or copy the running kernel's config (common on many distros)
cp /boot/config-$(uname -r) .config
make olddefconfig
3

Open the interactive menu

make menuconfig
Navigate with the arrow keys. Press Space to toggle a symbol between y (built-in), m (module), and n (disabled). Press / to search by symbol name. Press ? for help on the selected symbol. Press Esc Esc to go back one level, or select Exit at the top-level menu to save and quit.
4

Find new symbols after a kernel upgrade

When you upgrade to a new kernel version and reuse an existing .config, new symbols will appear. List them before deciding how to handle them:
cp .config .config.old
make listnewconfig
Alternatively, use oldconfig to be prompted for each new symbol interactively:
make oldconfig
scripts/diffconfig .config.old .config | less

Common configuration options

Symmetric multiprocessing is controlled by CONFIG_SMP. On most modern hardware you want this enabled.
CONFIG_SMP=y
CONFIG_NR_CPUS=512
CONFIG_NUMA=y
CONFIG_NR_CPUS sets the compile-time maximum number of logical CPUs the kernel will support. Setting it too low wastes no resources, but the kernel will refuse to bring up CPUs beyond that limit at boot.
Enable these symbols on a development or test kernel. They add significant runtime overhead and are not suitable for production.
CONFIG_DEBUG_KERNEL=y
CONFIG_DEBUG_INFO=y
CONFIG_KASAN=y
CONFIG_KFENCE=y
CONFIG_LOCKDEP=y
CONFIG_PROVE_LOCKING=y
CONFIG_DEBUG_ATOMIC_SLEEP=y
CONFIG_KASAN_GENERIC can increase memory usage by 2–5× and slow execution by 30–100%. Use it only on dedicated test systems.
These options harden the kernel against exploitation:
CONFIG_STACKPROTECTOR=y
CONFIG_STACKPROTECTOR_STRONG=y
CONFIG_STRICT_KERNEL_RWX=y
CONFIG_STRICT_MODULE_RWX=y
CONFIG_RANDOMIZE_BASE=y          # KASLR
CONFIG_SECURITY=y
CONFIG_SECURITY_SELINUX=y
CONFIG_SECURITY_APPARMOR=y
CONFIG_MODULE_SIG=y
CONFIG_MODULE_SIG_FORCE=y
localmodconfig queries lsmod and disables modules not currently loaded, producing a much smaller config. This is useful for fast iteration on development machines.
lsmod > /tmp/my-modules.txt
LSMOD=/tmp/my-modules.txt make localmodconfig
Run this on the target machine with all relevant hardware attached and drivers loaded, otherwise you may trim modules you actually need.

Out-of-tree builds with O=

You can keep build artifacts entirely separate from the source tree using the O= variable. This is useful when you share a single source checkout across multiple configurations.
# Build into a separate directory
make O=/path/to/build-dir menuconfig
make O=/path/to/build-dir -j$(nproc)
All subsequent make invocations for that build must pass the same O= value.

Saving and managing .config files

# Write only non-default values to ./defconfig
make savedefconfig

# Later, restore the full .config from it
cp defconfig arch/x86/configs/myboard_defconfig
make myboard_defconfig
After making any configuration change, run make -j$(nproc) to rebuild only the affected objects. The kernel build system tracks dependencies between source files and Kconfig symbols, so it will recompile only what has changed.

Environment variables for Kconfig

VariableEffect
KCONFIG_CONFIGOverride the default .config filename
KCONFIG_DEFCONFIG_LISTSpace-separated list of fallback configs when .config does not exist
KCONFIG_OVERWRITECONFIGPrevent Kconfig from replacing a .config symlink
KCONFIG_WARN_UNKNOWN_SYMBOLSWarn about unrecognised symbols in the config input
KCONFIG_WERRORTreat Kconfig warnings as errors
KCONFIG_ALLCONFIGFile containing symbols to force when using allyes/allmod/allno/alldef/randconfig

Build docs developers (and LLMs) love