The Internet is filled with outdated / incorrect / complicated / wrong ways to compile the Linux kernel. It's not difficult to do. I simply cannot account for all the incorrect posts.
Get the kernel source: curl -O http://www.kernel.org/pub/linux/kernel/2.6/linux-<version>.tar.bz2
Will put the kernel source file into the working directory. If you're wondering how one would know what to put for <version>, you go into the kernel archive using a web browser, and you look for the exact <version> you want. If you don't know what version you want, stick with the latest stable version, as listed on this page:
There is a link on that page to the
directory. When you get to
The kernel source files are
The other files in the directory are used for verifying the authenticity of the kernel.
** OPTIONAL **
If you wish to verify the kernel source file, download the proper
file, and get the kernel.org public encryption key here:
Then install the
package, and verify the kernel is properly signed.
** END OPTIONAL **
Install the development or lsb package for your distro. Move the kernel source file to:
mv linux-<version>.tar.bz2 /usr/src
tar jxvf linux-<version>.tar.bz2
The screen will scroll. Remove the:
Make a new soft link to the new kernel source directory:
ln -s linux-<version> linux
Change directory to linux:
Get a config file to start with:
cp /boot/config-`uname -r` .config
Apply and patches:
patch -p 1 < <patch>.diff
Configure the kernel:
The new kernel will work if you agree with everything the configure program suggests. If you disagree, and change something, it will usually be ok.
Now, make the changes to the kernel configuration that you desire, and save the
file. Don't worry about ruining the kernel config. If the new kernel doesn't boot, you can boot using the old kernel and repeat the above steps to copy the config file from
And configure the kernel again.
Give the kernel a unique name:
Put something meaningful after
such as the date, preceded by a hyphen. Name the kernel after an attractive female, using lowercase only. If you need to use numbers in the name of an attractive female ... Ok, Save:
Compile the kernel:
After you do the
step, there is a command line left on the screen, beginning with
You need to:
chmod +x /usr/src/linux-<version>/arch/x86/boot/install.sh
and then type the entire command left by:
and execute it.
Now you should have:
for a new entry.
# and a space
in front of
Check for your new entry, which should read
title <something> <version>
kernel /vmlinuz-<version> root=<something>
If the entry for your new kernel is in
the machine should boot with the new kernel.
The main rule for compiling a new kernel, or a kernel rebuild, is remove unnecessary options, such as unnecessary drivers, from the kernel config. You must know your hardware. But you can reduce the size of the kernel considerably, which is good. Usually a kernel rebuild is due to a patch being applied, requiring recompilation.