Releases: alsyundawy/DebianKernelBuild
Debian Kernel Build 2026.06.14-r5
🐧 ALSYUNDAWY Linux Kernel DEB Builder
Production-grade shell script to download, verify, configure, build, and optionally install upstream vanilla Linux kernel Debian packages — fully automated, VM-aware, and security-hardened.
✨ Overview
This script builds an upstream vanilla Linux kernel directly from kernel.org into Debian packages using the in-tree Kbuild target make bindeb-pkg. It handles the entire lifecycle — from downloading and cryptographically verifying the source tarball to configuring, compiling, packaging, and installing the resulting .deb files.
Designed for Debian, Ubuntu, Proxmox VE, and all Debian-based distributions.
🚀 Key Features
🔐 Security and Integrity
- OpenPGP signature verification of kernel.org tarballs before extraction using WKD-imported developer keys (Torvalds, Kroah-Hartman, Levin)
- Hardened GPG invocation with
--no-auto-key-importand--no-auto-key-retrieveto prevent silent key injection - Debian certificate sanitization for vanilla upstream sources (
SYSTEM_TRUSTED_KEYS,SYSTEM_REVOCATION_KEYS,MODULE_SIG_KEY) - Input validation with regex-based kernel version checks to prevent path or command injection
- Strict Bash mode (
set -Eeuo pipefail) with ERR, INT, and TERM signal traps - Path canonicalization via
readlink -fto prevent symlink-based path traversal
⚙️ Build Pipeline
- Isolated build directory per kernel version and timestamp — no cross-contamination between builds
- Flexible config seeding: seed from running kernel (
/boot/config-*),defconfig,localmodconfig, or none - Interactive and non-interactive modes:
menuconfig,nconfig,oldconfig,olddefconfig, or skip entirely - Debug info control: disabled by default to dramatically reduce build time and package size
- Parallel compilation with configurable job count (defaults to
nproc) - Custom versioning: set
LOCALVERSIONsuffix andKDEB_PKGVERSIONoverride - Release-candidate support: versions like
6.15-rc7automatically use kernel.org/testingdirectory
🖥️ VM Guest Optimization
Automatically detects the hypervisor at runtime using systemd-detect-virt and DMI/SMBIOS data, then applies hypervisor-specific kernel configuration:
| Hypervisor | Detection | Kernel Options Enabled |
|---|---|---|
| KVM / QEMU / Proxmox | kvm, qemu, bochs, proxmox |
Full VirtIO stack: virtio-pci, virtio-blk, virtio-scsi, virtio-net, virtio-balloon, virtio-console, virtio-input, virtio-rng, virtio-crypto, virtio-vsock, virtio-fs, 9p, net-failover |
| VMware | vmware |
VMXNET3, PVSCSI, VMware Balloon, VMCI, VMCI vsock, vmwgfx, vmmouse |
| Generic VM | virtualbox, xen, microsoft |
HYPERVISOR_GUEST, PARAVIRT, PARAVIRT_CLOCK, HIGH_RES_TIMERS, PCI_MSI, VSOCKETS |
- Driver mode control: choose between loadable
moduleorbuiltinfor paravirtual drivers - Guest tools auto-install: optionally installs and enables
qemu-guest-agentoropen-vm-tools
📦 Package Management
- Smart package discovery from actual build artifacts (no fragile filename globs)
- Automatic dependency repair with
apt-get -f installfallback afterdpkg -i - GRUB bootloader refresh via
update-grubafter successful installation - Selective installation: install
linux-image+linux-headersby default, optionally includelinux-libc-dev - Safe cleanup: removes source tree and archives after build while preserving all generated
.debpackages
🧪 Dry-Run Mode
Validate all inputs, paths, and environment configuration without making any system changes:
sudo DRY_RUN=1 ./debian_kernel_build.sh 6.12.93📋 Requirements
- OS: Debian, Ubuntu, Proxmox VE, or any Debian-based distribution
- Shell: Bash 5.0+
- Privileges: Root access (
sudo) - Network: Internet access to download kernel sources from
cdn.kernel.org - Disk space: At least 20–30 GB free (kernel source + build artifacts)
- RAM: Minimum 2 GB, recommended 4 GB+ for parallel builds
All build dependencies are installed automatically by the script:
bcbinutilsbisonbuild-essentialca-certificatescpiodirmngrdpkg-devfakerootflexgitgnupgkmodlibelf-devlibncurses-devlibssl-devopensslpaxctlperlpython3wgetxz-utilszstdOptional:
dwarves(pahole) ·lz4·liblz4-tool
📖 Quick Start — Step by Step
This guide walks you through the entire process. No prior kernel-building experience is required.
Step 1 — Download the Script
Open a terminal on your Debian-based system and run:
wget https://raw.githubusercontent.com/alsyundawy/DebianKernelBuild/master/debian_kernel_build.sh
chmod +x debian_kernel_build.shStep 2 — Choose Your Kernel Version
Visit kernel.org to find the latest stable version (e.g., 6.12.93). You can also use release candidates like 6.15-rc7.
Step 3 — Run the Build
Run the script with sudo and pass the kernel version as the argument:
sudo ./debian_kernel_build.sh 6.12.93The script will automatically:
- Install all required build dependencies via APT (you do not need to install anything manually)
- Detect your VM hypervisor (KVM, VMware, etc.) if you are running inside a virtual machine
- Install VM guest tools (qemu-guest-agent or open-vm-tools) when a supported hypervisor is detected
- Download the kernel source tarball from
cdn.kernel.orgover HTTPS - Verify the OpenPGP signature to ensure the source has not been tampered with
- Extract the source tree into an isolated, timestamped build directory
- Seed
.configfrom your currently running kernel (/boot/config-*) - Open
menuconfigfor you to review and customize kernel options — just save and exit when done - Sanitize the config (disable debug info, clear Debian cert paths, apply VM optimizations)
- Compile the kernel using all available CPU cores (
make -j$(nproc) bindeb-pkg) - Install the generated
.debpackages (linux-imageandlinux-headers) - Refresh the GRUB bootloader so the new kernel appears in the boot menu
- Clean up the source tree and archives (the
.debpackages are preserved)
Step 4 — Reboot
sudo rebootStep 5 — Verify
After rebooting, confirm the new kernel is active:
uname -rYou should see the version you just built (e.g., 6.12.93).
💡 Usage Examples
Basic Usage
# Standard interactive build with menuconfig
sudo ./debian_kernel_build.sh 6.12.93Non-Interactive / Automation
# Fully non-interactive build — ideal for CI pipelines or scripted deployments
sudo CONFIG_MODE=olddefconfig INSTALL_AFTER_BUILD=0 ./debian_kernel_build.sh 6.12.93VM Guest Builds
# VMware guest with modular paravirtual drivers
sudo VM_GUEST_OPTIMIZE=vmware VM_DRIVER_MODE=module ./debian_kernel_build.sh 6.12.93
# KVM/Proxmox guest with built-in drivers and custom kernel suffix
sudo VM_GUEST_OPTIMIZE=kvm VM_DRIVER_MODE=builtin LOCALVERSION=-pvefast ./debian_kernel_build.sh 6.12.93Release Candidate Kernels
# Build a release candidate kernel (automatically uses kernel.org /testing directory)
sudo ./debian_kernel_build.sh 6.15-rc7Build Only (No Install)
# Build packages but do not install them, and keep the source tree
sudo INSTALL_AFTER_BUILD=0 CLEANUP_SOURCE=0 ./debian_kernel_build.sh 6.12.93Testing and Debugging
# Skip OpenPGP verification (use only for emergency testing)
sudo VERIFY_TARBALL=0 ./debian_kernel_build.sh 6.12.93
# Dry-run — validate inputs and environment without making any changes
sudo DRY_RUN=1 ./debian_kernel_build.sh 6.12.93
# Build with debug symbols enabled (for crash analysis, kgdb, BTF, SystemTap)
sudo DISABLE_DEBUG_INFO=0 ./debian_kernel_build.sh 6.12.93Custom Branding
# Add a custom suffix to the kernel v...