how to compile linux kernel on redhat


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to compile linux kernel on redhat
# 1  
Old 07-21-2008
how to compile linux kernel on redhat

Hello,
Please let me know how to compile a linux kernel on redhat. I am relatively new in this area so please be a little patient with me. Here is the file I was consulting with the following details:
Compiling the Linux Kernel on Redhat 7.1

This page describes how to install the latest Linux version 2.4 kernel on Redhat 7.1. In particular, it describes how to compile the official kernel sources with Redhat's default configuration.
Motivation

It can be quite tricky for a typical Linux user to configure the official linux kernel source from www.kernel.org to work with Redhat. For example, I once compiled a kernel that didn't work with my sound card. The best way to avoid such headaches is to get the kernel source config file from the Redhat source RPM, and to use this config with the official kernel source from kernel.org. The following instructions outline how this can be done. I suggest using this guide as a supplement to the usual documentation, not as a replacement.
Download the Sources


  • Download latest stable kernel source from kernel.org. Don't try to compile the same version that you are already using unless you know what you are doing, or you risk messing up your kernel modules. You can figure out what kernel you are already running with $ uname -r
  • Unpack the sources. Older versions had to be unpacked in /usr/src, but now days you are probably better off compiling the source in your own home directory logged in as a normal user. $ tar xzf linux-2.4.3.tar.gz
  • You can get the config files from the kernel source RPM. Unfortunately, this implies installing over 100 MB of kernel source just to get a single 30 kB file. Be aware that there are two different source RPMs, i.e. kernel-xxx.xxx.srpm and kernel-source.xxx.xxx.rpm. Once you have these files, it is probably possible to uninstall the source RPM to save disk space. To save you the time and hassle, here are the config files for kernel 2.4.2, as shipped with the Redhat 7.1 source RPM. $ tar xzf configs.tar.gz
Configure


  • In top directory of your kernel source from kernel.org, run $ make mrproper
  • Copy the most appropriate config file for your system into .config in the top directory of the kernel source. $ cp configs/kernel-2.4.2-i586.config linux-2.4.3/.config
  • Your config file is for an older version of the kernel, and so must be updated. The following command will only ask questions about new features. Most of the time you can safely leave out these new features unless they specifically interest you. $ make oldconfig
  • As configured, your kernel and modules will support a huge variety of hardware and features that you don't need. You might want to turn off some of things to speed up the compile and save disk space. Or you may want to enable some feature that was turned off in the default. To do so, run $ make xconfig
  • Make a backup copy of .config. $ cp .config ~/backup-kernel-config
Compile the kernel and modules


  • This part is easy. You'll have plenty of time to go get a cup of coffee.... $ make dep
    $ make bzImage
    $ make modules
Install your new kernel


  • Up to now, you have hopefully been logged in as a normal user. Now you'll need to become root. $ su
  • Copy the kernel into its final destination. Don't overwrite your working kernel!!! # cp ~user/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.4.3
  • Install the modules. # make modules_install
  • Edit /etc/lilo.conf so that you can boot the new kernel. Don't take out the lines for your working kernel until you have booted the new one!!! In the following example, you'll probably have to change the location of the root partition. image=/boot/vmlinuz-2.4.3
    label=linux-2.4.3
    read-only
    root=/dev/hdc2
  • Run lilo # /sbin/lilo
  • If you want a rescue disk, do $ make bzdisk
continued: I went to the kernel.org site downloaded the the latest stable version of linux, untarred the file, I also downloaded configs.tar.gz and untarred it. i am now confused, what to do next? Thanks in advance. What is the top directory of my kernel source, getting a bit confused from hereon. Please explain or you can explain the whole process from the beginning. Also I am not working with linux 7.1, but with Linux 4.0, however, i am hoping they would be same. Thanks!Smilie
# 2  
Old 07-22-2008
First of all, you should know what hardware you have, before compiling your own kernel, so you don't have to add modules you will not need and will make the kernel bigger than needed.

Second, I can't tell about the speciallities for Red Hat, but all in all it's like the guy described, what you already wrote.

