How to Recompile and install a new kernel.
How to Recompile and install a new kernel.
Recompiling and installing a kernel is often a fearsome experience for a linux newbie, here are easy to use (shampoo bottle) instructions for doing so.
1. Download the Linux kernel from the linux kernel website, currently Linux Kernel 2.6.12 (as of feb 2006)
*www.kernel.org
2. Extract the .Bz2 (BZip2) archive to /usr/src/, by doing the following.
Open a terminal, if you are in graphical environment or if it's your login shell, just continue.
Remember, You must be of group wheel to su in.
$ su
(root password)
# cd /usr/src
This moves you to /usr/src directory.
# tar -xvjpf <downloaded file location>/linux*.tar.bz2
This extracts the bz2 image to the /usr/src directory. Substitute the <downloaded file location> with the location of your file.
Now, we have to update the linux symlink for your earlier kernel to our new kernel source.
# rm linux
# ln -s linux-2.6.12* linux
this -s option instructs the ln command to create a symlink instead of a hard link. Make sure that the new link points to your new kernel.
Now, cd into directory and make the kernel.
# cd linux
# make menuconfig
This fires up a n-curses based menu that performs the kernel configuration. Here, I have nothing to do. Browse each option and take your time to fully read the help associated with each option. The commands lspci and lsmod can help you identify hardware info if you have installed pciutils package. Additionally you can also view boot messages for help, using dmesg. You can either compile stuff into the kernel using brutal compilation or compile stuff as modules in a more subtle way.
A few keystrokes to help you,
[Enter] --> Activate Current Item
[Esc] --> Go backwards
[Tab] --> Toggle through the interface.
/ --> Search
? ([shift] + /) --> Help for the associated item.
With item Selected,
Y --> Compile into kernel
N --> Donot Use the Item in the kernel.
M --> Compile as Module which you can insert, remove using insmod, modprobe commands.
Sometimes it opens up a submenu there you can either walk around using Arrow keys and select the stuff or type if it's a text input box.
After doing all your work, Go to the top most hierarchy and select [Exit] and select [yes] to save your config.
After you are dropped in the terminal, do the following.
# make
# make modules_install
This creates a hot new bz kernel for you to use. Copy it to the /boot partition using the following commands.
# cp arch/i386/boot/bzimage /boot/newkernel
Now, update your boot loader for booting with the new kernel, for example create new section in /boot/grub/grub.conf or in /boot/grub/menu.lst as,
# emacs /boot/grub/grub.conf
title newkernel26
root (boot partition in boot loader lingo) // Example (hd0,0)
kernel /boot/newkernel root=/dev/hda* (your root partition)
Save and close.
Now, you can boot your new kernel from the boot time. Enjoy Linux!!
Edit: a small mistake corrected.