Compile Linux Kernel on CentOS6
I have tried to compile Linux kernel 2.6.34.14 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 2.6.34.14 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:
make oldconfig
3. Compile
Now compile the kernel just as compiling general applications:
make
4. Install the new kernel
cp arch/x86/boot/bzImage to /boot directory, you can rename it, and install the kernel modules:
make modules_install
Then make initrd with following command:
mkinitrd /boot/initramfs-2.6.34.14.fwso.img 2.6.34.14.fwso
2.6.34.14.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:)