Kali Linux: Recompile Kernel
Recompiling the Kali Linux Kernel
Home/ 07. Kali Linux Development
On occasion, you might want to add certain 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. Please 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 required for recompiling your kernel. apt-get install kernel-package ncurses-dev fakeroot bzip2 Download Kali Linux Kernel Source Code
Download and extract the Kali Linux kernel source. apt-get install linux-source cd /usr/src/ tar jxpf linux-source-3.7.tar.bz2 cd linux-source-3.7/ Configure Your Kernel
Copy over the default Kali kernel .config file and then modify it to your needs. This is the stage where you would apply various patches, etc. In this example, we are re-compiling a 64 bit kernel. cp /boot/config-3.7-trunk-amd64 .config make menuconfig Build the Kernel
Compile your modified kernel image. Depending on your hardware, this could take a while. CONCURRENCY_LEVEL=$(cat /proc/cpuinfo|grep processor|wc -l) make-kpkg clean fakeroot make-kpkg kernel_image Install the Kernel
Once the kernel has successfully compiled, go ahead and install the new kernel and reboot. Please note that kernel version numbers may change – in our example, it was 3.7.2. Depending on the current kernel version, you might need to adjust it accordingly. dpkg -i ../linux-image-3.7.2_3.7.2-10.00.Custom_amd64.deb update-initramfs -c -k 3.7.2 update-grub2 reboot
Once rebooted, your new kernel should be running. If things go wrong and your kernel does not boot, you can still boot the original stock Kali kernel and fix your issues.