linux kernel This short tutorial describes a quick and easy way to customize, build and install a Linux kernel under Debian or Ubuntu Linux. First, we will install all prerequisites and then download the kernel source. Next step will be the customization or the kernel and the last step will be to create and install a Debian package with the new Customized Linux kernel.

1. Prerequisites

Let’s start with the first step which is installing all the prerequisites:

# apt-get install bzip2  build-essential \ 
kernel-package libncurses5-dev

2. Kernel build and customization

Next step is to download the kernel source code from kernel.org. Then untar the file and cd into the new 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 (create the new customized kernel) and build the Debian package. This is all done with a single make-kpkg command.

NOTE:
Optional step is to apply kernel patches before running a following command:

make-kpkg --rootcmd fakeroot --config menuconfig --initrd --us --uc kernel_image

  • –us do not sign source
  • –uc do not sign changelog
  • –initrd perform any actions necessary for a kernel loaded using initrd
  • — rootcmd fakeroot command that provides a means of gaining super user access
  • –config menuconfig will use menuconfig as a configuration tool where default is oldconfig

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

Make sure that all the 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 the 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[1]: *** [debian/stamp/install/linux-image-2.6.34] Error 2
make[1]: Leaving directory `/home/lilo/temp/linux-2.6.34'
make: *** [kernel_image] Error 2

Use the following command to fix the problem and re-run make-kpkg command:

$ cp include/generated/utsrelease.h include/linux/

3. Installation of the Customized Linux Kernel

Your new customized Linux kernel is now ready to be installed.

$ cd ..
# dpkg -i linux-image-2.6.34_2.6.34-10.00.Custom_i386.deb

Congratulations, now you are ready to reboot into the new kernel!



Tags: , , ,

Spin up a cloud server in no time flat

Simple setup. Full root access. Straightforward pricing.


DEPLOY SERVER




Leave a Reply