Article Title: how to compile a kernel-Fedora method. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Version: 1.0
Author: Falko Timme [ At]Falkotimme[Dot]Com>
Translation: Ken Zhao
Original article: http://www.howtoforge.com/kernel_compilation_fedora
English: http://blog.zhaoke.com/5.html
Last Updated: 11/10/2006
Last Chinese updated: 11/16/2006
Each Linux release has its own dedicated tool to build a custom kernel. this article describes how to compile the kernel on the Fedora platform, and how to obtain the latest and unmodified kernel source code from www.kernel.org (also called vanilla kernel) to build a custom kernel, in this way, you can use your own kernel instead of the kernel of the release version, and also introduce how to patch the kernel to facilitate the addition of new features.
I have tested the following work on Fedora Core 6.
The first thing I want to talk about is that the way to build a custom kernel in the article is not the only one. There are many other ways, but this is just a method I used. I cannot guarantee that no problems will occur after use.
1. preparations
This article describes how to build a custom kernel on the Fedora platform. the first method is the Fedora method. Finally, you can obtain a kernel rpm Package, which can be easily shared with others. the second method is the traditional method. it applies to all linux releases, but you won't have an rpm package.
We recommend that you use the root user to perform all the following steps. however, you may also need to use a non-super user (such as user tom) to run some commands, so you may use the mongodo editor to add the following line to the/etc/sudoers file:
Tom ALL = (ALL) ALL
At any time, you need to run the command with the root permission, for example:
Yum install fedora-rpmdevtools unidef
You can use the following command instead:
Sudo yum install fedora-rpmdevtools unidef
Remember: If you run all commands as the root user, you can completely forget sudo. how to use it, depending on your habits.
2. build an rpm kernel package
This section describes how to build the kernel and finally you can get an rpm Package to facilitate installation or sharing with others.
2.1 Create your rpmbuild directory.
Create your rpmbuild directory as follows:
Cd ~
Cp-a/usr/src/redhat/rpmbuild
Echo '% _ topdir % (echo $ HOME)/rpmbuild'>. rpmmacros
Then install the application software package required to build the rpm Package
Yum install fedora-rpmdevtools unidef
Then run
Fedora-buildrpmtree
2.2 download and install the src. rpm Package of the Fedora kernel
Next, download the latest kernel src for our Fedora version. rpm package. for Fedora Core 6, you can obtain src from the following URL. rpm Package: http://download.fedora.redhat.com/pub/fedora/linux/core/6/source/SRPMS/, for Fedora Core 5, you can get src from the URL below. rpm Package: http://download.fedora.redhat.com/pub/fedora/linux/core/5/source/SRPMS/, etc.
The latest src Ora Core 6 kernel src. rpm Package is kernel-2.6.18-1.2798.fc6.src.rpm, so now we download and install it:
Cd/usr/src
Wget http://download.fedora.redhat.com/pub/fedora/linux/core/6/source/SRPMS/kernel-2.6.18-1.2798.fc6.src.rpm
Rpm-ivh kernel-2.6.18-1.2798.fc6.src.rpm
If you see these warnings:
Warning: user brewbuilder does not exist-using root
Warning: group brewbuilder does not exist-using root
You can ignore them.
We have successfully installed the latest 2.6.18.1 kernel source code package. if we continue to build the kernel source code package, our kernel version will be 2.6.18.1.
2.3 patch the kernel
I want to install the new kernel 2.6.18.2 to replace 2.6.18.1. the src. rpm package that has been installed in the system is 2.6.18.1 that has been patched for 2.6.18. now we will use the patching method to upgrade the kernel to 2.6.18.2.
Cd ~ /Rpmbuild/SOURCES/
Wget http://www.kernel.org/pub/linux/kernel/v2.6/patch-2.6.18.2.bz2
If you want the kernel name to end with 2.6.19-rc5, you can also use the prepatch package http://www.kernel.org/pub/linux/kernel/v2.6/testing/patch-2.6.19-rc5.bz2. note that this operation is only valid for prepaches. for example. the kernel patch is only valid for the final kernel version, for example, 2.6.19 kernel. you can patch 2.6.18 kernel source code, but not 2.6.18.1 or 2.6.18.2. this rule is noted in the following web page: http://kernel.org/patchtypes/pre.html
Prepatches is equivalent to the test release in linux; they are located in the archive test directory, and we can patch the previous full release (version number in three parts) using patch (1) tool (for example, 2.6.13-rc4 prepatch can only patch 2.6.11 kernel source code, rather than 2.6.11.10 .)
Now we have to modify the kernel-2.6.spec file to let it know that we are using the new kernel patch:
Cd ~ /Rpmbuild/SPECS/
Vi kernel-2.6.spec
Search for the following line
Pattern: patch-2.6.18.1.bz2
Replace with the following content:
Pattern: patch-2.6.18.2.bz2
(Or another version you have downloaded)
Then run
Rpmbuild-bp kernel-2.6.spec
(If you want to build kernels for other platforms such as i386, i586, i686, or x86_64, run the following command:
Rpmbuild-bp -- target = i686 kernel-2.6.spec
I didn't specify i386 in the above example. your system may be of another platform type. please remember to enter your platform type .)
Now we are going to the key part. src. rpm has a lot of specialized fedora patches, some of which cannot work well with our 2.6.18.2 patch, so if you see the following in the rpmbuild output:
+ Echo 'Patch #300 (linux-2.6-ppc-dac960-ipr-clash.patch ):'
Patch #300 (linux-2.6-ppc-dac960-ipr-clash.patch ):
+ Patch-p1-s
Reversed (or previusly applied) patch detected! Assume-R? [N]
Apply anyway? [N]
1 out of 1 hunk ignored -- saving rejects to file drivers/block/DAC960.c. rej
Error: Bad exit status from/var/tmp/rpm-tmp.46287 (% prep)
RPM build errors:
Bad exit status from/var/tmp/rpm-tmp.46287 (% prep)
At this time you have to edit the kernel-2.6.spec file again, annotate the patch #300 line:
Vi kernel-2.6.spec
[...]
# Patch300: linux-2.6-ppc-dac960-ipr-clash.patch
[...]
# % Patch300-p1
[...]
Then run the rpmbuild command, for example:
Rpmbuild-bp kernel-2.6.spec
Note:: You must repeat the process until no errors occur.
[1] [2] [3] [4] [5] Next page