The following steps will guide you through building a custom kernel for the x86 architecture:
This example uses a 2.6.13 as the kernel version. Your kernel version might differ. To determine your kernel version, type the command in a console uname -r. Replace 2.6.13 with your kernel version.
1.The most important step is to make sure that you have a working emergency boot disk in case you make a mistake. If you did not make a boot disk during the installation, use the mkbootdisk command to make one now. The standard command is similar to mkbootdisk –device /dev/fd0 2.6.x (where 2.6.x is the full version of your kernel such as 2.6.13). Once done, test the boot disk to make sure that it will boot the system.
2.You must have the kernel-source package installed.
Login as 'root'
cp linux-2.6.13.tar.gz /usr/src/linux-2.6 cd /usr/src/linux-2.6 tar -zxvf linux-2.4.2.tar.gz
3.Open a shell prompt and change to the directory /usr/src/linux-2.6. All commands from this point forward must be executed from this directory.
4.It is important that you begin a kernel build with the source tree in a known condition. Therefore, it is recommended that you begin with the command make mrproper. This will remove any configuration files along with the remains of any previous builds that may be scattered around the source tree. If you already have an existing configuration file that works (/usr/src/linux-2.6/.config) that you want to use, back it up to a different directory before running this command and copy it back afterward. If you use an existing configuration file, skip the next step.
5. Now you must create a configuration file that will determine which components to include in your new kernel. If you are running the X Window System, the recommended method is to use the command make xconfig. Components are listed in different levels of menus and are selected using a mouse. You can select Y (yes), N (no), or M (module). After choosing your components, click the Save and Exit button to create the configuration file /usr/src/linux-2.6/.config and exit the Linux Kernel Configuration program.
If you want to use the settings of a default Linux kernel, copy the the configuration file from the /usr/src/linux-2.6/configs directory to /usr/src/linux-2.6/.config. Then, run the make xconfig command and only make the desired changes. Be sure to save your changes to the configuration file.
Other available methods for kernel configuration and are standard with the standard kernel are listed below:
* make config — An interactive text program. Components are presented in a linear format and you answer them one at a time. This method does not require the X Window System and does not allow you to change your answers to previous questions.
* make menuconfig — A text mode, menu driven program. Components are presented in a menu of categories; you select the desired components in the same manner used in the text mode Red Hat Linux installation program. Toggle the tag corresponding to the item you want included: [*] (built-in), [ ] (exclude), <M> (module), or < > (module capable). This method does not require the X Window System.
* make oldconfig — This is a non-interactive script that will set up your configuration file to contain the default settings. If you are using the default Red Hat Linux kernel, it will create a configuration file for the kernel that shipped with Red Hat Linux for your architecture. This is useful for setting up your kernel to known working defaults and then turning off features that you do not want.
6. After creating a /usr/src/linux-2.6/.config file, use the command make dep to set up all the dependencies correctly.
7. Use the command make clean to prepare the source tree for the build.
8. Build the kernel with make bzImage.
9. Build any modules you configured with make modules.
10. Use the command make modules_install to install the kernel modules (even if you did not build any). Make sure that you type the underscore (_). This will install the kernel modules into the directory path.
11. If you have a SCSI adapter and you made your SCSI driver modular, build a new initrd image. Also, if you build your kernel with ext3 support as a module, you must create an initrd image.
12. Use make install to copy your new kernel and its associated files to the proper directories.
13. The kernel is built and installed now.
14. Next, we copy the bzImage over to boot.
cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.13
This is assuming that the new kernel is 2.6.13, obviously.
If you're using Grub, which is becoming more and more common (see my grub page then add the following entry to grub/menu.lst or grub/grub.conf (depending upon your distro.) Let's assume that your 2.6.12 kernel is on /dev/hda2 or (hd0, 1) in grub terminology. So, say grub already has the lines:
title Linux root (hd0,1) kernel /boot/vmlinuz-2.6.12 ro root=/dev/hda2
Add the lines
title Linux New root (hd0,1) kernel /boot/vmlinuz-2.6.13 ro root=/dev/hda2
In other words, you're adding a new title and a new boot image. The rest of it will be indentical to what you already have.
If you're running LILO then say you have the lines:
image=/boot/vmlinuz-2.6.12 label=linux read-only root=/dev/hda2
image=/boot/vmlinuz-2.6.13 label=linuxnew read-only root=/dev/hda2
Again, an almost duplicate entry, simply adding a new label and new boot image. Then, run lilo
You should see a message that it added linux and added linuxnew (Note that with lilo there can be no spaces in the label)
Now reboot, and see what happens. If it doesn't boot for some reason, see if the error messages give a clue, go back and once again run make menuconfig (or whichever you chose) and see if the error can be fixed. If it boots, and hangs at
Ok, uncompressing the kernel
That often means you chose the wrong processor during configuration. If it does work, you might want to keep the old configuration around for a few days to make sure there's nothing you've forgotten, then you can delete the vmlinuz-2.6.12 in your /boot partition and also get rid of the linux.bak drectory.