Reasons why you want to build a custom Linux kernel are numerous. For example, you may want to add driver support for devices which are not recognized by the generic kernel shipped with Linux distros. You may want to optimize the kernel for your hardware, tweak performance tuning options, or turn on or off specific kernel options that cannot modified at run time. If you would like to compile the Linux kernel for any of these reasons, follow these instructions on compiling the Linux kernel on Debian or Ubuntu.
First of all, make sure that you have enough space left in the partition where the kernel source will reside. You need at least 10GB available space in the partition. Once you verify that there is enough space, then proceed as the root as follows.
$ sudo apt-get install kernel-package libncurses5-dev fakeroot wget bzip2
$ sudo apt-get install build-essential udev
$ sudo apt-get install linux-source-$(uname -r)
$ cd /usr/src
$ sudo tar xvfvj linux-source-xxxxxx.tar.bz2
$ sudo ln -s linux-source-xxxxxxx ./linux
$ cd /usr/src/linux
$ sudo make clean && make mrproper
$ sudo cp /boot/config-`uname -r` ./.config
$ sudo make menuconfig
(modify kernel configurations as you wish)
(or you could just do: $ make oldconfig)
$ sudo make-kpkg clean
$ sudo fakeroot make deb-pkg
The last step build is going to take 30 minutes to 1 hour depending on your system. If the build is successful, it will generate linux-image-xxxxxx.deb in /usr/src. You can install the newly built custom kernel image as follows.
Finally, update the grub configuration file (/boot/grub/grub.cfg) to change the default kernel image to load during booting.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to back up a WordPress website to remote cloud storage from the Linux command line - November 24, 2015
- How to access Dropbox from the command line in Linux - November 22, 2015
- How to send email notifications using Gmail SMTP server on Linux - November 9, 2015