torvalds/linux
Configuration
The kernel is configured by Kconfig. The configuration is materialized into a .config file at the repository root which the build reads. Modules and built-ins, debug options, sanitizers, and architecture features are all controlled by Kconfig.
The configuration cycle
graph LR
A[Kconfig files in tree] -->|read by| B[scripts/kconfig]
B -->|writes| C[.config]
C -->|materialized into| D[include/generated/autoconf.h, Kconfig include files]
D -->|consumed during build| E[Kbuild]
E --> F[vmlinux + modules]Common targets
| Target | What it does |
|---|---|
make defconfig |
Default config for the host arch |
make ARCH=arm64 defconfig |
Default config for arm64 |
make <name>_defconfig |
Pick a arch/<arch>/configs/<name>_defconfig |
make menuconfig |
ncurses UI |
make nconfig, xconfig, gconfig |
Other UIs |
make olddefconfig |
Accept defaults for newly added options |
make oldconfig |
Interactive prompt for new options |
make savedefconfig |
Write a minimal defconfig that reproduces the current .config |
make localmodconfig |
Trim .config to only what your machine has loaded |
make allyesconfig, allnoconfig, allmodconfig |
Build everything / nothing / everything as modules |
make randconfig |
Random config (used by build farms) |
make help |
List all targets |
The Kconfig program lives in scripts/kconfig/.
Kconfig file structure
Each directory has its own Kconfig file, included by parent Kconfigs via source. The hierarchy starts at the top-level Kconfig.
config CONFIG_FOO
bool "User-friendly name"
depends on BAR && !BAZ
default y
help
Multi-line help text shown in menuconfig.Types: bool, tristate (y/m/n), string, int, hex. Tristate options can be built into the kernel (y) or as modules (m).
Example defconfigs
| File | Use |
|---|---|
arch/x86/configs/x86_64_defconfig |
A reasonable x86_64 config |
arch/arm64/configs/defconfig |
The big arm64 defconfig |
arch/riscv/configs/defconfig |
RISC-V |
kernel/configs/*.config |
Fragments to overlay (tiny.config, kvm_guest.config, rt.config, …) |
Apply a fragment:
make x86_64_defconfig
./scripts/kconfig/merge_config.sh -m .config kernel/configs/kvm_guest.config
make olddefconfigImportant Kconfig groups (tip-of-the-iceberg)
The full menu is enormous. A few Kconfig "spheres" that come up often:
- Architecture —
arch/<arch>/Kconfigand per-platform Kconfigs. - Processor type and features — CPU family, NUMA, NR_CPUS.
- Memory model — sparsemem vs. flatmem; vmemmap; HIGHMEM (32-bit); page size on archs that allow it.
- Kernel hacking — sanitizers, lockdep, debug objects, KASAN, UBSAN.
- Security options — LSMs (
CONFIG_LSM=...), seccomp, lockdown, randstruct. - Networking — IPv6 hash, BPF, XDP, kTLS, MPTCP, netfilter modules.
- Device drivers — the bulk of any defconfig.
- General setup — preempt model, init system flavor, BPF, kallsyms, IKCONFIG.
- General architecture-dependent options — page size, addressable memory, CMA.
- Cryptographic API — every algorithm.
Build system
Kbuild is the recursive make engine driven by make from the top. See Subsystems → Scripts for the engine itself.
Common Make variables
| Variable | Purpose |
|---|---|
ARCH |
Cross-build target architecture |
CROSS_COMPILE |
Toolchain prefix (e.g. aarch64-linux-gnu-) |
LLVM=1 |
Use clang/lld toolchain |
O=path |
Out-of-tree build directory |
KBUILD_OUTPUT |
Same effect as O= (env var form) |
CC=, LD=, AR=, STRIP=, OBJCOPY= |
Override individual tools |
KAFLAGS=, KCFLAGS=, KCPPFLAGS= |
Extra flags |
V=1 |
Verbose build (show every command) |
W=1, W=2, W=3 |
Increasing warning level |
C=1, C=2 |
Run sparse |
Out-of-tree build
mkdir /tmp/build
make O=/tmp/build defconfig
make O=/tmp/build -j$(nproc)This keeps the source tree clean.
Module signing
CONFIG_MODULE_SIG=y requires the kernel to verify modules. The build embeds the public key from CONFIG_SYSTEM_TRUSTED_KEYS= (defaulting to a generated signing_key.pem under the build directory). See Subsystems → Certs.
Compressed kernel image
Each architecture compresses vmlinux with one of gzip, bzip2, lzma, xz, lzo, lz4, zstd (selectable in General setup → Kernel compression mode). The compressed image is then wrapped in arch-specific glue to make bzImage / Image / vmlinuz.
Where to look
Documentation/kbuild/— Kconfig and Kbuild reference.Documentation/admin-guide/kernel-parameters.txt— boot parameters.Documentation/admin-guide/sysctl/—/proc/sysknobs.
Related pages
- Subsystems → Scripts — Kbuild engine.
- Tooling — checkpatch, sparse.
- Subsystems → Certs — module signing.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.