CentOS 6.4 kernel compile

On occasion you may find that the stock kernel just does not cut the mustard and decide to change some of the configuration parameters and re-compile. Below is a list of the steps involved.

As root:

yum groupinstall "Development Tools"
yum install ncurses-devel
yum install qt-devel qt3-devel
yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel
yum install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed xmlto
yum install binutils-devel elfutils-libelf-devel newt-devel python-devel zlib-devel

As standard user:

Install sources

wget http://vault.centos.org/6.4/updates/Source/SPackages/kernel-2.6.32-358.2.1.el6.src.rpm
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
rpm -i kernel-2.6.32-358.2.1.el6.src.rpm 2>&1

Prepare

cd ~/rpmbuild/
rpmbuild -bp --target=$(uname -m) SPECS/kernel.spec

Update spec file

cd ~/rpmbuild/SPECS
cp kernel.spec kernel.spec.ori
nano kernel.spec ; modify buildid #define to e.g. .zjl_c7

Also comment out lines 939 and 943

Configure

cd ~/rpmbuild/BUILD/kernel-2.6.32-358.2.1.el6/linux-2.6.32-358.2.1.el6.zjl_c7.i686/
cp ./configs/kernel-2.6.32-i686.config  .config
make oldconfig
make xconfig
nano .config ; add first line: # i386
cp -i .config configs/kernel-2.6.32-i686.config
; repeat for all other config files in configs
cp -i ./configs/kernel-2.6.32-i686* ~/rpmbuild/SOURCES/
; build
rpmbuild -v -bb --with baseonly --without debug --without debuginfo --without doc --without kabichk --target=`uname -m` SPECS/kernel.spec 2> build-err.log | tee build-out.log
rpmbuild -v -bb --target noarch --without doc SPECS/kernel.spec 2> fw-build-err.log | tee fw-build-out.log

As root:

rpm -ivh kernel-*.rpm

=======

See also

http://wiki.centos.org/HowTos/I_need_the_Kernel_Source

http://wiki.centos.org/HowTos/Custom_Kernel

http://wiki.centos.org/HowTos/BuildingKernelModules

Leave a Reply

Your email address will not be published. Required fields are marked *