———
|
Table of Contents
Kernel compile for RedHat based linux [beta]There are many howtos for compiling kernels, but most of them don't work. Why? It's not that they are wrong. The problem is that every linux distribution has its own idiosyncrasies. There is no howto that works for all cases. This document will help you to compile linux kernel for Redhat based distributions:
First of all you must have the kernel source. Even all Redhat distributions are similar, kernel source is not installed in the same way for all of them. With Redhat 6,7,8 and 9 you can select kernel source from OS installer or later you can install kernel-source-xxx.rpm Some (or all?) Fedora distributions don't have this package. One thing is sure for all Redhat distributions - complete source of open source packages is provided in .src.rpm format, including the linux kernel. Sources are usually not included with distributions, but you can download them from official websites as well as mirror sites. Here are some locations of OS sources:
Preparing the sourcesDownload and install source rpm. Please correct file name and url depending on what OS you are using. Good idea is to check if you already have the source: ls /usr/src/linux* You should see directories like “linux-2.6.18” or “linux” if you have the kernel source installed. cd ~ wget http://download.fedora.redhat.com/pub/fedora/linux/core/6/source/SRPMS/kernel-2.6.18-1.2798.fc6.src.rpm rpm -i kernel-2.6.18-1.2798.fc6.src.rpm cd /usr/src/redhat/SPECS rpmbuild -bp kernel-2.6.spec --target=i686 cd /usr/src/kernel/BUILD/kernel-2.6.18/ mv linux-2.6.18.i686 /usr/src/linux-2.6.18 cd /usr/src ln -s linux-2.6.18 linux
Configuring the kernelIf kernel is the same version as currently running you can copy config file from your /boot directory: cd /usr/src/linux cp /boot/config-2.6.18.xxx ./.config Or you can use some of default configs: cd /usr/src/linux ls ./configs cp ./configs/kernel-2.6.18-xxxx ./.config The best way is to use ncurses configure program to select compile options for kernel: cd /usr/src/linux make menuconfig If this doesn't work try to install ncurses-devel-xxx.rpm package. Use “make help” command to see other configure targets. I won't describe various configure options here. There will be separate howto for configuring the linux kernel. Compile and InstallCompilation is almost the same on all linux distributions: make dep #for 2.4 (or lower) kernel version only make bzImage make modules make modules_install make install “make install” will configure automatically your current boot installer to load new kernel, but you can check it jsut in case. Do not delete old kernel from boot loader. If your new kernel fails to boot use old kernel. If you re-compile the new kernel using different options be sure that you booted with your old kernel or else “make install” will fail. Removing the old kernelIt's not a good idea to remove your original kernel, but if you compiled and installed second kernel and you need to update it with latest version you may want to remove it. To remove a kernel you must delete these files: cd /boot rm initrd-<version>.img rm System.map-<version> rm vmlinuz-<version> cd /lib/modules rm -fr <version> |