Compiling a Custom Linux Kernel in Ubuntu

Recently I started the process of upgrading all deployed server instances of Ubuntu to the latest LTS release Hardy Heron or Ubuntu 8.04.  For the most part the transition was fairly smooth,however several Xen guest images that are deployed on a Dell PowerEdge 1950 virtual server has been plagued with kernel panics.   In attempting to solve this issue I thought I would also use the time to learn the Debian way of building kernel packages.  The process itself is fairly straight forward and might convince me to stop rolling vanilla kernel builds manually.  For future reference,I captured the steps below.

There are several sites (like here and here) out there that contain more instructions and the full background on the process.  Here are the steps I followed to build new deb packages for those that just want the steps and minimal direction.

  1. Update the system
  2. sudo aptitude update
    sudo aptitude safe-upgrade

  3. Install the needed packages
  4. sudo aptitude install gcc kernel-package libc6-dev libncurses-dev fakeroot build-essential

  5. Download an appropriate kernel from kernel.org. For this example it is Linux Kernel 2.6.26
  6. wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.26.tar.bz2

  7. Remove any old link to /usr/src/linux that may exist.
  8. rm -f /usr/src/linux

  9. Unpack the kernel downloaded previously
  10. cd /usr/src &&tar xfj /path/you_downloaded_file/into/linux-2.6.26.tar.bz2

  11. Create a new link to the unpacked source code
  12. ln -s /usr/src/linux-2.6.26 /usr/src/linux

  13. Pull in the current kernel configuration into the new source tree
  14. cp /boot/config-`uname -r` /usr/src/linux/.config

  15. Let the kernel pull in the new configuration values available in the kernel into the old configuration file
  16. cd /usr/src/linux &&make oldconfig

  17. If you need to change or alter configuration values,run the kernel console menu configuration program
  18. cd /usr/src/linux &&make menuconfig

  19. Use the Debian tools to build new deb packages. Instead of uname -m,you may substitute other text to help identify your kernel.
  20. make-kpkg clean
    make-kpkg -initrd -revision=`uname -m` kernel_image kernel_headers modules_image

  21. If all goes well,you can now install the resulting debian packages.
  22. cd /usr/src &&dpkg -i linux*2.6.26*.deb

  23. You can now reboot and try the new kernel out. If something fails,you can always revert back to your older kernel using the GRUB menu at boot.
  24. update-grub &&reboot



Posted from Rowlett,Texas,United States.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • email
  • PDF
  • StumbleUpon
  • Twitter

Comments are closed.