Fedora Kernel Building Information

Current Version at time of writing: Fedora 12

New Info:

http://fedoraproject.org/wiki/Building_a_custom_kernel (info for fedora > 8)


Old Info:

http://www.mjmwired.net/

http://www.mjmwired.net/resources/mjm-fedora-fc5.html#kernelsrc

     the above links shows how to download the fedora kernel source

http://www.howtoforge.com/kernel_compilation_fedora

     the above link explains how to build a fedora rpm kernel

http://fedoraproject.org/wiki/Docs/CustomKernel

Fedora is using a system frequency of 1000Hz now, which sometimes causes problems when the Fedora server is being run as a virtual server (the client system). The clock gets all out of whack.

I've been able to compile a custom kernel with a frequency of 100Hz to solve this problem. 1)

Preparation

Download Kernel Source

Obtaining Kernel Source through 'yum'

There are yum utilities which will download the LATEST kernel source.

You only have to install yum-utils once:

[root@maltsweb kernel-source]# yum install yum-utils

Download the new kernel source:

[root@maltsweb kernel-source]# yumdownloader --source kernel --enablerepo core-source --enablerepo updates-source

Install the Kernel Source

Install the SRC.RPM file and Prepare source

Install the kernel.src.rpm that you chose to install in the previous steps.

Install:

[root@maltsweb kernel-source]# rpm -Uvh kernel-2.6.15-1.1955_FC5.src.rpm
   1:kernel                 ########################################### [100%]

Prep the Source

Install any dependencies that our kernel build might have:

# yum-builddep kernel

Set it up:

First we need to “brand” our custom kernel:

[root@maltsweb kernel-source]# vi /usr/src/redhat/SPECS/kernel-2.6.spec

And change:

- #% define dist .XX
+ %define dist .www

Make sure you remove the space after the %

And finally run:

[root@maltsweb kernel-source]# rpmbuild -bp --target=$(uname -m)  /usr/src/redhat/SPECS/kernel-2.6.spec

rpmbuild: -bp = build prep (it extracts and patches the kernel, preparing it for building, but does NOT build the kernel)

Customize your kernel

This is when you prepare patches, new configs, etc.

Configure the Kernel

cd SOURCES/*
make menuconfig

Build the Kernel RPM

Build the RPM:

# cd SPECS/
# rpmbuild -bb --target=$(uname -m) --with firmware --without debug --without debuginfo --without devel kernel.spec

Install the RPM:

cd RPMS/i386
rpm -ivh kernel-2.6.20www1.2316-2.i386.rpm

Old Notes

mkinitrd

mkinitrd /boot/initrd-2.6.20-www1.2316-2.img 2.6.20-www1.2316

Edit grub

vi /boot/grub/menu.lst
#title Fedora Core (2.6.20-1.2316.fc5smp)
#       root (hd0,0)
#       kernel /vmlinuz-2.6.20-1.2316.fc5smp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
#       initrd /initrd-2.6.20-1.2316.fc5smp.img

title Fedora Core (2.6.20-www1.2316)
        root (hd0,0)
        kernel /vmlinuz-2.6.20-www1.2316 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.20-www1.2316-2.img

Removing old Kernels

Reboot using the new kernel (and leave the old one installed just incase).

Run the following to verify that the new kernel is loaded:

[john@maltsweb ~]$ uname -r
2.6.20-www1.2316


Now, view the currently installed kernels:

[root@maltsweb john]# rpm -q kernel
kernel-2.6.20www1-1
kernel-2.6.20www1.2316-2

select the kernel you wish to remove (kernel-2.6.20www1-1 in this case, since the other kernel looks similar to the currently running kernel) and remove it:

[root@maltsweb john]# rpm -e --nodeps kernel-2.6.20www1-1
[root@maltsweb john]#

Removing old source files/making space for the build

You should probably remove the source of your previous kernel build prior to building the new kernel.

[root@maltsweb ~]# cd /usr/src/redhat/BUILD/
[root@maltsweb BUILD]# ls
kernel-2.6.20  kernel-2.6.20www1.2316
[root@maltsweb BUILD]# ls -l
total 16
drwxr-xr-x  5 root root 4096 May 15 18:33 kernel-2.6.20
drwxr-xr-x 21 root root 4096 May 15 18:25 kernel-2.6.20www1.2316
[root@maltsweb BUILD]# uname -r
2.6.20-www1.2316
[root@maltsweb BUILD]#

The above shows that I currently have the kernel-2.6.20 source code, and a custom build for kernel-2.6.20www1.2316, which matches the currently running kernel. So when I upgrade my kernel, before I start I can remove the custom kernel directory:

[root@maltsweb BUILD]# rm -Rf kernel-2.6.20www1.2316/
[root@maltsweb BUILD]#

This should clear up enough space to build a new kernel.

linux/server/fedora_kernel.txt · Last modified: 2010/03/10 21:37 by john
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki