Compile Linux Kernel on CentOS6
I have tried to compile Linux kernel 188.8.131.52 on CentOS6.3, whose default kernel is 2.6.32, successfully. It’s just for fun, you can follow the following simple steps if you are interested.
The CentOS6.3 runs on VMware, with 1 virtual CPU and 1GB RAM.
1. Fetch kernel source
Download the source of one kernel version from kernel.org. I selected stable version 184.108.40.206 but not the latest one.
2. Configure kernel
Second, extract the source archive and configure the kernel before compiling. There are many different way to configure the kernel, one simplest way is just copy the configuration for current kernel. The configuration file is located at /boot directory, like /boot/config-2.6.32-279.el6.i686. Just copy it to the kernel source directory as .config, and run following command:
Now compile the kernel just as compiling general applications:
4. Install the new kernel
cp arch/x86/boot/bzImage to /boot directory, you can rename it, and install the kernel modules:
Then make initrd with following command:
mkinitrd /boot/initramfs-220.127.116.11.fwso.img 18.104.22.168.fwso
22.214.171.124.fwso is my compiled kernel version, it should be changed according to your configuration.
If mkinitrd does not exist, install dracut package:
yum install -y dracut
Finally, configure your grub in order to boot from the new kernel.
Good luck, enjoy:)