Install Kernel Source

31 October 2006

Installing the kernel source is typically NOT needed unless you wish to re-compile your kernel or for some special development. However in some cases the kernel headers may be required.
There are 3 basic steps involved in installing the kernel source.
  1. Download the desired kernel source (matching your current kernel if required)
  2. Installing the SRC.RPM package
  3. Using rpmbuild to prepare the source into a usable state
NOTE: Following these steps will consume at least ~500MB of disk space!
1. Download the Kernel Source
Obtaining Kernel Source (for default FC6 kernel)
The default kernel source can be found through any Fedora mirror. Look in the directory “/SRPMS/” under the “/6/” directory . For example: http://download.fedora.redhat.com/pub/fedora/linux/core/6/source/SRPMS/.
kernel-2.6.18-1.2798.fc6.src.rpm 16-Oct-2006 22:26 44M
Obtaining Kernel Source (for updated FC6 kernel)
If you updated your kernel, then the typically the last 2 or 3 releases of the source of the kernel will be available though the Fedora updates. IF YOU REQUIRE you can (try to) match the kernel source with your running kernel.
Look in the update directory on most Fedora mirror sites. For example: http://download.fedora.redhat.com/pub/fedora/linux/core/updates/6/SRPMS/.
Obtaining Kernel Source through ‘yum’ (for latest FC6 kernel)
There are yum utilities which will download the LATEST kernel source. If it does not find anything, then there are no updates (yet) use the DEFAULT Fedora kernel source.
[mirandam@charon ~]$ sudo yum install yum-utils
[mirandam@charon ~]$ cd downloads
[mirandam@charon downloads]$ yumdownloader --source kernel --enablerepo updates-source
2. Install the Kernel Source
Install the kernel.src.rpm that you chose to download in the previous steps.
[mirandam@charon downloads]$ sudo rpm -ivh kernel-2.6.18-1.2798.fc6.src.rpm
   1:kernel                 ########################################### [100%]
Ignore, group does not exist or user does not exist errors.
3. Prepare the Source
[mirandam@charon downloads]$ sudo rpmbuild -bp --target=$(uname -m) /usr/src/redhat/SPECS/kernel-2.6.spec
The source files will be properly located in /usr/src/redhat/BUILD/kernel-2.6.18/. There are 2 useful directories:
  1. linux-2.6.18.ARCH/
    This will have the standard kernel.org kernel WITH Fedora patches and updates. The ARCH architecture will match the output of uname -m, usually i686. You may use noarch for the target= option if you wish.
  2. vanilla/
    This will have the standard kernel.org kernel ONLY (no patches or updates).
NOTE: Users of x86_64 architecture may experience the following error:
error: Failed build dependencies:
       unifdef is needed by kernel-2.6.18-1.2798.x86_64
To fix, run sudo yum install unifdef.

0 Response to "Install Kernel Source"

Posting Komentar