So what do you want to have explained from this guide? And there is a lot of page in the web dedicated how to build a kernel, btw.
# 3  
Old 07-22-2008
how to compile linux kernel on redhatII

Thanks for the response! So how do I detect the hardware my Linux system have, and how do I determine what I need what I do not? Also, what is the meaning of the sentence "on top directory of your kernel source from kernel.org, run $ make mrproper" what is this top directory, I know I unpacked the linux in /usr/src/linux, is this directory they are talking about? Please let me know. Thanks!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Compile smbfs module in kernel version 3.10 running Ubuntu 12.04 LTS

Is there any way to compile smbfs module in kernel 3.10 running Ubuntu 12.04 LTS. I did a 'make menuconfig' and it shows cifs. I found out online that smbfs is deprecated and replaced by cifs. I have an old system with kernel version 2.4 which only has smbfs (no cifs). Is it possible to compile... (1 Reply)
Discussion started by: Monil
1 Replies

2. UNIX for Dummies Questions & Answers

can i get UNIX kernel and compile it like Linux ?

I am not a newbie to Linux, i have been using Linux as my desktop for 4 years, but i am just an end user to Linux, no advanced knowledge to it. I knew that, i can download generic linux kernel and compile it by myself, but how about Unix? how can i get an Unix kernel and compile it ? or no this... (5 Replies)
Discussion started by: wong.sie.ung
5 Replies

3. Ubuntu

Kernel compile error

Hi I'm compiling a real-time kernel in linux, but after I type make bzImage things end with this: (Things going well doing CC and things).... CC arch/x86/kernel/kgdb.o CC arch/x86/kernel/vm86_32.o CC arch/x86/kernel/early_printk.o CC arch/x86/kernel/ipipe.o... (2 Replies)
Discussion started by: mdop
2 Replies

4. Linux

Howto compile my own module into the kernel

Hi there, I'm currently writing a program/module which makes use of the Linux Security Modules (LSM), which provide hooks for some security . The bad thing about it is: The function to set the hook to the LSM is not exported. That means, I can't just write a loadable kernel module, but have to... (3 Replies)
Discussion started by: disaster
3 Replies

5. UNIX for Dummies Questions & Answers

Compile most recent kernel on older distro ?

Debian lenny uses the 2.6.26 kernel by default. Can I compile the most recent kernel from kernel.org and use it instead ? Will the new kernel be incompatible with other installed softwares ? (1 Reply)
Discussion started by: cyler
1 Replies

6. Slackware

Compile Leanest Slackware Kernel

My goal is to make the leanest Slackware kernel possible for my machine specifically. I'm not exactly a newbie to unix, but I'm not an expert. I tried this tutorial Chapter*18.*Building a kernel , but I would like something in more depth to really make a lean slack machine. Where should I go? (2 Replies)
Discussion started by: darkstarxor
2 Replies

7. Linux

kernel compile

Dear experts, How can compile the kernel as application mode? Thanks in advance. (2 Replies)
Discussion started by: Zaxon
2 Replies

8. Debian

compile kernel with OFED

Hello Friends, I know how to compile the kernel . But I don't know how to compile the kernel with OFED. Can any one assist me on that. Or can anyone send me the link. Thank you. (0 Replies)
Discussion started by: pradeepreddy
0 Replies

9. Linux

Compile new kernel in Fedora 5

Hi All, I try to compile new kernel in FC5. New kernel version - 2.6.20.21 Operating System - Fedora 5 I have followed these steps, make menuconfig make make modules make modules_install make install Then i have changed the grub.cong and reboot the system with new kernel. The... (0 Replies)
Discussion started by: viveksnv
0 Replies

10. UNIX for Advanced & Expert Users

compile a new kernel in RHEL 5

Hi all, I need some help in compiling a new kernel. I am using RHEL 5 with kernel version 2.6.18. I have downloaded a kernel from link http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.6.tar.bz2 1. cd /usr/src 2. wget -c http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2 3.... (1 Reply)
Discussion started by: vikas027
1 Replies
Login or Register to Ask a Question