User:Tompravi

Choosing the Sources:
First off, head over to the Kernel Sources page and figure out which kernel you'll be wanting to install.

The most commonly used sources are the vanilla and gentoo sources:


 * : sources straight from kernel.org (unpatched)
 * : sources patched for bug fixes and features by Gentoo Developers
 * : sources of the development version, maintained by Andrew Morton. Use if you want to help with kernel testing or really bleeding-edge material.
 * : contains gentoo standard patchset as well as patches maintained by Con Kolivas for a low-latency desktop or server system. The ck-server use flag tunes for server applications.

Installing the Kernel Sources
As root,download and extract the chosen kernel sources with, for example:

If a specific version is desired, run, for example, as root :

If using a tarball, for example 2.6.14.2 directly from kernel.org, unpack it, as root, to using the following instructions.

Unpacking kernel sources

The /usr/src/linux Symlink
Linux uses a neat method for allowing programs that need to compile against the kernel (such as kernel modules, "nvidia-drivers" for example) to know which version they should compile against. This is the symlink.

Gentoo additionally provides an easy tool for moving this symlink around, called kernel-config (It's actually part of, so make sure that package is installed). To see a quick summary of how to use kernel-config, run it with no other options:

Now that the new kernel sources are installed, move the symlink to point to them using the following procedure. First list the available kernel sources with:

Example output of kernel-config

the currently selected sources are marked with an ' * '. For older versions run :

Now set the symlink to the new kernel sources. For example, if the new sources are 2.6.20-rc5, then run as root:

Alternatively, the sources directory name can also be used, for example:

Detecting your Hardware:
Running, as root, will give you the basics about what is on your system, if you do not know. The output from lspci looks like this: lspci You'll particularly need to know the IDE Chipset ([Intel] 8xx series in the example), the Audio Controller (Creative Labs SB Audigy), and the Ethernet Controller (Intel PRO/100 VE). You won't normally need to know your VGA Controller type when compiling the kernel.

Also you may look, as root, at output, if for some reason you don't know what's hooked up to your computer (...):

lsusb

Configuring the Kernel
cd to your kernel source directory in. Type: Or, if you have X support, type: at the command line. You'll see a bunch of text flying by and then you'll see the ncurses kernel configuration screen.

When you see an '[M]' next to an option it means it will compile as a module. When you see an '[*]' next to an option it means it's compiled into the kernel. The difference is "modules" are not a part of the kernel; they are similar to what Windows users may think of as `drivers`. Modules must be loaded manually. The built-in parts of the kernel are just that; they do not need to be manually loaded.

Generally, the menuconfig defaults are suitable for most users. However, there are a few areas that require our special attention.

First off--enable Gentoo required options:

Select one or more of the following filesystems. Your filesystem, the one on which gentoo is now running, MUST BE COMPILED INTO THE KERNEL, NOT as a module. To find out which filesystem you're running, open the file in your favorite text editor. The line where the second element is / will be your root filesystem, and you can see what type the filesystem is there. For example:

The above would indicate that the main filesystem is of type ReiserFS.

If you're still unsure of your filesystem, just enable the most common types - this is perfectly safe to do, but will result in a larger kernel:

Recall your chipsets you were directed to find earlier. You might not need them, as by default, the menuconfig program automatically enables the most common hardware chipsets. The IDE Chipset Controller Drivers are under:

Next is Audio. You'll find drivers for the Advanced Linux Sound Architecture (the default; OSS is no longer used) at:

You should only enable one of these. Compile your soundcard INTO the kernel, not as a module, so you won't have to worry about module loading. If you have an Audigy 1, 2, or 4 card, for example, select the `emu10k1` driver.

Next is your Ethernet Controller, which connects your computer to your cable or DSL modem. I'm assuming you have a 10/100 Card (almost everyone does). Gigabit cards are relatively common nowadays, find them under Ethernet (1000Mbit), except for the forcedeth driver for nVidia nForce cards, which is under the 10/100 section despite supporting gigabit on nForce4 chipsets. Choose your driver under:

The Ethernet Driver can be modular or compiled into the kernel, but again, I recommend you compile it into the kernel for reasons of simplicity.

If your network uses PPP (dial-up), you'll have to enable the following:

If you are compiling your kernel for a laptop computer then you'll probably want to include ACPI to help improve battery life. These options can compiled in or built as modules, either way they should function properly.

Unless you're into selecting advanced options or are following the ATI Driver guide, you are done configuring the kernel. Keep choosing  until it asks you if you want to save your new kernel configuration. Choose yes, of course!

Compiling the kernel
Run the following in the kernel source directory:

Voila! Your kernel has been compiled and you are ready to install.

Installing the kernel
Great Job! You're almost done. Now just copy over the kernel image to. This can be done with the provided kernel image installer available in all linux kernel sources:

This will make a backup of the old kernel under the name and save a copy of the new one with the name. You can keep your bootloader (either GRUB or LILO) pointed at at all times and provide for a backup,. That way if something goes wrong, you can boot to the old version of the kernel (vmlinuz.old).

Manual installation
Mount with

Then copy new kernel in to the boot directory

Then install the modules in.

Now configure the boot manager. Make sure to match your chosen filename when you specify the kernel in the GRUB or LILO config file.

To be specific, use a line like: kernel /boot/vmlinuz ... in if you use GRUB, or image=/boot/vmlinuz ... in if you use LILO. In either case, replace "..." with suitable kernel options. You can find and copy these from a working or.

In both GRUB and LILO, you may wish to give yourself a "fallback" option by creating a separate menu entry pointing to. See the documentation for your bootloader for further details.

Autoloading modules at boot
If you compiled any kernel drivers as modules, you'll need to add module name to, for example: echo "nvidia" >> /etc/modules.autoload.d/kernel-2.6

The driver name can be found in the menuconfig help file on the particular driver (pressing "SHIFT" + "/" on the driver, a key combo that otherwise produces a question mark).

Rebuild modules
Modules provided by other packages, such as nvidia or ipw2200, can be rebuilt by installing the package and then running:

Automating the compilation with a shell script
After you've figured out which steps are necessary to compile your kernel, you can create a shell script that facilitates future compilations:


 * 1) !/bin/sh

mount /boot cd /usr/src/linux make menuconfig && \ make && \ make modules_install && \ # all kernel sources provide an image installer make install && \ umount /boot
 * 1) This script assumes a correct /usr/src/linux symlink!


 * 1) Add required package remerges here:
 * 2) emerge alsa-driver

General Update - the quick version
Note: This section assumes previous experience with updating the kernel and is for when just changing settings on an existing kernel. For detailed instructions on upgrading the kernel, please see Gentoo Linux Kernel Upgrade Guide.

For those who just need to update your kernel, here's how: mount /boot make clean && make && make modules_install && make install Now edit the grub or lilo config files as required.
 * configure your kernel (cd to and run as root make menuconfig).
 * choose your updated options.
 * run the following (note this is just taken from above)
 * 1) note: manually copying kernel images is not required as
 * 2) note: all linux kernel sources provide an image installer
 * 3) note: in this howto we use make install
 * 1) add any modules to /etc/modules.autoload.d/kernel-2.6
 * 2) rebuild any modules using module-rebuild rebuild