How To Build Linux kernels the Debian way

Article By: samantha


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 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- ) 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:
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: , , ,

Welcome to the healthcare-only HIPAA - GDPR compliant cloud. Exclusively hosted on a HPC environment!

Learn more or start today by choosing your secure HIPAA - GDPR compliant server's Operating System bellow and pick the package that's best for you.

BIPmd makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine, thousand or more.

Windows VPS options and add ons
Linux VPS options and add ons


Looking for a custom solution?

Our technicians can provide you with the best custom-made solutionss on the market, no matter whether you're a small business or large enterprise.

Get in touch

Leave a Reply