PDA

View Full Version : Compiling a kernel using RPM - Ilja How To


ewdi
29th November 2004, 08:41 PM
Just re-posting for ilja

Have you ever thought about compiling your Linux kernel and was afraid of the many commands that are to be typed ? Have you ever wanted to install your kernel just with rpm -ihv and to delete it with a rpm -e ?
I will show you, how you can make it in just a few steps.

1. Downloading the Kernel
go to http://www.kernel.org/ and see which kernel is the recent one. When I write this tutorial it is the Kernel 2.6.7. Then go to the the mirror-page (http://www.kernel.org/mirrors/) and choose a mirror near you. You can use the master-server, but it is mostly faster than the master server and also saves some traffic for kernel.org. There you need /pub/linux/ . Here you need kernel/ and the kernel version you want to download (so for me v2.6/). In the directory you can find a lot of different files, you need the one with the recent kernel number and .bz2. (You remember, I use 2.6.7). Download it to any location on you harddisk, where you can find it (e.g. you /~ directory.)
2.Unpacking the file.
unpack the file there are different possibilities and even a gui avalible, but this should work :

tar -xjvf <filename>.tar.bz2

go to the directory you unpacked it to.
3.Preparing the Kernel
make sure you have no stale .o files and dependencies lying around(2):

make mrproper

4.Configuring the Kernel
Now you have to configure you kernel. You can do it with a text-based assistent

make config

with an ANSI-menu (needs ncurses)

make menuconfig

with a X11-GUI (needs. QT ) (If you have problems with fonts follow this intstructions (http://www.webservertalk.com/message194869.html) thx @pigpen )

make xconfig

or X11-GUI based on GTK (needs GTK)

make gconfig

Here you can choose the options you want, please make sure, that the filesystem of you root partition is compiled and not just installed as a module ! It's mostly ext3, ext2 or reiserfs. You will need it later.
Take a lot of time for this step and make it carefully.
type

pwd

to show the directory you are at the moment.
5.Creating a RPM
So now comes the step, where you need to become root

su -

now change to the directory, where you were (remember the pwd, you made in the previous step)
Now type

make help | grep rpm

The output should be something like :

rpm - Build a kernel as an RPM package

If the output contains rpm , then type

make rpm

if the output contains rpm-pkg or rpm and rpm-pkg, then type

make rpm-pkg

look that it started and now you can go and have a cup of tea, because it can take several hours.

When it is ready it returns you something like:
Wrote: /usr/src/redhat/SRPMS/kernel-2.6.7-2.src.rpm
Wrote: /usr/src/redhat/RPMS/i386/kernel-2.6.7-2.i386.rpm

6.Installing the kernel
Install the kernel ( the second of the files above). Please use the option -i and not -U, or else the older kernel will be erased.

rpm -ihv /usr/src/redhat/RPMS/i386/kernel-2.6.7-2.i386.rpm


7. Configuring GRUB
new-kernel-pkg --mkinitrd --depmod --install <kernelnumber>
can be used to configure Grub
8.Final step
reboot your system and choose the new kernel in the grub menu.

This tutorial is based on linuxwiki.de (http://linuxwiki.de/LinuxKernel#head-93c15f8b759a9c8d3b88e3b214f0d158da53510d) and is inspired by this message (http://www.redhat.com/archives/fedora-de-list/2004-June/msg00168.html)
Please if you find any errors (content and especially language) report it to me.

]
(2) (http://www.de.kernel.org/pub/linux/kernel/)
(3) (http://www.linuxquestions.org/questions/showthread.php?s=&threadid=192459)

Thank you mhelios for your great advices.

ilja
29th November 2004, 08:41 PM
thanks ewdi :)

arpi
29th November 2004, 11:15 PM

to show the directory you are at the moment.

if you want to su root and stay in the same directory try this:

su -m

daywalker
30th November 2004, 05:08 AM
hi just wanna highlight the problem im having. i followed the instuctions given here but the last one "new-kernel-pkg --mkinitrd --depmod --install <kernelnumber>" what it means? iis it a command to be issued? well if it is i issued but it says "bash: new-kernel-pkg: command not found"! any idea where i go wrong and btw after installing the rpm and selecting the new kernel, the boot process stops at "Uncompressing Linux... OK, booting the kernel." nothing happens after that.

i hope someone could shed some light on this.

thnx

ghaefb
30th November 2004, 10:03 AM
if you want to su root and stay in the same directory try this:

su -m
Ok didn't know that, very useful info.
Thanks.

ilja
30th November 2004, 02:42 PM
hi just wanna highlight the problem im having. i followed the instuctions given here but the last one "new-kernel-pkg --mkinitrd --depmod --install <kernelnumber>" what it means? iis it a command to be issued? well if it is i issued but it says "bash: new-kernel-pkg: command not found"! any idea where i go wrong and btw after installing the rpm and selecting the new kernel, the boot process stops at "Uncompressing Linux... OK, booting the kernel." nothing happens after that.

i hope someone could shed some light on this.

thnx


strange :
I have this application:

[root@josephine ~]# whereis new-kernel-pkg
new-kernel-pkg: /sbin/new-kernel-pkg

Have you logged in as root? with su -?

daywalker
30th November 2004, 03:13 PM
well now i know where the new-kernel-pkg is found it. but i still could not sucessfully boot the kernel. it stalls at "Uncompressing Linux... OK, booting the kernel.".

btw my boot partition is ext3 and my root is reiserfs could this be an issue?
or do i need to enable audit during making choices?

pls help

thnx

ilja
30th November 2004, 03:20 PM
Have you compiled Reiserfs as Module or hard into the kernel? I would compile it into the kernel, because that might be the issue.

daywalker
30th November 2004, 03:23 PM
ok. i compiled the file system into the kernel not as a module, but i also made the initrd img for it but couldn't boot the new kernel.

let me know if i may be missing some features in the kernel that i did not include.

thnx.