You will need at least 12 GB of free space in your build directory for a standard build with debug symbols enabled, or around 4 GB with debug symbols disabled. An additional 150 MB in
/lib/ and 100 MB in /boot/ are needed at install time.Install build dependencies
The kernel requires a C compiler, GNU Make, a linker, and several supporting tools. Install them with your distribution’s package manager:- Debian / Ubuntu
- Fedora / RHEL
- openSUSE
- Arch Linux
Minimal version requirements
The following table lists the minimum versions of tools required to build the current kernel. Verify installed versions with the commands shown.| Tool | Minimum version | Check command |
|---|---|---|
| GCC | 8.1 | gcc --version |
| GNU Make | 4.0 | make --version |
| Binutils | 2.30 | ld -v |
| Bash | 4.2 | bash --version |
| flex | 2.5.35 | flex --version |
| bison | 2.0 | bison --version |
| pahole | 1.22 | pahole --version |
| OpenSSL | 1.0.0 | openssl version |
| Python | 3.9.x | python3 --version |
| Clang/LLVM (optional) | 15.0.0 | clang --version |
| Rust (optional) | 1.78.0 | rustc --version |
Secure Boot
On systems with Secure Boot enabled, self-compiled kernels will be rejected at boot unless they are signed with a key trusted by your firmware. The quickest approach on commodity x86 systems is to disable Secure Boot in your BIOS setup utility. Alternatively, on mainstream Linux distributions you can disable validation for your environment:Get the source
Clone the stable kernel repository
A shallow clone retrieves only the history you need and downloads roughly the same amount of data as a tarball:To access a specific stable series (for example, 6.6.y), add its remote branch and deepen accordingly:If you need the very latest mainline code rather than the stable mirror (which lags by a few hours), add Linus’s tree as an additional remote:
(Optional) Download a tarball instead
If you only need to build a specific release without using git, download a tarball from kernel.org and extract it:
Configure the kernel
Kernel configuration is stored in a.config file. The build system provides several make targets to create or update this file.
- localmodconfig (recommended for testing)
- defconfig
- olddefconfig (existing .config)
localmodconfig trims the configuration to modules that are currently loaded on your running system. This dramatically reduces compile time.Tag your build (optional but recommended)
If you have patched the kernel or want to distinguish your build from a distribution kernel with the same version number, add a local version tag:uname -r will then report something like 6.9.0-mybuild.
Adjust debug symbols
Debug symbols increase build artifacts from roughly 1 GB to around 5 GB. Disable them if you are short on space and do not need to decode stack traces:Build
Compile the kernel and modules
Use all available CPU cores to minimize build time:A typical build takes 5–30 minutes depending on configuration size and hardware. If the build fails, re-run with verbose output to see the exact error:
Cross-compilation
To build for a different architecture, setARCH and CROSS_COMPILE:
CROSS_COMPILE prefix must match a toolchain installed on your build host. On Debian/Ubuntu, gcc-aarch64-linux-gnu provides the aarch64-linux-gnu-gcc compiler needed above.
Install
Install modules and kernel image
On most distributions a single command handles both steps:
make modules_install copies modules to /lib/modules/<release>/. make install then calls the distribution’s installkernel helper, which copies the kernel image to /boot/, generates an initramfs, and updates the bootloader configuration.Always run
modules_install before install. The initramfs generator called by installkernel may need the freshly installed modules.Manual installation (Arch Linux and derivatives)
Arch Linux and some other distributions do not ship an Then generate an initramfs using your distribution’s tooling (e.g.,
installkernel executable. Install manually:mkinitcpio on Arch) and add an entry to your bootloader (e.g., grub-mkconfig or a direct systemd-boot entry).