Recompiling the Kali Linux Kernel

3:32:00 م
Recompiling the Kali Linux Kernel

The customizability of Kali Linux extends all the way down into the Linux kernel.
Depending on your requirements, you might want to add drivers, patches, or kernel features that are not included in the stock Kali Linux kernel. The following guide will describe how the Kali Linux kernel can be quickly modified and recompiled for your needs. Note that global wireless injection patches are already present by default in the Kali Linux kernel.

Install Build Dependencies

Start by installing all the build dependencies for recompiling the kernel.
apt-get install kernel-package ncurses-dev fakeroot unxz

Download the Kali Linux Kernel Source Code

Next, download and extract the Kali Linux kernel source.
apt-get install linux-source
cd /usr/src/
unxz linux-source-3.14.tar.xz
tar xvf linux-source-3.14.tar
cd linux-source-3.14/

Configure Your Kernel

Copy over the default Kali kernel .config file and then modify it as needed. This is also the point in the procedure where you would apply any patches, etc., that you required. In this example, we are rebuilding a 64 bit kernel.
cp /boot/config-3.14-kali1-amd64 .config
make menuconfig
The details of using menuconfig to set up a kernel build are beyond the scope of this guide. There is a detailed tutorial on configuring a kernel build on

Build the Kernel

Once you’ve made your customizations and updated your configuration, compile and build your modified kernel image. The Linux kernel image is a big build, expect it to take a while to complete.
export CONCURRENCY_LEVEL=$(cat /proc/cpuinfo | grep processor | wc -l)
make-kpkg clean
fakeroot make-kpkg kernel_image

Install the Modified Kernel

When the build has successfully completed, you can go ahead and install the new custom kernel, and reboot your system. Please note that the specific kernel version numbers will vary — in our example, done on a Kali v1.0.9a system, it was 3.14.5. Depending on the current kernel version you’re building, you will need to adjust your commands accordingly.
dpkg -i ../linux-image-3.14.5_3.14.5-10.00.Custom_amd64.deb
update-initramfs -c -k 3.14.5
Once your system has rebooted, your new kernel should be running. If things go wrong and your kernel fails to boot successfully, you can still use the GrUB menu to boot from the original stock Kali kernel and fix your issues.