birmingham@ic.fbi.gov , phoenix@ic.fbi.gov , fbise@leo.gov
NickSoft Linux Cookbook Index NickSoft Linux Cookbook
Quick howto's, Real live examples.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Kernel compile for RedHat based linux [beta]

 
Post new topic   Reply to topic    NickSoft Linux Cookbook Index -> Kernel Comile & Install
View previous topic :: View next topic  
Author Message
NickSoft
Site Admin


Joined: 13 Nov 2006
Posts: 22

PostPosted: Fri Jan 05, 2007 2:50 pm    Post subject: Kernel compile for RedHat based linux [beta] Reply with quote

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:
Redhat
Fedora
Redhat Enterprise
CentOS

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:
Fedra 6 - http://download.fedora.redhat.com/pub/fedora/linux/core/6/source/SRPMS/
Fedora 1, Fedora 2, Fedora 3, Fedora 4, Fedora 5
RHEL 4 - ftp://ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os/i386/SRPMS/
CentOS - http://isoredirect.centos.org/centos/4/isos/SRPMS/ [mirrors]

Preparing the sources
Download 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:
Code:
ls /usr/src/linux*

you should see directories like "linux-2.6.18" or "linux" if you have the kernel source installed.

Code:
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


    * if you are using pentium 1 processor use --target=i586 for rpmbuild option
    * if you are using 2.4 kernel .spec file will be named kernel-2.4.spec
    * putting link to linux-2.6.18 directory is good idea because there are some programs which refer to linux sources with /usr/src/linux directory. If you have older version of kernel source you should remove the "linux" link to old kernel directory first


Configuring the kernel
If kernel is the same version as currently running you can copy config file from your /boot directory:
Code:
cd /usr/src/linux
cp /boot/config-2.6.18.xxx ./.config

Or you can use some of default configs:
Code:
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:
Code:
cd /usr/src/linux
make menuconfig

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 install
compilation is almost the same on all linux distributions:
Code:
make dep #for 2.4 (or lower) kernel version only
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 old kernel
It'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:
Code:
cd /boot
rm initrd-<version>.img
rm System.map-<version>
rm vmlinuz-<version>
cd /lib/modules
rm <version>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NickSoft Linux Cookbook Index -> Kernel Comile & Install All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




MLDb.org Magic Eight Ball Croler Web Search Croler Web Directory Bianca Ryan MyBestMatch.net Microlab.info Digger Services Sofia

Powered by 220V

AbuseIPDB Contributor Badge