This short article describes the quick and easy way on how to customize, build and install Linux kernel under Debian or Ubuntu Linux. First, we will install all prerequisites then download kernel source. Next step will be customization and as a last step we will create and install a Debian package with new Customized Linux kernel.
Let's start with first step which is installation of all prerequisites:
# apt-get install bzip2 build-essential \ kernel-package libncurses5-dev
Next step is to download kernel source code from kernel.org. Untar and cd inside the kernel's directory tree:
$ tar xvjf linux-2.6.34.tar.bz2 $ cd linux-2.6.34
At this point we will do the most important part of creating new customized kernel and building a Debian package. This is all done with a single make-kpkg command.
Optional step is to apply kernel patches before running a following command:
make-kpkg --rootcmd fakeroot --config menuconfig --initrd --us --uc kernel_image
Please note that you can choose different configuration tool instead of menuconfig. For example, if you would like to use xconfig then your command would look like the one below:
make-kpkg --rootcmd fakeroot --config xconfig --initrd --us --uc kernel_image
You have to make sure that all prerequisites for xconfig are installed.
If you already have your .xconfig Kernel configuration file ready ( for example the one delivered with your current kernel installation which can be found in /boot/config-<kernel-version> ) than simply copy it into kernel directory tree as .config and execute:
make-kpkg --rootcmd fakeroot --initrd --us --uc kernel_image
NOTE: If you get a following error message:
echo "The UTS Release version in include/linux/version.h"; echo " \"\" "; echo "does not match current version:"; echo " \"2.6.34\" "; echo "Please correct this."; exit 2 The UTS Release version in include/linux/version.h "" does not match current version: "2.6.34" Please correct this. make: *** [debian/stamp/install/linux-image-2.6.34] Error 2 make: Leaving directory `/home/lilo/temp/linux-2.6.34' make: *** [kernel_image] Error 2
Use a following command to fix this problem and re-run make-kpkg command:
$ cp include/generated/utsrelease.h include/linux/
You new customized Linux kernel is now ready to be installed in form of Debian package.
$ cd .. # dpkg -i linux-image-2.6.34_2.6.34-10.00.Custom_i386.deb
Now you are ready to reboot into new kernel. Good luck !