Recompiling the Linux kernel tntadmin August 15, 2013 How-To The Linux kernel is a very interesting piece of software. Recompiling a Linux kernel is every Linux geek’s right of passage. This is a tutorial on how to recompile the Linux kernel. The reasons to compile kernels are far and few in between. You may want to consider doing this if you have exotic architecture or hardware that the mainline kernel does not support, which is a rarity today. Another reason may be performance benefits. If you have a very old machine, creating a custom kernel with a minimal disk and memory footprint could be your thing. Similarly, if you need a kernel for an odd target device that has constrained resources, like a router or such, the only way to get past the limitations would be by compiling your own kernel, Well enough babbling from me let’s begin with the process. Step1 -> Install the kernel-devel kernel-headers packages [root@blizzard ~]# yum install kernel-devel kernel-headers ncurses ncurses-devel Step2 -> Install the Development and Debugging Tools these will be needed in order to recompile the linux kernel [root@blizzard ~]# yum groupinstall “Development-Tools” “Debugging Tools” Step3 -> Grab a copy of the lastest kernel. The latest version of the kernel at the time of this writing is 3.6 [root@blizzard ~]# wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.87.tar.gz Step4 -> Copy the linux-3.0.87.tar.gz kernel package over to the /usr/src directory. This directory holds the Linux kernel sources. [root@blizzard csh11]# cp linux-3.6.tar.gz /usr/src/ Step5 -> Unpack the Linux kernel Package [root@blizzard src]# tar -xzvf linux-3.0.87.tar.gz Step6 -> Change into the linux-3.6 Directory [root@blizzard src]# cd linux-3.0.87 Step7 -> Run the make menuconfig (text menu) or make config to configure the kernel Note: its always best to run the make menuconfig command it’s a lot easier to select or deselect modules. [root@blizzard src]# make config Step8 -> Run the make command [root@blizzard src]# make Step9 -> Install the kernel [root@blizzard src]# make install Step10 -> Make the kernel image [root@blizzard src]# make bzImage Step11 -> Make and install the modules [root@blizzard src]# make modules && make modules_install Step12 -> Copy the new image to /boot/ [root@blizzard src]# cp ./arch/i386/boot/bzImage /boot/vmlinuz-3.0.87-CUSTOM …and your config to /boot [root@blizzard src]# cp .config /boot/config-3.0.87-CUSTOM Step13 -> Create an initial RAMdisk (change the ext3 to whatever file system you use and the device file in which your root partition resides. In my case, my / is on device /dev/sda5) [root@blizzard src]# mkinitrd -c -k vmlinuz-3.0.87-CUSTOM -m jbd:ext4 -f ext4 -r /dev/sda5 Step14 -> After the mkinitrd command, it will generate /boot/initrd.gz. If you want, you can change your initrd.gz name. [root@blizzard src]# mv /boot/initrd.gz /boot/initd-3.0.87-CUSTOM.gz Step15 -> Edit your /etc/lilo.conf and add new entries at the buttom. Don’t remove the old settings so you would have a fallback. Add these lines. Change the root value to the device for your / partition. You can also change the label. image = /boot/vmlinuz-3.0.87-CUSTOM initrd = /boot/initrd-3.0.87-CUSTOM.gz root = /dev/sda5 label = Linux-3.0.87 read-only Step16 -> After saving your lilo.conf, install it. [root@blizzard src]# lilo Step17 -> Restart the computer [root@blizzard src]# reboot Then on the bootsplash screen, select your new kernel and If your lucky it will work. That’s it I hope this article will be useful to anyone trying to learn about recompiling the linux kernel in centos. m4s0n501 Leave a Reply Cancel Reply You must be logged in to post a comment.