From time to time you need to add some modules in the kernel which are not compiled in by default. To achieve that you need to compile your kernel. In this post we will go over the steps you need to take to compile your own kernel.
First of all you will need to find a source for your kernel you can either download the kernel source from kernel.org and place it to
/usr/src or get it from the apt repository.
#apt-get source linux-image
You will need to install some extra packages:
#apt-get install fakeroot kernel-package libncurses5-dev
Ones you have downloaded the package you will find it in
If you have downloaded the package from kernel.org the package will be most probably archived with bzip2 so you will need to unpack it.
#tar -xvJf linux-3.17.tar.xz #cd linux-3.17/
Now we want to use configure the kernel. Best we start with the configuration file of the current setup. To do that use the following command:
#cp /boot/config-`uname -r` .config
To add the new modules you need to run make menuconfig
Select the modules you need and save the configuration file before you exit. It is time to start the compilation. First we need to clean the source.
Before we start building the new kernel it is a good idea to set the new concurrency level. The maximum which can be set is equal with the number of cores your system have +1. For example if you have a 4 core cpu then the concurency level is equal with 5. Setting the concurrency level will significantly shorten he new kernel's compilation time.
Now it's time to build the new kernel.
#fakeroot make-kpkg --append-to-version "-customkernel" --revision "1" initrd kernel_image kernel_headers
--append-to-version you set a custom description in the kernel name. The
--revision would set the revision version of the build.
After the kernel is compiled the new packages will be found in
/usr/src. You can install them by running the following command:
/usr/src# dpkg -i linux-image-3.17.0-customkernel_1_amd64.deb /usr/src# dpkg -i linux-headers-3.17.0-customkernel_1_amd64.deb