CentOS Kernel setup

From Bashlinux
Jump to: navigation, search

How to install the CentOS Kernel Sources

The following procedure explains how to install an use the kernel sources used by CentOS, this procedure also applies for Fedora, but please note that the kernel version is different and maybe the spec file has not kernel number.

  • Download the sources from the main repository, usually is placed under ... /source/SRPMS
# cd /usr/local/src
# wget http:// ... /source/SRPMS/kernel-2.6.xxxxx.src.rpm
  • Install with rpm command
# yum install rpm-build
# useradd mockbuild
# rpm -ivh kernel-2.6.xxxxx.src.rpm
  • Go to the sources and build the kernel source folder structure
# cd /usr/src/redhat
# rpmbuild -bp SPECS/kernel-2.6.spec
  • Move the sources to the default location
# mv /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386 /usr/src/
# ln -sf /usr/src/linux-2.6.18.i386 /usr/src/linux

The folder /usr/src/linux wil have the current CentOS kernel with all the patches and fixes made by their development team. In order to keep untouched the kernel version and avoid conflicts at the time to add new modules, fixes, patches or whatever to the kernel, set the EXTRAVERSION variable to match the version of current installed kernel.

# cd /usr/src/linux
# sed -i "s/^EXTRAVERSION =/EXTRAVERSION = -`uname -r | cut -d '-' -f 2`/" Makefile