Compile latest Linux kernel for Debian


Install needed packages

apt-get install fakeroot kernel-package libncurses5-dev

Download latest Kernel source

As of this writing, the latest source is 4.3.3

export KVERSION=4.3.3
tar xvJf linux-$KVERSION.tar.xz

Start configuring

cd linux-$KVERSION

Get current config

cp /boot/config-`uname –r` .config

Start menuconfig and change the stuff you want to:

make menuconfig


make-kpkg clean


Export the wanted concurrency (number of cores + 1) and build a Debian package of the kernel.

fakeroot make-kpkg --append-to-version "-customkernel" --revision "1" --initrd kernel_image kernel_headers

When this command is complete, we will have two dpkg files, one for the kernel and one for headers. The great thing about this is that we can just install them and it will fix grub for us.

dpkg -i linux-headers-$KVERSION-customkernel_1_amd64.deb linux-image-$KVERSION-customkernel_1_amd64.deb


Remove everything we do not need anymore:

cd ~
rm -f linux-$KVERSION.tar.xz
rm -rf linux-$KVERSION
rm -f linux-headers-$KVERSION-customkernel_1_amd64.deb linux-image-$KVERSION-customkernel_1_amd64.deb

Remove a custom kernel

To remove a kernel that we are not using, or that does not work just uninstall it.

apt-get remove linux-image-$KVERSION-customkernel linux-headers-$KVERSION-customkernel