[CentOS] Run a more recent kernel than 2.6.18 on CentOS?

Florin Andrei florin at andrei.myip.org
Wed Sep 17 23:08:36 UTC 2008

Niki Kovacs wrote:
> Hi,
> Usually I'm not one to complain about "old" version of the CentOS kernel 
> and/or software, since I appreciate CentOS' stability. So this might be 
> the exception that confirms the rule.

It's not the end of the world. I've a server with a whole bunch of 
various services, running CentOS 5.2 x86_64 and a custom kernel, because 
the network card is not supported by the original kernel. It's rock solid.

> What i naively plan to do: get a kernel SRPM from Fedora 9, try to build 
> from there, and see where it leads.

Get the vanilla kernel tarball.
Apply the mkspec patch. (*)
Get the .config file from the CentOS kernel (see /boot).
Use that config file to do a "make oldconfig" in the vanilla kernel 
source tree. This will import most settings from the original CentOS kernel.
Now do a "make menuconfig" and peruse the config items. Make sure it's 
not missing important stuff.
Now do "make rpm".
Voila, you've got a kernel rpm that's pretty similar to CentOS, only newer.

(*) - without the mkspec patch, the rpm will be pretty generic. The 
CentOS/Redhat kernel rpm has a few more features that you need. This 
patch adds them. See the file attached to this message.

Florin Andrei

-------------- next part --------------
--- linux-	2007-10-19 02:07:58.000000000 -0700
+++ linux-	2007-10-19 05:42:47.000000000 -0700
@@ -81,6 +81,11 @@ echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"
 echo "%endif"
 echo "%endif"
+if $RPM_RH5_STYLE; then
+echo 'touch $RPM_BUILD_ROOT'"/boot/initrd-$KERNELRELEASE.img"
+echo 'gzip -c9 < Module.symvers > $RPM_BUILD_ROOT'"/boot/symvers-$KERNELRELEASE.gz"
 echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
 echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
@@ -88,9 +93,44 @@ echo ""
 echo "%clean"
 echo '#echo -rf $RPM_BUILD_ROOT'
 echo ""
+if $RPM_RH5_STYLE; then
+if [ `uname -i` == "x86_64" -o `uname -i` == "i386" ]; then
+  if [ -f /etc/sysconfig/kernel ]; then
+    /bin/sed -i -e 's/^DEFAULTKERNEL=kernel-smp$/DEFAULTKERNEL=kernel/' /etc/sysconfig/kernel || exit $?
+  fi
+/sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install $KERNELRELEASE || exit $?
+if [ -x /sbin/weak-modules ]
+    /sbin/weak-modules --add-kernel $KERNELRELEASE || exit $?
+/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove $KERNELRELEASE || exit $?
+if [ -x /sbin/weak-modules ]
+    /sbin/weak-modules --remove-kernel $KERNELRELEASE || exit $?
 echo "%files"
 echo '%defattr (-, root, root)'
 echo "%dir /lib/modules"
 echo "/lib/modules/$KERNELRELEASE"
+if $RPM_RH5_STYLE; then
+cat <<RH5_FILES
+%ghost /boot/initrd-$KERNELRELEASE.img
 echo "/boot/*"
 echo ""

More information about the CentOS mailing list