How to (re)build a custom kernel on CentOS
There are plenty of how-to's about building vanilla kernel on all types of Linux'es. The top of the search results tell you about "the CentOS way" of building new kernel - using rpm etc. It might be the "right way" of obtaining a custom kernel, but it did not fit into my brains even after few reading attempts 🙂 Hence this simplified old-style procedure, that proved to work well on modern CentOS.
I needed to get rid of kipmi0 process clogging CPU on a server running CentOS 6.4 x64 (minimal install). Apparently the IPMI module was built in the kernel - therefore it was impossible to relinquish the system from it by a simple call to something like:
service ipmi stop
Or twiddling with lm-sensors (that were not installed on that system at all). I had to disable that module in the kernel configuration, rebuild the kernel and reboot the system into the new build.
Assuming one had a minimal install as I did, the following list should be sufficient. The list might contain some extra packages unnecessary for this exercise - please comment so we clean it up together.
yum -y groupinstall "Development tools" yum -y install ncurses-devel qt-devel yum -y install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel yum -y install rpm-build redhat-rpm-config asciidoc hmaccalc perl-ExtUtils-Embed yum -y install xmlto newt-devel python-devel rng-tools bc yum -y install wget
Get and pre-configure the kernel
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.51.tar.xz xz -d linux-3.2.51.tar.xz cd /usr/src tar xvf ~/linux-3.2.51.tar cd linux-3.2.51 make oldconfig
Edit the configuration
Let's edit the kernel configuration:
Find the line:
And replace it by:
I also changed CONFIG_ACPI_IPMI to "m" - though I am not sure it was needed in my particular case.
Build the new kernel
Let's use all the CPU cores available on the system - this can speed-up the process enormously! In the example below I used 20 cores for building.
make -j20 bzImage make -j20 modules make modules_install install
The commands above should get you a new bootable kernel and add necessary stuff to the grub config. One may still want to edit it:
If everything went Ok - please let others know it works in comments below. If anything went not as expected - I would appreciate your feed-back so we can make this little how-to useful for others!
Kipmi0 eating up to 99.8% cpu on centos 6.4 - Page 2