Gentoo - kernel

By: John McFarlane <john.mcfarlane@rockfloat.com>
Last updated: 02/01/2007 @ 23:59

Abstract:
This document will go thru a step by step installation of the linux 2.6.17-gentoo-r7 kernel.



1. Download the Linux kernel sources

To build the kernel you will need the actual kernel sources.

root# emerge gentoo-sources
        
I'm finished with this step

2. Configure the new kernel

Point /usr/src/linux to the correct kernel sources:

root# cd /usr/src
root# rm linux
root# ln -s linux-2.6.17-gentoo-r7 linux
        
Now we want to pick which pieces of the kernel we want, and which parts we don't want. The following command will open up a very simple but somewhat graphical interface that lets you pick which elements you want to include/exclude from your kernel. You also have the option to load some things as "Modules" that can loaded dynamically using insmod or modprobe:

root# cd /usr/src/linux
root# make menuconfig
        
Tip You can find most of the hardware information you'll need by using lspci.
If you are using SCSI but aren't sure which modules you need here are some commands that might help:
  1. root# dmesg | grep SCSI
  2. root# lsmod | grep SCSI
Here are some of the features that you will need if your running Gentoo like all the cool kids do. It's helpfull to remember that options will be marked (*) when they are compiled directly into the kernel, and (M) when it's to be compiled as a kernel module (and then loaded at a later time)

Processor Type and Features -->
    Processor Family -->
        *pick your processor, and hit the spacebar
Device Drivers -->
    ATA/ATAPI/MFM/RLL support -->
        [*] VIA82CXXX chipset support #dmesg | grep IDE to see what you need
    SCSI device support -->
        SCSI low-level drivers ->
            #Remove drivers you don't need
	    #Compile directly in the drivers you need [NOT AS MODULES!]
    Networking device support -->
        Ethernet (10 or 100Mbit) -->
            #Remove drivers you don't need
            #Compile AS MODULES, the drivers you need
        Ethernet (1000Mbit) -->
            #Add drivers as needed AS MODULES
    Sound -->
        Advanced Linux Sound Architecture -->
	    #Uncheck Advanced Linux Sound Architecture if you don't need sound
	    #Add drivers AS MODULES if you need them
File systems -->
    ( ) Deselect EXT3
    (*) Reiserfs support
        
Once your finished making your selections you can close the menuconfig interface and it will ask you to save the file. Go ahead and do this, saving the file under the name /usr/src/linux/.config
I'm finished with this step

3. Compile the new kernel

Now it's time to actually compile the kernel

root# make && make modules_install
        
I'm finished with this step

4. Copy the newly compiled kernel to the boot partition

In order to boot from your new kernel, it must be on the boot partition

root# cp arch/i386/boot/bzImage /boot/kernel-2.6.17-gentoo-r7
        
I'm finished with this step

5. Copy the system map to the boot partition


root# cp System.map /boot/System.map-2.6.17-gentoo-r7
        
I'm finished with this step

6. Replace the old system map with the new one


root# cd /boot
root# rm System.map
root# ln -s System.map-2.6.17-gentoo-r7 System.map
        
I'm finished with this step

7. Setup the bootloader (grub)


root# nano -w /boot/grub/grub.conf

# Make file look like this:
default 0
timeout 30
title=Gentoo Linux 2.6.17
root (hd0,0)
kernel /kernel-2.6.17-gentoo-r7 root=/dev/hda3
	
I'm finished with this step

8. Create /etc/fstab which holds static information about the filesystem


root# nano -w /etc/fstab

# Make file look like this:
/dev/hda1           /boot           ext2            defaults,noatime    1 2
/dev/hda3           /               reiserfs        noatime,notail      0 1
/dev/hda2           none            swap            sw                  0 0
/dev/cdroms/cdrom0  /mnt/cdrom      auto            noauto,ro,user      0 0
none                /proc           proc            defaults            0 0
none                /dev/shm        tmpfs           defaults            0 0
	
I'm finished with this step

9. Finish up the bootloader


root# cat /proc/mounts > /etc/mtab
root# grub-install /dev/hda
    	
Tip If you have problems with grub hanging as it tries to probe devices, you should know that grub-install gets all confused if you don't have a floppy. If you find yourself in this situation, try:
root# grub-install --recheck --no-floppy /dev/hda
I'm finished with this step

10. Resume Gentoo install if that's what you are doing

If you are currently following the Gentoo install howto, you can go back resume by clicking here.
I'm finished with this step

11. Install utilities for alsa

If your an alsa user (which is a good idea) you'll want to make sure you have the needed alsa utilities

user# sudo emerge -a alsa-utils alsa-driver
        
I'm finished with this step

12. Make sure modules.autoload.d is set up to your liking

After installing a new kernel of any version, it is important that you have the appropriate /etc/modules.autoload.d/kernel-X.Y created (X.Y is the first 2 parts of your new kernel version)

For example, this kernel will require:
/etc/modules.autoload.d/kernel-2.6
I'm finished with this step

13. Reboot

If all goes well, your machine will startup with a shiney new 2.6 kernel. Enjoy!
I'm finished with this step

Changelog: Date Description
01/30/2004 @ 21:00 Initial creation
11/03/2005 @ 18:30 Updates for the 2.6 kernel
12/11/2005 @ 14:00 Updated to be Gentoo specific
09/02/2006 @ 23:59 Updated for 2.6.17-gentoo-r7
02/01/2007 @ 23:59 Switch from cp to cat for mtab

This document was originally created on 01/30/2004


Conventions and tips for this howto document:
  1. Please remember that I'm no kernel expert, and making even the slightest wrong step in a kernel update can render your machine useless.
  2. Please always have a live-cd available and know how to use it - just in case something goes wrong :/

Disclaimer:
This page is not endorsed by gentoo.org or any other cool cats. Any information provided in this document is to be used at your own risk.