HOWTO build linux kernel v2.6

From Chaos

Jump to: navigation, search
This article is part of the HOWTO series.

Contents

Summary

This article explains clearly and concisely how to build and install a 2.6 Linux Kernel.

Details

Obtain Source

1. Download the 2.6 kernel source from ftp://ftp.kernel.org.
2. Copy the file into /usr/src, and decompress it:

root@localhost:~# cp linux-2.6.x.tar.gz /usr/src
root@localhost:~# cd /usr/src
root@localhost:/usr/src# tar -zxvf linux-2.6.x.tar.gz

Prepare the Kernel

1. By default, Slackware symlinks /usr/src/linux to /usr/src/linux-x.x.x, where linux-x.x.x is the kernel version the system shipped with. Remove this symlink, we will have more on this later:

root@localhost:/usr/src# rm linux

2. The default (shipped version) of the kernel in Slackware has a bunch of modules enabled. To re-use this (if you just want a generic kernel), do the following:

root@localhost:/usr/src# cp linux-x.x.x/.config linux-2.6.x/
root@localhost:/usr/src# cd linux-2.6.x
root@localhost:/usr/src/linux-2.6.x# make menuconfig

DO NOT change anything, simply save and exit the menu.

Build the Kernel

1. Run the following:

root@localhost:/usr/src/linux-2.6.x# make bzImage && make modules && make modules_install

Install the Kernel

1. Once it is done building, you are safe to install the new kernel. Do the following, this prepares Lilo, so we can revert to the old kernel if needed.

root@localhost:/usr/src/linux-2.6.x# cd /boot
root@localhost:/boot# rm System.map
root@localhost:/boot# rm vmlinuz
root@localhost:/boot# rm config
root@localhost:/boot# mv config-ide-x.x.x config-x.x.x
root@localhost:/boot# mv vmlinuz-ide-x.x.x Linux-x.x.x
root@localhost:/boot# mv System.map-ide-x.x.x System.map-x.x.x
root@localhost:/boot# cp /usr/src/linux-2.6.x/arch/i386/boot/bzImage /boot/Linux-2.6.x
root@localhost:/boot# cp /usr/src/linux-2.6.x/System.map /boot/System.map-2.6.x
root@localhost:/boot# ln -s System.map-2.6.x System.map

Fix LILO

1. Now that everything is prepared, we need to modify our /etc/lilo.conf:

root@localhost:/boot# vi /etc/lilo.conf

2. Change the default entry (for the older kernel) so it looks something like this:

# Linux-x.x.x
image = /boot/Linux-x.x.x
  root = /dev/hdc1
  label = Linux-x.x.x
  read-only

3. And add a new entry, above the old kernel, for the new kernel:

# Linux-2.6.x
image = /boot/Linux-2.6.x
  root = /dev/hdc1
  label = Linux-2.6.x
  read-only

4. Run lilo, so it's aware of the changes:

root@localhost:/boot# lilo

5. Reboot!

References

Personal tools
Sponsored Links