Dashboard > Linux > Building a Custom Linux Kernel > Information > Page Comparison
Linux Log In   View a printable version of the current page.
Building a Custom Linux Kernel
compared with
Current by Scott Kveton
on Jun 08, 2004 08:06.

(show comment)
 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 1 changes. View first change.

  
  
  
 The following describes how to build a custom Linux kernel for Debian GNU/Linux.
  
 I'm sure there are better ways to do this but this seems to be the most reliable for me and our environment here. As always, I'm open to comments and suggestions on how to improve this document.
  
 So you've got your machine installed (possibly using [my ISO|http://wiki.osuosl.org/display/LNX/Debian+on+Dell+Servers]) and now you want to put a better/more customized kernel.
  
  The following lists out the complete steps but [V.J. McIntyre|http://www.atnf.csiro.au] was kind enough to make a [fantastic shell script|http://wiki.osuosl.org/download/attachments/862/make-new-iso.sh] for automating these steps. Thanks V.J.!
  
 h2. Installing a fresh kernel
  
 First off, install the 'kernel-package' debian package by running 'apt-get install kernel-package'.
  
 Now get the latest/greatest source from www.kernel.org. As of this writing its 2.4.25.
  
 Copy the source into /usr/src (this can be anywhere but this is the most common), tar zxf it there.
  
 We'll take the first case that you have never installed a Debian kernel and that you don't have X installed/working.
  
 Make sure you have the libncurses5 and libncurses5-dev packages installed (apt-get install libncurses5 libncurses5-dev).
  
 {code}
 cd /usr/src/linux
 make menuconfig
 {code}
  
 Configure your kernel as you see fit. I just compile stuff into the kernel ... modules are for sissy's ... however, the Debian kernel package tool doesn't care if you're a sissy ... :-)
  
 Once you have configured and saved your kernel config you run the following in /usr/src/linux:
  
 {code}
 make-kpkg kernel_image
 {code}
  
 This will commence to install the debian specific directory with configs, make sure you have a .config present and then build the kernel image. The kernel image will be /usr/src/kernel-image--.deb. You can install this kernel using 'dpkg -i kernel-image...deb' from the command-line. If you are installing this kernel on another machine you'll probably want the kernel headers as well so compilation of software that needs it will work correctly. To build that you run the following in /usr/src/linux:
  
 {code}
 make-kpkg kernel_headers
 {code}
  
 Same deal; it will make a .deb named accordingly that you can run dpkg -i on.
  
 So that's all well-and-good but its technically more of a pain than just doing make; make bzImage; make install ... but there is a method do the madness. The real benefit comes when the next kernel revision comes.
  
 h2. Upgrading a Kernel
  
 Let's say you compiled v.2.4.16 and then v.2.4.17 comes out. Let's just say you really need the features in v.2.4.17 so you go ahead and decide to build it.
  
 Grab the new source and put it in /usr/src/linux (moving the v.2.4.16 out of the way). Copy /usr/src/linux-2.4.16/.config to /usr/src/linux (where /usr/src/linux is the v.2.4.17 kernel source).
  
 Now run:
  
 {code}
 make-kpkg kernel_image
 {code}
  
 The kernel package will then commence to parse your .config, diff it with the new one, prompt you with anything that is new or changed and then proceed to build the actual kernel image placing it at /usr/src/*.deb as listed above.
  
 Now you can install the new kernel with dpkg -i if you want ... same goes for the kernel_headers.
  
 Another nice thing about using the kernel package for Debian is that it also update your LILO (assuming that is your bootloader). So it will move your old kernel to LinuxOLD and and run 'lilo' for you. That way, if you screw up your kernel you can revert to a working one without having to smack yourself on the head for totally hosing your machine.
  
 Alright, that's about all I've got on kernel mojo ... I think I went a little overboard but I'm saving this for me too ... :-)
Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.7 Build:#524 Jul 28, 2006) - Bug/feature request - Contact Administrators