Menu
User

DropVPS Team

Writer: Cooper Reagan

How to install Mainline Kernel on Kali linux

How to install Mainline Kernel on Kali linux

Publication Date

10/07/2025

Category

Articles

Reading Time

3 Min

Table of Contents

Upgrading Kali Linux to a mainline Linux kernel unlocks new hardware support, performance boosts, and fresh security features. The safest approach is to build Debian packages from kernel.org sources and keep your old kernel for rollback. Expect better device compatibility, faster I/O, and improved energy efficiency. Back up and use stable power.

Check current kernel and prepare a fallback

Confirm your running kernel and note it for GRUB fallback if needed. Also verify CPU cores and free disk space.

uname -a
cat /etc/os-release
nproc
df -h / /boot
Linux kali 6.8.0-kali3-amd64 #1 SMP PREEMPT_DYNAMIC ... x86_64 GNU/Linux

💻 Looking for reliable Linux VPS hosting? Buy Linux VPS with full root access and instant setup.

Update Kali and install build prerequisites

Install all required toolchains and libraries for compiling and packaging the kernel as .deb files.

sudo apt update
sudo apt full-upgrade -y
sudo apt install -y build-essential bc fakeroot ccache git curl ca-certificates \
libncurses-dev bison flex libssl-dev libelf-dev dwarves

Download the latest stable mainline kernel source

Fetch the latest stable tarball from kernel.org. Replace the version with the current stable if newer.

VER=6.12.7
cd /usr/src
sudo wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-$VER.tar.xz
sudo tar -xf linux-$VER.tar.xz
sudo chown -R "$USER":"$USER" linux-$VER
cd linux-$VER

Reuse Kali’s current kernel config

Seed the new kernel with your existing Kali config for maximum compatibility, then auto-accept new defaults.

cp -v /boot/config-$(uname -r) .config
yes "" | make olddefconfig

(Optional) Tweak kernel options

Open a text UI to enable or disable features such as BPF, WireGuard, or specific drivers. Skip if unsure.

make menuconfig

Build Debian kernel packages

Compile and package the kernel without root. This creates .deb files one directory above the source tree.

export CCACHE_DIR="$HOME/.cache/ccache"
export LOCALVERSION="-mainline"
fakeroot make -j"$(nproc)" bindeb-pkg
cd ..
ls -1 *.deb
linux-headers-6.12.7-mainline_6.12.7-1_amd64.deb
linux-image-6.12.7-mainline_6.12.7-1_amd64.deb
linux-libc-dev_6.12.7-1_amd64.deb

Install the new kernel packages

Install image and headers. The installer updates initramfs and GRUB automatically.

sudo dpkg -i linux-image-6.12.7-mainline_*.deb linux-headers-6.12.7-mainline_*.deb

If dkms modules (e.g., VirtualBox, Nvidia) are used, rebuild them.

sudo apt install -y dkms
sudo dkms autoinstall

Regenerate boot files and reboot

Ensure initramfs and GRUB entries exist, then restart into the new kernel.

sudo update-initramfs -u -k 6.12.7
sudo update-grub
sudo reboot

Verify the running kernel

Confirm the system is using the mainline kernel.

uname -r
6.12.7-mainline

Rollback or remove the mainline kernel

If something breaks, select “Advanced options for Kali” in GRUB and boot the previous kernel. To remove the new kernel:

sudo dpkg -l | grep linux-image
sudo apt purge -y "linux-image-6.12.7-mainline" "linux-headers-6.12.7-mainline"
sudo update-grub

Alternative: Quick install via Ubuntu Mainline builds (unsupported)

This script fetches prebuilt kernels from kernel.ubuntu.com. It is fast, but less aligned with Debian/Kali. Use only if you accept potential breakage.

sudo apt install -y wget xz-utils
wget -O /usr/local/bin/ubuntu-mainline-kernel.sh https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
sudo chmod +x /usr/local/bin/ubuntu-mainline-kernel.sh
sudo ubuntu-mainline-kernel.sh -i v6.12.7
sudo reboot

Upgrade to a mainline kernel on Kali safely by building Debian packages, keeping GRUB fallbacks, and testing drivers.

Linux VPS
U
Loading...

Related Posts