📚 Linux Kernel Programming Series – Chapter 2
Lecture 13 – Part 2 of 2 | Free Linux Kernel Development Course
Every make configuration target explained, updated for kernel 6.x, with 10 interview questions
6.x
Kernel Version
20+
Config Targets
Intermediate
Level
Topics in This Free Linux Kernel Development Course Lecture
make menuconfig
make olddefconfig
make localmodconfig
make tinyconfig
Kconfig files
syncconfig
kvm_guest.config
scripts/config tool
free linux device drivers course
🎯 What You Will Learn
- How the kbuild system and Kconfig files work together internally
- Every interactive configuration target and when to choose each one
- Every automated configuration target for scripted and CI builds
- Which targets were removed in kernel 5.11+ and what replaced them
- How to use
scripts/configfor command-line config changes - A complete end-to-end workflow from clean tree to configured kernel
- 10 interview questions with detailed answers for embedded Linux roles
1. How the kbuild System Works Internally
When you run make in the Linux kernel source directory, you are working with the kbuild system — the collection of Makefiles, Kconfig files, and helper scripts that control how the kernel is configured and compiled. Understanding this system is essential for anyone serious about Linux kernel development, embedded Linux, or Linux device driver work.
The configuration side of kbuild is driven by Kconfig files. Every subdirectory in the kernel source has a Kconfig file declaring what options exist in that part of the kernel, what their valid values are, and what they depend on. The interactive tools like menuconfig read these Kconfig files to build the menus you navigate.
kbuild Configuration System – Internal Flow
in every subdir + your saved choices
declare options (=y / =m / not set)
| |
v v
menuconfig reads syncconfig runs
both and shows automatically
interactive menus –> generates headers
under include/generated/
|
v
kernel C files use
#ifdef CONFIG_XXX
to include/exclude code
|
v
make -j$(nproc)
compiles only what
.config selected
An important point: .config alone is not what the C compiler reads. After you save your config, kbuild runs an internal target called syncconfig (previously called silentoldconfig) which generates C header files. The kernel’s C source files then use #ifdef CONFIG_SOME_FEATURE preprocessor guards to include or exclude code. You do not call syncconfig manually — make calls it automatically.
Key Files Generated by syncconfig
include/generated/autoconf.h # main header - #define CONFIG_XXX 1
include/config/auto.conf # used by Makefiles (obj-$(CONFIG_X) += file.o)
include/config/tristate.conf # tracks y/m/n states for Makefile logic
You will see these referenced in kernel Makefiles and driver source files constantly. They are all auto-generated — never edit them by hand.
2. Interactive Configuration Targets – GUI and Text Menus
These targets open a visual interface where you browse and toggle config options. All of them read the current .config (if one exists) and write your changes back when you save. They are the tools you use for day-to-day kernel configuration work in this free Linux kernel development course.
make config — Line-by-Line (Classic)
The oldest, simplest configurator. It asks about every config option one at a time at the command line. With thousands of options in a modern kernel this is impractical for interactive use but is occasionally useful in automated scripts where no terminal UI is available.
make config
make menuconfig — Most Popular ⭐
An ncurses-based text menu that runs in any terminal. This is the most widely used configurator because it works over SSH, works without any desktop environment, and is fast. Navigate with arrow keys, toggle with Space, search with /, get help with ?.
make menuconfig
For cross-compilation targets, always pass ARCH:
make ARCH=arm menuconfig
make nconfig — Alternate Text UI
An alternative ncurses-based configurator showing function-key shortcuts at the bottom of the screen. Functionally similar to menuconfig but with a different layout. Supports / for search. Some engineers prefer its cleaner look. Also works over SSH without a display.
make nconfig
make xconfig — Qt Graphical UI
Opens a Qt-based graphical window with a proper tree view and search box. Requires the Qt development libraries and a running display server (X11 or Wayland). Convenient for desktop use. Not available on headless servers or embedded build machines.
# Install Qt dev libs first (Ubuntu/Debian)
sudo apt install qtbase5-dev
make xconfig
make gconfig — GTK Graphical UI
Same idea as xconfig but uses the GTK+ toolkit. Requires GTK development libraries and a display. Rarely used in practice — most developers prefer menuconfig for terminal work or xconfig for GUI work.
make gconfig
Choosing an Interactive Config Tool
————|—————-|————|—————————
config | Terminal only | Yes | Scripted/automated prompts
menuconfig | ncurses | Yes | Day-to-day standard use
nconfig | ncurses | Yes | Alternative to menuconfig
xconfig | Qt + display | No | Desktop with GUI
gconfig | GTK + display | No | Desktop alternative
3. Automated Configuration Targets – No User Prompts
These targets create or modify .config without any interactive prompts. They are ideal for CI pipelines, scripted production builds, and automated testing. Every embedded Linux engineer and Linux device driver developer should know these targets well.
make oldconfig — Update Config for New Kernel Version
Takes your existing .config and updates it to be compatible with a newer kernel version. For any config symbol that is new (did not exist in the old kernel), it prompts you interactively to provide a value. Used when you upgrade the kernel version over an existing source tree.
# Typical workflow when pulling a newer kernel version
cp /boot/config-$(uname -r) .config
make oldconfig # prompts only for brand-new options
make olddefconfig — Auto-Update Without Prompts ⭐ CI Standard
Same as oldconfig but does not prompt for anything. New config symbols are automatically set to their kernel-defined defaults. This is the standard target used by CI systems, package maintainers, and anyone automating kernel builds at scale.
cp /boot/config-$(uname -r) .config
make olddefconfig # no prompts — all new options get defaults
make defconfig — Fresh Architecture Default Config
Generates a fresh .config from the architecture’s default config file. For x86-64 it picks the generic x86-64 default. For ARM targets you must specify ARCH. This wipes any existing .config and replaces it with the arch default.
# x86-64 default
make defconfig
# ARM64 default
make ARCH=arm64 defconfig
make savedefconfig — Create a Minimal Config Snapshot
Takes your current .config and saves a minimal version of it as ./defconfig. The minimal version only lists options that differ from the kernel defaults — everything else is omitted. This is exactly how the defconfig files inside arch/*/configs/ are created and maintained by kernel developers and BSP teams.
# Save a minimal version of your current config
make savedefconfig
# Result: ./defconfig (a clean, minimal representation of your choices)
# You can then copy it to the arch configs directory
cp defconfig arch/arm/configs/myboard_defconfig
make localmodconfig — Lean Config from Loaded Modules ⭐ Desktop Best
Configures the kernel to include only modules currently loaded on your system. Produces a compact config and much faster build times. Covered in depth in Lecture 12.
lsmod > /tmp/mods.txt
make LSMOD=/tmp/mods.txt localmodconfig
make localyesconfig — Like localmodconfig but Built-In
Similar to localmodconfig but converts all matched modules from =m to =y — compiling them directly into the kernel image rather than as separate .ko files. The resulting kernel image is larger but removes the need for runtime module loading. Useful for initramfs-only environments or container kernels where you want a single self-contained binary.
lsmod > /tmp/mods.txt
make LSMOD=/tmp/mods.txt localyesconfig
make allnoconfig — Everything Disabled
Sets every possible option to n (disabled). The resulting kernel barely boots — it is the absolute bare minimum. Used by kernel developers to test that individual features compile cleanly when all others are disabled, or to study config dependency chains.
make allnoconfig
make allyesconfig — Everything Built-In (Very Slow)
Sets every possible option to y (built-in). The build is enormous and extremely slow. Used by kernel CI infrastructure to verify that all code compiles cleanly when nothing is excluded. Not used in normal day-to-day development.
make allyesconfig
# Warning: build takes a very long time and produces a huge kernel
make allmodconfig — Everything as Modules
Enables every optional feature as a loadable module (=m) wherever possible. Like allyesconfig but for modules. Used by kernel CI systems to test that all drivers can be built as modules without compilation errors. Not for production builds.
make allmodconfig
make alldefconfig — All Symbols Set to Defaults
Sets all config symbols to their default values as declared in the Kconfig files using the default keyword. Unlike defconfig which uses an arch-specific defconfig file, this relies purely on the inline defaults inside Kconfig declarations.
make alldefconfig
make randconfig — Random Config (Testing / Fuzzing)
Generates a completely random .config where every option is randomly set to y, m, or n subject to dependency rules. Used by automated kernel testing infrastructure (like Linux’s 0-day CI robots) to find compilation errors in unusual config combinations that developers wouldn’t normally try. Not for human use.
make randconfig
make tinyconfig — Smallest Possible Kernel
Produces the absolute minimum kernel by combining allnoconfig with a tiny set of essential options. Boots in constrained environments and is useful for studying kernel boot internals. Also a very fast build — great for learners who want to see a kernel compile quickly for the first time.
make tinyconfig
make -j$(nproc) # builds very fast — ideal for learning
make listnewconfig — See What Is New
A read-only target that lists config symbols present in the current kernel source but absent from your existing .config. Use it before running olddefconfig when upgrading the kernel version — it shows exactly what new options appeared so you can review them before accepting defaults.
make listnewconfig
make testconfig — Kconfig Unit Tests
Runs the Kconfig unit test suite. Requires Python 3 and pytest. This target is for developers who work on the Kconfig system itself — not for normal kernel builds or embedded Linux work.
make testconfig
4. Configuration Fragment Targets – What Changed in Kernel 6.x
Rather than having dedicated make targets for every use case, modern kernels use a flexible system of Kconfig fragment files stored under kernel/configs/. These are small .config snippets that you merge on top of an existing config to enable a specific set of options. They were introduced to replace old shorthand targets.
⚠️ Important Breaking Change — Kernel 5.11 and Later (including 6.x)
The old shorthand targets make kvmconfig and make xenconfig were removed starting with kernel 5.11. If you use them on any current kernel (5.11+, all 6.x versions) you will get a “No rule to make target” error. Use the replacement fragment targets instead.
Deprecated vs Current Config Targets
———————|——————————-|——————————-
make kvmconfig | make kvm_guest.config | KVM virtual machine guest
make xenconfig | make xen.config | Xen hypervisor guest
# WRONG — will fail on kernel 6.x
make kvmconfig
# CORRECT — use the fragment file target
make kvm_guest.config
Other useful fragment targets available on kernel 6.x:
make debug.config # debugging options for CI and regression testing
make rust.config # enable Rust language support in the kernel
make nopm.config # disable power management (low-latency / real-time use)
make tiny.config # smallest possible kernel image options
These fragments are designed to be applied on top of an existing .config. They merge in only the options they define and leave everything else untouched. Behind the scenes they use the scripts/kconfig/merge_config.sh helper. You can apply multiple fragments in sequence if needed.
5. Cleaning Targets – Know These Before Every Build
Linux Kernel Cleaning Targets Comparison
—————|———————————————-|—————————–
make clean | Most .o files; keeps .config | Recompile after code change
make mrproper | Everything including .config + headers | Starting fresh from scratch
make distclean | mrproper + editor backups + patch leftovers | Preparing tree for archive
The rule of thumb: use clean when you changed source code and want a rebuild. Use mrproper when you want to start with a completely new configuration. Use distclean when creating a clean release tarball.
6. The scripts/config Tool – Command-Line Config Changes
The kernel ships a helper script called scripts/config that lets you query or modify config options directly from the command line without opening any interactive UI. This is invaluable for automation, CI scripts, and BSP build systems.
# Enable a feature (set to y — built-in)
scripts/config --enable CONFIG_BT
# Set as loadable module
scripts/config --module CONFIG_BT_RFCOMM
# Disable a feature
scripts/config --disable CONFIG_SOUND
# Query the current value
scripts/config --state CONFIG_BT
# Set a string value
scripts/config --set-str CONFIG_LOCALVERSION "-myboard-v1"
# Set a numeric value
scripts/config --set-val CONFIG_LOG_BUF_SHIFT 17
After making changes with scripts/config, always run make olddefconfig to resolve any dependency changes before building:
scripts/config --enable CONFIG_BT
make olddefconfig
make -j$(nproc)
7. How to Find Any Config Option Quickly
Kernels have thousands of config options. Knowing how to find the one you need is a practical skill every Linux kernel developer must have.
Method 1 – Search Inside menuconfig (Fastest)
Open make menuconfig and press / to open the search dialog. Type the option name without the CONFIG_ prefix. menuconfig shows you the full menu path, current value, and all dependencies.
# Open menuconfig, press /, then type: BT
# Result shows where CONFIG_BT is in the menu tree and its dependencies
Method 2 – Search .config Directly
# Check if a specific option is enabled
grep CONFIG_BT /path/to/kernel/source/.config
# Check the generated header (after running make)
grep BT include/generated/autoconf.h
Method 3 – Search Kconfig Files for the Definition
# Find which Kconfig file defines a symbol
grep -r "config BT$" . --include="Kconfig"
# Output tells you which subsystem owns the option
8. Complete End-to-End Kernel Configuration Workflow
Here is a complete sequence from freshly downloaded kernel source to a configured, ready-to-build tree. This uses the localmodconfig approach for an x86-64 system — the recommended method for this free Linux kernel development course.
# 0. Set the kernel source root
export KSRC=~/linux-6.9
cd $KSRC
# 1. Clean the tree completely before starting
make mrproper
# 2. Snapshot the currently loaded kernel modules
lsmod > /tmp/mods_snapshot.txt
# 3. Generate a lean .config based on those modules
# Accept all defaults for new options
yes "" | make LSMOD=/tmp/mods_snapshot.txt localmodconfig
# 4. Review and tweak the config interactively
make menuconfig
# 5. Build the kernel using all CPU cores
make -j$(nproc)
# 6. Install kernel modules to /lib/modules/
sudo make modules_install
# 7. Install the kernel image and update bootloader
sudo make install
All kbuild Config Targets Quick Reference – Kernel 6.x
———————|————-|——————————|——————
make config | Yes (lines) | Scripted prompts | Available
make menuconfig | Yes (menu) | Day-to-day standard | Available
make nconfig | Yes (menu) | Alt. to menuconfig | Available
make xconfig | Yes (Qt) | Desktop GUI | Available
make gconfig | Yes (GTK) | Desktop GUI alt. | Available
make oldconfig | Semi | Updating existing .config | Available
make olddefconfig | No | CI / automated builds | Available
make defconfig | No | Fresh arch default | Available
make savedefconfig | No | Create minimal defconfig | Available
make localmodconfig | Semi | Lean x86-64 desktop build | Available
make localyesconfig | Semi | Built-in only (no .ko files) | Available
make allnoconfig | No | Testing / bare minimum | Available
make allyesconfig | No | Compile test all code | Available
make allmodconfig | No | Module compile testing | Available
make randconfig | No | Fuzz / CI testing | Available
make tinyconfig | No | Smallest possible kernel | Available
make listnewconfig | No | See new options after update | Available
make testconfig | No | Kconfig unit tests | Available
make kvm_guest.config| No | KVM guest kernel | Available (new)
make xen.config | No | Xen guest kernel | Available (new)
make kvmconfig | – | OLD KVM shorthand | REMOVED (5.11+)
make xenconfig | – | OLD Xen shorthand | REMOVED (5.11+)
📝 Lecture 13 Summary – kbuild Config Targets
- The kbuild system uses Kconfig files to declare all available options
.configstores your choices;syncconfigconverts them to C headers automaticallymenuconfigis the standard interactive tool — works over SSH, no display neededolddefconfigis the standard for CI and automated builds — no promptslocalmodconfiggives the fastest desktop build;localyesconfigmakes everything built-inallyesconfig/allmodconfig/randconfigare for kernel CI and testing onlytinyconfigis perfect for learning — fast build, smallest possible kernelkvmconfigandxenconfigare gone since kernel 5.11 — usekvm_guest.configandxen.configscripts/configis the best tool for scripted, non-interactive config changes- Always run
olddefconfigafter usingscripts/configto resolve dependencies
Interview Questions – Linux Kernel kbuild and Configuration
Q1. What is the difference between make oldconfig and make olddefconfig?
Both targets update an existing .config when you move to a newer kernel version. make oldconfig interactively prompts the user for a value for each new config symbol that appeared in the newer kernel. make olddefconfig does the same update but without any prompts — it automatically sets all new symbols to their kernel-defined defaults. In practice, olddefconfig is used in CI systems and automated build pipelines because it requires no human input.
Q2. What is the difference between make localmodconfig and make localyesconfig?
Both start from a snapshot of currently loaded kernel modules. localmodconfig keeps those modules as =m so they are compiled as separate .ko files loaded at runtime. localyesconfig converts them all to =y, compiling them directly into the kernel image. localyesconfig produces a larger binary but removes the need for module loading infrastructure — useful for initramfs-only systems or container kernels where .ko loading is not practical.
Q3. What replaced make kvmconfig and make xenconfig in kernel 6.x?
Starting from kernel 5.11, the shorthand targets make kvmconfig and make xenconfig were removed. They are replaced by Kconfig fragment files. The modern equivalents are make kvm_guest.config for enabling options needed to run as a KVM virtual machine guest, and make xen.config for Xen hypervisor guest support. These fragment files live in kernel/configs/ and are merged on top of an existing .config rather than generating a config from scratch.
Q4. What is syncconfig and when does it run?
syncconfig is an internal kbuild target that converts .config into auto-generated C header files under include/generated/ and include/config/. The kernel’s C source files use #ifdef CONFIG_XXX preprocessor guards that read from these headers to include or exclude code at compile time. You never invoke syncconfig manually — kbuild runs it automatically when you invoke make after a .config is created or modified. It was previously called silentoldconfig before being renamed because the old name was misleading.
Q5. When would you use make allnoconfig or make allyesconfig?
allnoconfig and allyesconfig are not for production builds — they are for kernel developer testing. allnoconfig sets everything to disabled and is used to test that individual features compile cleanly in complete isolation. allyesconfig enables everything built-in and is used by kernel CI infrastructure to verify that all code compiles when nothing is excluded. The resulting allyesconfig build takes a very long time and produces an enormous kernel image.
Q6. How would you find which menu path a specific config option is located in?
The quickest way is to open make menuconfig and press / to open the search dialog. Type the config symbol name without the CONFIG_ prefix. menuconfig shows the full menu path, the current value, and all dependencies. Alternatively, you can search Kconfig files directly with grep -r "config SYMBOL_NAME" . --include="Kconfig" which tells you which subsystem defines it.
Q7. What is the purpose of make savedefconfig and how is it used by BSP teams?
make savedefconfig takes the current .config and saves a minimal version of it as ./defconfig. The minimal version only lists options that differ from the kernel’s defaults — everything else is omitted. This is exactly how the defconfig files inside arch/*/configs/ are created and maintained upstream. BSP teams use this to keep their board-specific defconfig files compact and readable rather than storing all 15,000+ options explicitly.
Q8. How does the kernel use .config during compilation — what is the actual mechanism?
The .config file itself is not read by the C compiler. After you save a config, kbuild runs syncconfig which generates C header files: mainly include/generated/autoconf.h which has lines like #define CONFIG_BT 1 for enabled options. The kernel’s C source files include this header and use #ifdef CONFIG_BT guards to conditionally compile code. Makefiles use include/config/auto.conf with lines like obj-$(CONFIG_BT) += bluetooth/ to decide which directories and files to compile.
Q9. What is the scripts/config tool and when would you use it over menuconfig?
scripts/config is a command-line helper script shipped with the kernel source that lets you query or change individual config options non-interactively. You would use it instead of menuconfig when you need to automate config changes in build scripts, CI pipelines, or BSP build systems — for example, enabling a specific driver or setting the kernel version string without opening an interactive menu. After any scripts/config change you should run make olddefconfig to resolve dependency side-effects before building.
Q10. What does make tinyconfig produce and why is it useful for learning?
make tinyconfig produces the absolute minimum kernel config by combining allnoconfig with a small set of essential options needed to boot. The resulting kernel is tiny and compiles in a fraction of the time a full kernel build takes. It is useful for learners because it lets you see a complete kernel compile cycle quickly without waiting hours for a full build. It is also used by kernel developers to study boot-time behavior and minimal kernel internals.
Article SEO Information
SEO Details – Free Linux Kernel Development Course
Focus Phrase : linux kernel kbuild configuration targets free linux kernel development course
Meta Desc : Master all Linux kbuild configuration targets: menuconfig, olddefconfig,
localmodconfig and more. Free Linux kernel development course with Q&A. (155 chars)
URL Slug : linux-kernel-kbuild-configuration-targets-free-linux-kernel-development-course
Targets : free linux kernel development course
free linux device drivers course
free embedded linux course
free embedded system course
📚 Linux Kernel Programming Series – Chapter 2
