Finding Kernel-HOWTO

James McDermott jmcdermo at redhat.com
Wed Dec 10 22:08:39 UTC 2003


Heres an old one Tish wrote, hope it helps.
--J

On Wed, 2003-12-10 at 17:03, leam wrote:
> All the kernel howto's I've seen referenced on the web are "down for 
> review". I understand the push for updating for 2.6, but what about 
> those of us who'd like one now? Is compiling going to be that different?
> 
> ciao!
> 
> leam
> 
> 
> --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
-------------- next part --------------
NEWBIE CRONICLES                               Tish 'TwItcH' McDermott
Vol 1      12.2000

Kernel Compile

First I want to pass on a deep seated hatred for AbiWord. Thank you.

The following is step by step of compiling the stock kernel, for version 
7.

To begin you will need to log in as root, do not go to the GUI, stay in 
command line. If your system logs you into GUI then you will need to get 
to a virtual terminal for the compile. This can be done by hitting Ctrl + 
Alt + F2. From the prompt log in as root and you can begin.  

To compile a kernel you will need to have the following 10 rpm's loaded.
kernel-headers
kernel-source
dev86
make
glibc-devel
kgcc
cpp
ncurses-devel
binutils
gcc-2

To verify if the rpm's have been loaded you can query them with the -q 
switch. 
Ex. [root at localhost root]$ rpm -q kernel-headers

When executed it will show you the version that is installed or tell you 
that it is not installed.  If it is not installed you will have to find 
them on the installer cd's in the RedHat RPMS directory. A complete 
listing of what is on each cd can be found at:

http://www.gudanglinux.or.id/data/datadata/rh70gpl_2.txt
http://www.gudanglinux.or.id/data/datadata/rh70gpl_1.txt

**If you are unsure how to install an RPM, please see the RPM How-To**

Once all of your RPM's have been verified you can begin.

>From your root prompt, you will need to cd into /usr/src/linux. (all steps 
will be done from this directory unless otherwise specified)  Once 
there, type ls . This will show you all the files. You now need to 
modify your Makefile, so you can point to your new kernel. Using your 
favorite text editor,(examples will be given while using pico) edit as 
follows the Makefile.  

At the prompt type  pico Makefile. There you will see the VERSION 
PATCHLEVEL   SUBLEVEL    EXTRAVERSION. You will need to edit the 
EXTRAVERSION to reflect the kernel you are building.  We will use 'test' 
for the examples.

EX. EXTRAVERSION = -22test

Also I would recommend using kgcc. For this down arrow in the file to 
HOSTCC = gcc and change it to refelct kgcc. Once these steps are done, you 
will want to write the file and save changes. To do this, hit Ctrl x
y  (for yes) enter

Now at the prompt you want to copy the kernel file into the default 
kernel config file. To do this, at root type (exactly as below)

cp -p configs/kernel-*-i686.config arch/i386/defconfig

This will take your kernel configs and move them all to the defconfig 
file, so when you do the next step you won't completely clean everything 
out. It is like doing a back up.


Now you start the make process. At the prompt type:
      make mrproper

This command will clean out all old compilations, dependencies, core files 
and so on. Making ready for the new kernel.

 
      make oldconfig

This keeps safe your old configuration.

Now it is time to choose what tool you will use to customize your kernel.  
Each of the listed tools will allow you to build in or modulize options.  
Some options will only allow to be built it, you cannot make a module out 
of it. One of the reasons for building it into the kernel is for speed, 
but at the same time, if all of your options are built in, the you have a 
kernel that is bogged down with processes it doesn't need to be running. 
For example there is an option for Amature Radio. If this is built into 
the kernel, but you never use it, you are wasting space in the kernel, and 
the kernel is wasting energy trying to keep the process up and running. At 
this point you could make it a module, incase you would ever want to use 
that option, then you would have the module loaded. Then again, if you are 
never going to use that option, remove it from the kernel.  

***WARNING***WARNING***WARNING***WARNING***WARNING***WARNING***WARNING***
Be well versed in your kernel options, what they do, what they 
need,(dependencies)to work properly,or if you need the options or not. 
Don't just go in and remove things randomly trying to streamline your kernel.
YOU WILL REGRET IT!!!!!
     
(The kernel options can be found in the appendix)

Now that you have made your changes to the kernel, it is time to write 
them as an image. Writing them as an image will then allow you to point to 
the kernel you wish to load.

In this step, you are also making the depencies. So now you will want to 

type   make dep bzImage    

This can take a bit of time. You may see a few 'warnings' these are not to 
be alarmed about. If you do see any at the end of the file, as it is exiting,
make note of it. This will reflect how you have built your kernel, and where
the errors lie. You may have left out something that the kernel has to have, 
and it will not build until it can be found.

Now that you have built the image, you will want to build in the modules. 

type     make modules

This will create the modules you added to your kernel. This step normally 
takes the longest, as it goes in and out of all the packages and creates 
the modules. 

After this is done, you will need to copy the bzImage and the System.map 
into /boot. It is not the kernels job to find the correct System.map. It 
is up the boot scripts or programs that use the map to reset any symlinks
or use the kernel version to select the right map.

cp -p arch/i386/boot/bzImage /boot/vmlinuz-2.2.16-22test  (the example)
cp -p System.map /boot/System.map-2.2.16-22test

Now that you have moved the kernel to it's new home, you want to install 
the modules you have made.

type    make modules_install

Next make the initial ramdisk image

type    mkinitrd /boot/initrd-2.2.16-22test.img 2.2.16-22test

Making this gives you the image file you will need, if for some reason you 
will need to make a boot disk or if you need to rescue the OS.

It is time to change directories to edit your lilo.conf file.

type   cd    (this will take you directly back to root)

type   pico /etc/lilo.conf

Now you need to put the stanza in /etc/lilo.conf that will reflect the 
kernel you will want to use. You don't want to erase the Image stanza that 
is already there, incase something happens to the new kernel, you will 
have one to fall back on.

Basically you will copy exactly what is in the image stanza of lilo.conf 
so you have two kernel images listed. The second image, which you create, 
will have the label changed to match what you named your kernel. Next you 
will want to make the default in the boot stanza reflect the new kernel, by 
changing it from linux to test. When you edit /etc/lilo.conf it will first 
look something like this:

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=linux
 
image=/boot/vmlinuz-2.2.16-22.img
        label=linux
        initrd=/boot/initrd-2.2.16-22.img
        read-only
        root=/dev/hda1
                                                        

After you have made your changes, it will look like the example below.


boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
linear
default=test
 
image=/boot/vmlinuz-2.2.16-22.img
        label=linux
        initrd=/boot/initrd-2.2.16-22.img
        read-only
        root=/dev/hda1
                         

image=/boot/vmlinuz-2.2.16-22test.img
       label=linux
       initrd=/boot/initrd-2.2.16-22test.img
       read-only
       root=/dev/hda1	

Now that you have made the changes to the lilo.conf file, you will need to 
write the changes by typing Ctrl x    y    and enter.

This will drop you right back to your root prompt

Then you will need rerun lilo by typing at your root prompt 

    lilo -v -v

Reboot your system.  Now is the time of truth, because I know you are 
itching to see that brand spankin new kernel loaded. Above the log in 
prompt will show you the version of the kernel you are running. It should 
be 2.2.16-22test

Congratualtions you have just compiled your kernel!!!!!





More information about the fedora-list mailing list