The Linux kernel build system uses GNU Make and a layered Kconfig configuration framework. This page walks you through every step required to go from a fresh checkout to a running, self-compiled kernel — covering required tools, configuration strategies (including theDocumentation 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.
localmodconfig trimmed-config approach), build commands, and installation. It also notes common pitfalls such as Secure Boot restrictions and distro-specific adjustments.
Required build dependencies
You need the following minimum tool versions before building. Run./scripts/ver_linux inside the source tree to check what is installed.
| Tool | Minimum version |
|---|---|
| GNU C (gcc) | 8.1 |
| GNU make | 4.0 |
| bash | 4.2 |
| binutils | 2.30 |
| flex | 2.5.35 |
| bison | 2.0 |
| bc | 1.06.95 |
| perl | 5 |
| Python | 3.9.x |
| openssl + libcrypto | 1.0.0 |
| pahole (dwarves) | 1.22 |
openssl and its development headers are required even if you do not plan to
use Secure Boot, because many distribution kernel configurations enable it for
x86 by default.Build flow
Prepare for Secure Boot
On systems with Secure Boot enabled, self-compiled kernels will be rejected
at boot unless you either sign them or disable the restriction.The quickest approach on mainstream x86 Linux distributions is to disable
validation for your local environment:This prompts you to set a one-time password. Reboot, and when the Shim
bootloader shows the MOK management screen, select Change Secure Boot
state and enter the password characters it requests. Alternatively,
disable Secure Boot entirely in your BIOS setup utility.
Get the source
Clone the Linux stable git repository. A shallow clone saves bandwidth and
works well for building and testing:To also access recent stable/longterm releases (for example, the 6.1.y
series), add the branch and deepen the history:
Configure the kernel
Choose a configuration strategy based on your goal.Trimmed config (recommended for testing and day-to-day use)Generic config based on your running kernelIf you want to match your distribution’s configuration more closely:Interactive configurationTo browse and toggle options manually:Debian-specific adjustmentOn Debian, remove a stale certificate reference that would cause a build
failure:
localmodconfig uses your currently loaded modules as a guide, disabling
drivers your system is not using. This dramatically reduces compile time:Tag your build (optional but recommended)
If you already have a kernel of the same version installed, or if you
applied patches, add a unique tag so the new kernel installs alongside the
existing one without conflict:Running
uname -r on the booted kernel will then show something like
6.1.0-rc4-mybuild.Compile
Build the kernel image and all modules in parallel across all available CPU
cores:The current kernel version is 7.1.0-rc3 (“Baby Opossum Posse”), as
defined in the top-level You can also build directly to a distributable package instead of using the
default targets:
Makefile.If the build fails, re-run with verbose output to isolate the error:Install modules and kernel
On most mainstream distributions a single command handles both module
installation and kernel image installation, then updates the bootloader
and generates an initramfs:On distributions such as Arch Linux that do not ship an After the manual install, generate an initramfs using your distribution’s
tool and add the kernel entry to your bootloader configuration.
installkernel
script, install manually:Install modules before the kernel image. Many distributions generate
the initramfs during
installkernel and require the modules to be present
at that point.Rebuilding for a newer version
Once you have a trimmed.config from the first build, use olddefconfig
rather than localmodconfig for subsequent builds so you keep your
configuration intact:
Removing a kernel
Kernel files are stored in exactly two places, both named after the kernel’s release name, making removal straightforward. Replace6.1.0-mybuild with
your actual release name:
Space requirements
Building a typical x86 kernel configured withlocalmodconfig requires
approximately 12 GB in the source directory. With debug symbols disabled the
build artifacts shrink to around 1 GB; with them enabled, expect roughly 5 GB.
The installed kernel needs about 150 MB in /lib/modules/ and 100 MB in
/boot/.
To disable debug symbols and save space:
