Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-03-2005, 08:52 AM   #1
Registered: Feb 2005
Posts: 43

Rep: Reputation: 15
does kernel-source installs with the compilation cum installtion of a new kernel?

If i download the tarball of a new kernel
compile it
and install it

then would the package kernel-source be installed or i shall have to intall it seperatey by first finding the appropriate rpm source and then using
apt-get ?

Muhammad Muzzamil Luqman
Old 03-03-2005, 09:28 AM   #2
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
What distribution are you using (I suspect Debian or Debian-based since you mentioned apt-get)?Where are you supposed to get your kernel tarball from? What have the rpms to do with apt-get? It's true you can use rpms in Debian distros using alien but that's for binary packages.
Old 03-03-2005, 09:37 AM   #3
Registered: Feb 2005
Posts: 43

Original Poster
Rep: Reputation: 15
noops i am using redhat9.0
and i have installed the apt-get separately on my box.

will you please tell me something about my problem
Old 03-03-2005, 09:55 AM   #4
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
You can have a new kernel by:
-installing an already compiled version of it (via apt-get, yum or whatever you're using);
-getting the source with apt-get with the "source" and "--compile" options specified in order to perform the compiling and installation as well;
-downloading the sources from and compiling them yourself.
The latter implies two things: that is the "original" kernel and is not patched or modified in any way for a particular distribution and also means some knowledge about your hardware in order to compile it succesfully.

Good luck!
Old 03-03-2005, 10:01 AM   #5
Registered: Feb 2005
Posts: 43

Original Poster
Rep: Reputation: 15
If i go with the last option, will the package kernel-source be installed or shall i have to install it afterwards ???
Old 03-03-2005, 10:24 AM   #6
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
The last option means a set of steps that have to be performed after downloading the kernel sources and wich, eventually, will lead to the new kernel to be installed (not as a package, but as a compiled source software).
The main steps are:
-unpack the sources. At this point some say to unpack in /usr/src. Others say it's better to do it in another directory (/home/kernel for example) to avoid conflicting headers declaration. I'd go with the second option as my kernel failed to compile correctly in /usr/src. The situation may vary, of course.
-configure the kernel. It can be done several ways:
'make oldconfig' - this will conigure your kernel based on the contents of a .config file took from an older kernel, which will spare you from choosing between the many options
'make config' - this is probably the "ugliest" method of configuring as it is text-only, hundreds of lines scrolling one after the other on your screen asking you for an "M", a "y" or a "n".
'make menuconfig' - an ncurses based configuration which requires ncurses-devel package installed
'make xconfig' - an graphical based interface for the configuration process; also requires some qt and X libraries installed.
-build the kernel: 'make bzImage'
-build the modules: 'make modules'
-install the modules: 'su' + 'make modules_install'
Optionally, depending whether you have built-in your kernel ext2/3 filesystem support, create the initial ram disk (initrd for short):'mkinitrd /boot/initrd-2.6.11.img 2.6.11' This command may vary a lot, depending on the kernel's version and distribution.
-finally, copy the necessary files: 'cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.11' + 'cp /boot/'

For more information, just in case I missed something, check out these links as well:

You will need to edit aftwerwards the configuration files of GRUB or LILO, whichever you're using, to point to the new kernel.

Good luck once again.

Last edited by harken; 03-03-2005 at 10:26 AM.
Old 03-03-2005, 10:48 AM   #7
Registered: Feb 2005
Posts: 43

Original Poster
Rep: Reputation: 15
i have successfully installed the new kernel-2.4.25 on my redhat 9.0 (shrike). It boots correctly and i am able to ssh in to my box.

Now the problem is that when i do

#uname -r

that ok.

but if i do

#rpm -qa | grep kernel

It doesn't even mention my new kernel

i have done all this to get the kernel-source package installed but :

#rpm -qa kernel-source
package kernel-source not installed

the steps for the compilation and the installtio were:

Linux Kernel Compilation

Steps in compiling a kernel:

* Installing the sources.
* Configuring the kernel (choosing which features and Drivers to compile).
* Compiling the kernel (i.e. typing a single command, and watching...).
* Installing the compiled kernel.
* Updating the boot loader to recognize the new kernel.
* Booting...
* Making the new kernel become the default.

Kernel "Types"

* The Linux kernel comes in two variants - the "vanilla" kernel, and the distribution's kernel.
* The "vanilla" kernel is the kernel officially released by Linus, or by a member of the community appointed by Linus (e.g. kernels version 2.4.X are officially maintained and released by Marcelo Tosatti).
* The distribution's kernel is normally a "vanilla" kernel, with many patches on top of it that either did not get accepted to the "vanilla" kernel, or that the distribution's maker back-ported from newer kernels.
* Thus, normally the latest "vanilla" kernel has more features...
* ... while the distribution's kernel has gone through more orderly testing and could be more stable.

Getting The Source

* The sources of linux kernels are available via the Internet, or on the distribution's CDs.
* Of-course, there are many mirrors, and since we're talking about not-so-small files (around 30MB), we better know our mirrors.
* In Israel, one may try Iglu's mirror, at, or check Hamakor's Israeli mirrors list, at

The Source Of The Distribution's Kernel

* The source code of the distribution's kernel comes as another package on the installation CDs.
* On RedHat 9, for example, it is stored in a file named 'kernel-source-2.4.20-8.i386.rpm'.
* Installing it is done like installing any other RPM package:

rpm -Uvh /path/to/kernel-source-2.4.20-8.i386.rpm

* If The distribution's maker updated the kernel, the new kernel sources would be found among the updates.
* In RedHat 9, the current file is kernel-2.4.20-28.9.src.rpm, found in the SRPMs (Source-RPMs) directory.

The Source Of The Vanilla Kernel

* The "vanilla" kernel is normally kept at, as a tar.gz (or tar.bz2 - better compressed) file.
* For example, the latest 2.4 kernel for now is found at
* Unpack these kernel sources as root:

cd /usr/src/
tar xjf /path/to/linux-2.4.24.tar.bz2

* You will get a new directory named 'linux-2.4.24', containing the sources.

"Readying" The Sources

* Before we do anything with the sources, we should make sure the source tree does not contain any old object files or configuration information...
* ... That got there accidentally.
* This is especially true for distribution kernels - they tend to contain various stale files.
* To do this, go into the source directory and run the command:

make mrproper

Configuring The Kernel

* Before we compile the kernel, we need to configure it.
* This includes telling it which drivers and features to compile ...
* ... and how to compile them (as modules or inside the kernel's main file).
* Several configuration programs are supported by the kernel, to be launched using one of the following commands:

make config
A simple text-mode program, that asks a zillion questions one after the other. Not recommended.
make menuconfig
A full-screen text-mode program. Use it if you don't have X windows running, or if you're connected from a remote location.
make xconfig
A Graphical program. Use this one when you can.

* There is yet another, which will be shown later...

Tips Regarding Configuring The Kernel

* Each item has a help section - read it.
* Each help text contains a suggestion of what to do if you're not sure. Use these suggestions, indeed.
* The first time around, take a tour around the different options, without changing them.
* The configuration process generates a file called ".config" in the top directory of the kernel sources. Keep a backup before making changes.
* Don't configure a kernel when you don't have enough free time - it's a long task (1-2 hours) the first time around.
* Do not despair - eventually, you'll configure kernels in 5 minutes

Compiling The Kernel

* Once configured, Compiling the kernel is easy.
* First, make sure we start afresh (takes a few seconds):

make clean

* Then, prepare the dependencies list (might take a minute):

make depend

Compiling The Kernel (Cont.)

* Then, compile the kernel's main part (might take 5-30 minutes):

make bzImage

After this step, we should have the following new file:

[root@simey linux]# ls -l arch/i386/boot/bzImage
-rw-r--r-- 1 root root 1064017 Jan 16 01:53 arch/i386/boot/bzImage

* Then, compile the kernel modules (might take 5-30 minutes):

make modules

Compilation Errors

* A normal compilation process might result several warnings.
* But errors should not happen, unless you're compiling a non-stable kernel.
* Make sure you started from a fresh compilation (i.e. ran 'make clean').
* Make sure that you have read/write access to the source tree (i.e. if the sources belong to 'root', compile them as user 'root').

Installing The New Kernel

* Installing the kernel is split into two parts:
1. First, installing the kernel itself.
2. Then, installing the kernel modules.
* Before we install the kernel, we want to make sure we do not overrun our current kernel, or a previously existing kernel.
* So we will install the kernel itself manually.
* Avoiding overrunning the kernel modules is more difficult, since the location of the modules is hard-coded into the kernel (its version number) and the module loading tools.

Installing The Kernel's Main File

* Runnable kernels are expected to be in the /boot directory.
* Simple way to install the kernel (assuming it is version 2.4.20-8):

cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.20-8

* Make sure the name is unique, and especially different then the current kernel...
* ... cause if we got a broken kernel, we will want to be able to switch back to the current kernel.

Installing The Kernel Modules

* The kernel modules will normally be placed in /lib/modules/<version>
* If the compiled kernel is of the same version as an existing kernel, we better first back-up the modules library:

cp -rp /lib/modules/2.4.20-8 /lib/modules/2.4.20-8.old

* This assumes that the older kernel can boot into a working system without working loadable modules...
* ... or that we can boot from a rescue CD/floppy to restore the modules.
* And now install the modules:

make modules_install

The "initrd" (Init Ram-Disk) File

* Sometimes, we need to pack modules that are needed before the kernel can access the disk partitions, into the 'initrd' file.
* To do this, we need to use the 'mkinitrd' command:

mkinitrd /boot/initrd-2.4.20-8.img 2.4.20-8

This creates an initrd file named '/boot/initrd-2.4.20-8.img', containing hard-disk and file-system related modules, for kernel version 2.4.20-8.
* The initrd command uses the modules installed under /lib/modules/, so it must be executed after make modules_install.

Updating The Boot Loader

* Once we installed the new kernel and its new modules, we need to tell the boot loader about it.
* Generally, we need to supply the following information:
o Kernel image file path (e.g. /boot/vmlinuz-2.4.20-8).
o Partition of the root directory - copy it from the spec of the current kernel.
o Kernel parameters - may be copied from the current kernel, if it has not changed drastically.
o Optional initrd file path.
o Label.

Instructions For "lilo"

* If your system uses "lilo" as the boot loader, the config file is normally at /etc/lilo.conf
* A normal entry for our example kernel would look like this:

image = /boot/vmlinuz-2.4.20-8
label = rh9-mykernel

* the 'root' entry may be omitted, if we have 'root=current' in the global section.
* If we do not need initrd, the initrd entry may be omitted.

Instructions For "lilo" (Cont.)

* Finally, run "lilo" to make the actual update of the boot loader:

[root@simey ~]# lilo
Added linux-2.4.18
Added rh9-mykernel
Added dos

MANY people forget this step!

Instructions For "grub"

* For systems with "grub" as their boot loader, the config file is normally at /boot/grub/grub.conf
* An entry for our example kernel would look like this:

title Red Hat Linux (2.4.20-8)
root (hd0,0)
kernel /boot/vmlinuz-2.4.20-8 ro root=/dev/hda1 hdc=ide-scsi
initrd /boot/initrd-2.4.20-8.img

* The disks and partitions are numbered by bus numbers, rather then by letters: hd0,0 means /dev/hda1.
* If we have /boot on its own partitions, the path names should NOT contain /boot, and the "root" entry should point to the /boot partition.
* No need to run anything after updating the config file - grub will read it during system boot.

Booting The New Kernel

* Once everything is set, reboot your machine.
* At the boot loader's prompt/menu, chose the new kernel.
* Watch the boot messages - are they similar to what you are familiar with? Are there any errors or failures?
* If boot fails - reboot again with the previous (working) kernel.
* If boot succeeds, check that everything works (including networking, sound card, modem...).

Troubleshooting The Boot Process

* The boot process logs all its messages into /var/log/messages
* Possibly also in /var/log/dmesg
* Look in those files for error messages, and try to analyze them or look them up on the Internet.
* Sometimes you'll notice a problem resulting from kernel configuration - reconfigure, recompile from scratch (make clean...), re-install and try again.
* If you see that all modules fail to load with unresolved symbols, make sure you compiled and installed the modules.

Boot Problems - No Root Device

* Symptom: you get the message that no root device was found.
* Reboot to the previous kernel.
* Check the exact syntax of your lilo/grub entry for the new kernel. Are you sure you specified the root device entry properly?
* Make sure you compiled the drivers for your hard-disk and the partitions into the kernel image, or you have them in the initrd image.

Boot Problems - "lilo" says "LI"

* Symptom: you get the message "LI" (or a similar message) and then nothing, or an endless loop of garbage.
* Reboot to the previous kernel.
* Check the syntax of the lilo entry for the kernel - something there is terribly wrong.
* If you can't see what is wrong, delete the entry, and create it again. Often mistakes done in the first copy+paste do not occur in the second attempt.

When Installing A Newer Kernel...

* Check the file 'Documentation/Changes' in the source directory, for packages that might need upgrading before booting the new kernel.
* Don't configure the new kernel from scratch - copy your previous kernel's '.config' file to the new kernel's source directory, and run make oldconfig - you will only need to answer questions about new features.
* If you used a distribution's kernel previously, it normally has a config file matching the installed kernel.
* On RedHat, this file is usually under /boot/config-<version>

External Device Drivers

* Various types of hardware might have drivers available not as part of the kernel sources.
* Perhaps this is a new driver, that didn't yet get accepted into the normal kernel.
* Or the driver is maintained by the manufacturer of the hardware...
* ... and possibly delivered in binary-only mode?
* We need to be able to install such drivers on our own, then.

External Device Drivers Formats

* An external device driver might come with full sources, that we need to compile. This is the best scenario.
* An external device driver might come as a binary-only module. In this case we need to get a driver that was compiled specifically for the kernel version we are using.
* If we use a less-commonly-used distribution, we might not find a driver for our distribution's kernel...
* At which time we either dumb the hardware, or take the best "vanilla" kernel for which there is a binary driver available.
* The driver could come as a hybrid - half source, and half binary. the Source-part need to be compiled against our kernel, and it'll make sure the binary part works.

Notes On External Device Drivers Compilation

* You need to have your kernel source tree configured properly, matching your running kernel.
* You don't have to actually compile the kernel source tree in this case.
* Sometimes the driver has a script that will compile the driver for you, hiding the actual compilation process.
* If it thinks your kernel sources are under /lib/modules/2.4.20-8/build, this is ok - this should be a symbolic link pointing to the right location of the sources....
* ... But it does not hurt to make sure.
* Otherwise, read the driver's installation instructions, and follow them carefully.

Originally written by Valid HTML 4.01!guy keren

Muhammad Muzzamil Luqman
Old 03-03-2005, 11:02 AM   #8
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
One quick tip: you could've pointed me to that tutorial through a link instead of reproducing it here.
I have no experience with the rpm system but it looks like you got the kernel sources not with rpm but elsehow. That's why it doesn't show up in the installed packages list. I specified in one of my previous posts that grabbing the kernel as pristine sources, compiling and installing them as described in the text you pasted in will not result in a package type installation. This is a "raw" source installation and has nothing to do with package managers.
Please tell me once again where exactly did you get the kernel sources.
And you should consider getting a newer kernel as 2.6.11 has just been released (2nd of March 2005...actually March 1st 23:59 hours if we look at the file's date at ) and the 2.4 series are quite old (I think more than 2 years).
Old 03-03-2005, 11:56 AM   #9
Senior Member
Registered: Mar 2004
Location: Munich
Distribution: SuSE, Ubuntu
Posts: 3,513

Rep: Reputation: 58
This effect (that the newly compiled kernel does not appear in the rpm database) is actually quite nice: it enables you to have more than one kernel installed in parallel. In SUSE for example you need to delete the old kernel entry from the rpm database, so that the new kernel does not overwrite it.

And I would like to repeat harken's hint: you should have posted a link! I have just read the same long post in the Kernel compilation thread.
Old 03-04-2005, 02:38 AM   #10
Registered: Feb 2005
Posts: 43

Original Poster
Rep: Reputation: 15

I will take care in future but harken i guess, such minor mistakes are always expected from newbies.

The thing is that i have plans to instal the 2.6.x but just as the first step to learn the kernel compilation i tried with the 2.4.x.

I got the source from the, because a friend of mine told me that this is the most authenticated source for kenels.
Old 03-04-2005, 03:42 AM   #11
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
Well then, your mistery is solved. Like I told you before ans like abisko00 said as well, installing programs from source isn't equivalent with installing a package (an rpm in your situation). That's why it won't show up when grepping for kernel in the package list.
I will take care in future but harken i guess, such minor mistakes are always expected from newbies.
Don't worry for that, that's how we all learnt our lessons, doing mistakes

And while you succedeed in compiling the 2.4 kernel, go grab the 2.6.11, it's just been released.
Old 03-04-2005, 04:07 AM   #12
Registered: Feb 2005
Posts: 43

Original Poster
Rep: Reputation: 15
One more thing harken.

On a different machine i have got 2.4.25-040218. I have been told that the kernel-source-2.4.25 would work with that kernel because the -040128 is the date on which kernel was compiled. is this right?

And how can i change this date to tadays date or with my name
Old 03-04-2005, 04:21 AM   #13
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
On a different machine i have got 2.4.25-040218. I have been told that the kernel-source-2.4.25 would work with that kernel because the -040128 is the date on which kernel was compiled.
This is a bit confusing to me. You have the kernel that ends with 040218 already installed? If the kernel-source-2.4.25 will work it? Work in what way? If will it compile succesfully? That depends on the compiler rather than the kernel.

As for changing the name, first change the name of the vmlinuz file (bzImage, or whatever it's called; the kernel itself) found in /boot to what you like (vmlinuz-2.6.11-luqman_rules for example) then edit lilo.conf or menu.lst, depending on what bootloader you use and change accordingly the line containing the kernel's location to
"kernel /boot/vmlinuz-2.6.11-luqman_rules".
That should do the trick.
Old 03-04-2005, 05:13 AM   #14
Registered: Feb 2005
Posts: 43

Original Poster
Rep: Reputation: 15
noops it didn't work

uname -r
still showing the old information.


and the second thing, sorry, my mistake i was not clear in my query. I meant to ask that the rpm kernel-source.2.4.25, will it work with my kernel which is 2.4.25-040218. Because as i said earlier that i have been told that this last part in the kernel version [which i get with uname -r] is the compilation date and it has nothing to do with the kernel version.
Old 03-04-2005, 05:59 AM   #15
Registered: Jan 2005
Location: Between the chair and the desk
Distribution: Debian Sarge, kernel 2.6.13
Posts: 666

Rep: Reputation: 30
uname -r
still showing the old information.
Now I see what you mean. I thought you want only the boot option to show a custom name for the kernel, that's why I told you about renaming the file.
That has to do with the compiling stage of your kernel. If I'm right (I don't have the documentation next to me right now), you must specify an alternate compile output directory using the "O=" (that's the letter O, not zero) switch as in "make O=/lib/modules/2.6.11-luqmans-kernel". This requires as far as I remember, using the "O=" switch for all the 'make' operations.
Try this one and you could also take a look at the documentation that comes along with the sources just to make sure.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel compilation : to remove a kernel which files should be deleted b0nd Linux - Newbie 2 08-17-2005 11:35 AM
Kernel compilation problems, distorted video and kernel panic shamrock_uk Linux - Laptop and Netbook 5 08-12-2005 10:53 PM
apt-get kernel-source is installing the wrong kernel source. JordanH Ubuntu 10 07-08-2005 05:42 PM
urpmi installs wrong kernel-source edgjerp Mandriva 4 02-14-2005 03:40 PM
aic79xx kernel panic on installtion rh 7.2 marl Linux - General 0 08-01-2003 07:36 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:40 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration