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.
Why?
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.
Prerequisites
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:
vi /usr/src/linux-3.2.51/.config
Find the line:
CONFIG_IPMI_SI=y
And replace it by:
CONFIG_IPMI_SI=m
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:
vi /boot/grub/menu.lst
Reboot!
reboot
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!
Pingback:Kipmi0 eating up to 99.8% cpu on centos 6.4 - Page 2