[CentOS] rolling your own kernel - guidelines?

Florin Andrei florin at andrei.myip.org
Mon Oct 22 17:28:11 UTC 2007


Florin Andrei wrote:
> Let's say I want to use a much newer kernel - even one from the future, 
> such as the upcoming 2.6.24. :-) What would y'all smart folks do in this 
> case, in order to avoid any possible nasty consequences?
> Would you import the config file from the original CentOS5 kernel into 
> the new kernel, and let the kernel deal with the differences? I.e. have 
> the old configuration as some sort of baseline that can be further tweaked.
> Or some other strategy?

I may post a real HOWTO, or add a page to the wiki, if I get a chance, 
but until then, here's what I did to obtain a newer kernel package as 
similar as possible to the default CentOS kernel.

Install CentOS in a new VMware instance, or on a clean system. Make sure 
to install the Development packages, and also the relevant kernel 
packages, especially kernel-devel and kernel-headers. kernel-doc doesn't 
hurt either. ;-) This will be your clean build environment.

Optionally, create a dedicated account for building packages as 
non-root. This is discussed in other HOWTOs. Login as that account.

Do a "yum update" to get all the recent patches and updates. Reboot.

Get the kernel source tarball with the desired kernel version. Unpack, 
do "make clean; make mrproper"

Get the CentOS kernel's config file (it's in /boot, e.g. 
/boot/config-2.6.18-8.1.14.el5) and save it into the kernel source tree 
as ".config"
Then do a "make oldconfig".

Optionally, do a "make menuconfig" and tweak the kernel options even more.
You may especially want to edit the CONFIG_LOCALVERSION field to reflect 
the fact that you're building a custom kernel. I prefer to make that 
field "COMPANYNAME.x" where x is the build number - start with x=1 for 
the first build, and bump it up as you're building new versions of the 
same kernel. This will enable painless upgrades if you decide to tweak 
the kernel options later.

Save the .config file (now modified by the make commands) in a safe 
place for future re-use.

Apply this patch to the scripts/package/mkspec file (careful, at least 
one line is wrapped by the Gmane mail archive, so unwrap manually):

http://thread.gmane.org/gmane.linux.kernel/593172

Or just use the patch file attached to this message if the mail archive 
doesn't work for you.
Either way, the command to apply the patch is the same - from within the 
kernel source tree, run:

patch -p1 < mkspec.patch

Do "make rpm"

You will obtain a kernel rpm package that is similar in kernel features 
to the original CentOS kernel. Also, the package will do the right 
things (modify grub.conf, build initrd) when installed or uninstalled - 
that's what my patch to mkspec does.

Install with "rpm -i". Do not install with "rpm -U" (but you should know 
that already).

You may also want to upgrade packages such as iproute and iptables if 
you're using fancy features of very recent kernels. The actual versions 
to upgrade to depend on what you're doing. This upgrade may not be 
needed in "boring" scenarios.

Works For Me (TM) on CentOS 5 x86_64 with kernel 2.6.23.1

-- 
Florin Andrei

http://florin.myip.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkspec.patch
Type: text/x-patch
Size: 1708 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20071022/62cde5ed/attachment.bin>


More information about the CentOS mailing list