Pages

Compiling linux kernel on debian

Here are the steps to compile a kernel from source in debian based systems.

Note:These steps have worked successfully on debian 6.0 (linux 2.6.32)
You will need a package by the name kernel-package, which implements the commands required for compilation, hence run



1. Download the source of the kernel version to which you want to compile e.g. linux-3.1.5.tar.bz2 or linux-3.1.5.tar.gz for linux kernel version 3.1.5 2. Untar the source using



Now change directory to kernel source



The make-kpkg command which we will use to compile the kernel might some times fail generate the initrd, to make sure the initrd is generated at the end of compilation run the following command.



Create a config file using the command



This will create a default configuration file, to customize it we can either open the .config file using an editor and set the required configuration or use the menuconfig i.e



Note: ncurses-devel package would be required to launch the menuconfig, hence if menuconfig does not launch with the error that ncurses was not found install the package.


A graphics window should launch which will allow you to select the options you need and then create an updated .config file based on your choices.
Now to compile and generate the deb package for the new kernel run the command



If you want the kernel headers too then add the target kernel-headers also to the command. 10. If the compilation in the above step finishes with out any errors, you should have a .deb package, linux-image-3.1.5_3.1.5-10.00.Custom_i386.deb in the folder in which you have placed the source package.
Install the package using



Now if you restart the system, the grub should list out this kernel too in the boot options, on selecting which you will boot into the custom kernel with your system call in it.


We can confirm the kernel version using the command


7 comments:

  1. Perhaps this is a bit off topic but in any case I have been surfing about your blog and it looks really neat. impassioned about your writing. I am creating a new blog and hard-pressed to make it appear great and supply excellent articles. I have discovered a lot on your site and I look forward to additional updates and will be back.
    http://scarprin.info/

    ReplyDelete
  2. You can also use squeeze backports. Kernel on this repositories is 3.X.

    ReplyDelete
    Replies
    1. Yes that is always an option if you don't want to do the compilation.

      Delete
  3. Why not use linux-source-3.1?

    ReplyDelete
    Replies
    1. You can use any kernel source that should not be a problem.

      Delete
  4. Thank you very much for that dazzling

    article.

    For more info click here

    http://www.scarprin.com/

    ReplyDelete
  5. newer drivers and higher, the more bugs are worked out.

    ReplyDelete