Installing the Sources Choosing a Kernel

The core around which all distributions are built is the Linux kernel. It is the layer between the user programs and your system hardware. Gentoo provides its users several possible kernel sources. A full listing with description is available at the Gentoo Kernel Guide.

For x86-based systems we have, amongst other kernels, vanilla-sources (the default kernel source as developed by the linux-kernel developers), gentoo-sources (kernel source patched with performance-enhancing features), xfs-sources (kernel source with the latest XFS support), gs-sources (kernel source patched for server usage), gaming-sources (kernel source patched for optimal gaming performance), ...

For alpha-based systems we have vanilla-sources (the default kernel source as developed by the linux-kernel developers), alpha-sources (kernel source optimized for alpha users) and compaq-sources (kernel source as used by RedHat for Alpha, maintained by Compaq).

For sparc-based systems we have vanilla-sources (the default kernel source as developed by the linux-kernel developers) and sparc-sources (kernel source optimized for SPARC users).

Other architectures should use the kernel source specifically optimized for their architecture: hppa-sources (HPPA) and ppc-sources (PowerPC).

Choose your kernel source and install it using emerge. From now onwards we will use emerge --usepkg which will install a prebuilt package if available (for GRP users) and download it otherwise. In other words, if you are not using prebuilt packages, you can omit the --usepkg option, but you don't have to. Furthermore, you can abbreviate the --usepkg option by using -k.

In the next example we install the vanilla-sources (as gentoo-sources isn't available on all architectures). Of course substitute with your choice of sources:

# emerge --usepkg vanilla-sources

When you take a look in /usr/src you should see a symlink called linux pointing to your kernel source:

# ls -l /usr/src/linux
lrwxrwxrwx    1 root     root           12 Oct 13 11:04 /usr/src/linux -> linux-2.4.22

If this isn't the case (i.e. the symlink points to a different kernel source) change the symlink before you continue:

# rm /usr/src/linux && ln -s /usr/src/linux-2.4.22 /usr/src/linux

Now it is time to configure and compile your kernel source. The x86-based architectures can use genkernel for this, which will build a generic kernel as used by the LiveCD. We explain the "manual" configuration first though, as it is the best way to optimize your environment.

If you want to manually configure your kernel, continue now with Default: Manual Configuration. If you are an x86-users and you want to use genkernel you should read Alternative: Using genkernel instead.

Default: Manual Configuration Introduction

Manually configuring a kernel is often seen as the most difficult course every Linux users ever has to go through. Nothing is less true -- after configuring a couple of kernels you don't even remember that it was difficult ;)

However, one thing is true: you must know your system when you start configuring a kernel manually. Most information can be gathered by viewing the contents of /proc/pci (or by using lspci if available). You can also run lsmod to see what kernel modules the LiveCD uses (it might provide you with a nice hint on what to enable).

Now go to your kernel source directory and execute make menuconfig. This will fire up an ncurses-based configuration menu.

# cd /usr/src/linux
# make menuconfig

You will be greeted with several configuration sections. We'll first list some options you must activate (otherwise Gentoo will not function, or not function properly without additional tweaks).

Activating Required Options

First of all, activate the use of development and experimental code/drivers. You need this, otherwise some very important code/drivers won't show up:

Code maturity level options --->
  [*] Prompt for development and/or incomplete code/drivers"

Now go to File Systems and select support for the filesystems you use. Don't compile them as modules, otherwise your Gentoo system will not be able to mount your partitions. Also select Virtual memory, /proc file system, /dev file system + Automatically mount at boot:

File systems --->
  [*] Virtual memory file system support (former shm fs)
  [*] /proc file system support
  [*] /dev file system support (EXPERIMENTAL)
  [*]   Automatically mount at boot

(Deselect the following unless you have a 2.6 kernel)
  [ ] /dev/pts file system for Unix98 PTYs

(Select one of more of the following options as needed by your system)
  <*> Reiserfs support
  <*> Ext3 journalling file system support
  <*> JFS filesystem support
  <*> Second extended fs support
  <*> XFS filesystem support

If you are using PPPoE to connect to the Internet, you will need the following options in the kernel:

Network device support --->
  <*> PPP (point-to-point protocol) support
  <*>   PPP support for async serial ports
  <*>   PPP support for sync tty ports

The two compression options won't harm but are not definitely needed, neither does the PPP over Ethernet option, that might only be used by rp-pppoe when configured to do kernel mode PPPoE.

If you are using LVM, you will need to activate it in the kernel:

Multi-device support (RAID and LVM) --->
  [*] Multiple devices driver support (RAID and LVM)
  <*>  Logical volume manager (LVM) support

If you require it, don't forget to include support in the kernel for your ethernet card.

Now, dependent on your architecture, you might need to select more options:

  • Activating Alpha-recommended Options
  • Activating HPPA-recommended Options
  • Activating PPC-recommended Options
  • Activating SPARC-recommended Options

If you have an x86-based system, you can immediately continue with Compiling and Installing.

Activating Alpha-recommended Options

The following options are recommended for Alpha-users:

General setup --->
  <*> SRM environment through procfs
  <*> Configure uac policy via sysctl

Plug and Play configuration --->
  <*> Plug and Play support
  <M>   ISA Plug and Play support

SCSI support --->
  SCSI low-level drivers --->
    <*> SYM53C8XX Version 2 SCSI support (NEW)
    <*> Qlogic ISP SCSI support

Network device support --->
  Ethernet (10 or 100 Mbit) --->
    <M> DECchip Tulip (dc21x4x) PCI support
    <M> Generic DECchip & DIGITAL EtherWORKS PCI/EISA
    <M> EtherExpressPro/100 support (eepro100)
    <M> EtherExpressPro/100 support (e100)
  Ethernet (1000 Mbit) --->
    <M> Alteon AceNIC
      [*] Omit support for old Tigon I
    <M> Broadcom Tigon3
  [*] FDDI driver support
  <M> Digital DEFEA and DEFPA
  <*> PPP support
    <*> PPP Deflate compression

Character devices --->
  [*] Support for console on serial port
  [*] Direct Rendering Manager

File systems --->
  <*> Kernel automounter version 4 support
  Network File Systems --->
    <*> NFS
      [*] NFSv3 client
      <*> NFS server
      [*] NFSv3 server
  Partition Types --->
    [*] Advanced partition selection
    [*] Alpha OSF partition support
  Native Language Support
    <*> NLS ISO 8859-1

Sound --->
  <M> Sound card support
    <M> OSS sound modules
      [*] Verbose initialisation
      [*] Persistent DMA buffers
      <M> 100% Sound Blaster compatibles

When you're finished configuring the kernel, continue with Compiling and Installing.

Activating HPPA-recommended Options

If you have a HIL mouse or keyboard, do not forget to compile in support for them.

Input core support --->
  [*] Keyboard support
  [*] Mouse support
  [*] Event interface support

If you have no mouse on your HIL port, only use the basic support:

HIL support --->
  [*] HIL Keyboard (basic) support

If you however want full HIL support, select the following options:

HIL support --->
  [*] HP System Device Controller i8042 Support
  [*] HIL MLC Support
  [*] HIL Keyboard (full) support
  [*] HIL Mouse & Pointer support

When you're done configuring your kernel, continue with Compiling and Installing.

Activating PPC-recommended Options

First of all, disable ADB raw keycodes:

Macintosh Device Drivers --->
  [ ] Support for ADB raw keycodes

Also choose the correct RTC support (disable the Enhanced RTC option):

Character devices --->
  [ ] Enhanced RTC

General setup --->
  [*] Support for /dev/rtc

Users of OldWorld machines will want HFS support so they can copy compiled kernels to the MacOS partition.

File Systems --->
  [*] HFS Support

When you're done configuring your kernel, continue with Compiling and Installing.

Activating SPARC-recommended Options

First activate the correct bus-support:

Console drivers --->
  Frame-buffer support --->
    [*] SBUS and UPA framebuffers             
      [*] Creator/Creator3D support     (Only for UPA slot adapter used in many Ultras)
    [*] CGsix (GX,TurboGX) support      (Only for SBUS slot adapter used in many SPARCStations)

Of course you want support for the OBP:

Misc Linux/SPARC drivers --->
  [*]  /dev/openprom device support

You will also need SCSI-specific support:

SCSI support --->
  SCSI low-level drivers --->
    <*> Sparc ESP Scsi Driver             (Only for SPARC ESP on-board SCSI adapter)
    <*> PTI Qlogic, ISP Driver            (Only for SBUS SCSI controllers from PTI or QLogic)
    <*> SYM53C8XX Version 2 SCSI support  (Only for Ultra 60 on-board SCSI adapter)

To support your network card, select on of the following:

Network device support --->
  Ethernet (10 or 100Mbit) --->
    <*> Sun LANCE support                   (Only for SPARCStation, older Ultra systems, and as Sbus option)
    <*> Sun Happy Meal 10/100baseT support  (Only for Ultra; also supports "qfe" quad-ethernet on PCI and Sbus)

When you're done configuring your kernel, continue with Compiling and Installing. However, after having compiled the kernel, check its size:

# ls -lh vmlinux
-rw-r--r--    1 root     root         2.4M Oct 25 14:38 vmlinux

If the (uncompressed) size is bigger than 2.5Mb (for Sparc32) or 3.5Mb (for Sparc64), reconfigure your kernel untill it doesn't exceed these limits. Ignoring this can lead to a non-booting kernel.

Compiling and Installing

Now that your kernel is configured, it is time to compile and install it. Exit the configuration and run make dep && make bzImage modules modules_install:

(For x86-based systems, 2.4 kernel)
# make dep && make bzImage modules modules_install

(For other systems, 2.4 kernel)
# make dep && make vmlinux modules modules_install

(For 2.6 kernel)
# make && make modules_install

When the kernel is done compiling, copy over the kernel image to /boot. In the next example we assume you have configured and compiled vanilla-sources-2.4.22:

(For x86-based systems)
# cp arch/i386/boot/bzImage /boot/kernel-2.4.22
# cp System.map /boot/System.map-2.4.22

(For other systems)
# cp vmlinux /boot/kernel-2.4.22
# cp System.map /boot/System.map-2.4.22

It is also wise to copy over your kernel configuration file to /boot, just in case :)

# cp .config /boot/config-2.4.22

Now continue with Installing Seperate Kernel Modules.

Alternative: Using genkernel

If you are reading this section, you have chosen to use our genkernel script to configure your kernel for you. However, this also means that you have an x86-based system. Other architectures are not supported by genkernel.

Now that your kernel source tree is installed, it's now time to compile your kernel by using our genkernel script to automatically build a kernel for you. genkernel works by configuring a kernel nearly identically to the way our LiveCD kernel is configured. This means that when you use genkernel to build your kernel, your system will generally detect all your hardware at boot-time, just like our Live CD does. Because genkernel doesn't require any manual kernel configuration, it is an ideal solution for those users who may not be comfortable compiling their own kernels.

Now, let's see how to use genkernel. First, emerge the genkernel ebuild:

# emerge --usepkg genkernel

Now, compile your kernel sources by running genkernel. Be aware though, as genkernel compiles a kernel that supports almost all hardware, this compilation will take quite a while to finish!

# genkernel
Gentoo Linux genkernel, version 1.4
Copyright 2003 Gentoo Technologies, Inc., Bob Johnson, Daniel Robbins
Distributed under the GNU General Public License version 2

Settings:
compile optimization: 1 processor(s)
source tree: /usr/src/linux-2.4.22
config: gentoo (customized)
config loc: /etc/kernels/config-2.4.22
initrd config: (default) /etc/kernels/settings

* Running "make oldconfig"...                                                                     [ ok ]
* Logging to /var/log/genkernel.log...                                                            [ ok ]
* Starting 2.4.22 build...                                                                        [ ok ]
* Running "make dep"...                                                                           [ ok ]
* Running "make bzImage"...                                                                       [ ok ]
* Running "make modules"...                                                                       [ ok ]
* Running "make modules_install"...                                                               [ ok ]
* Moving bzImage to /boot/kernel-2.4.22...                                                        [ ok ]
* Building busybox...                                                                             [ ok ]
* Creating initrd...                                                                              [ ok ]

* Build completed successfully!

* Please specify /boot/kernel-2.4.22 and /boot/initrd-2.4.22
* when customizing your boot loader configuration files.

Once genkernel completes, a kernel, full set of modules and initial root disk (initrd) will be created. We will use the kernel and initrd when configuring a boot loader later in this document. Write down the names of the kernel and initrd as you will need it when writing the bootloader configuration file. The initrd will be started immediately after booting to perform hardware autodetection (just like on the Live CD) before your "real" system starts up.

Now, let's perform one more step to get our system to be more like the Live CD -- let's emerge hotplug. While the initrd autodetects hardware that is needed to boot your system, hotplug autodetects everything else. To emerge and enable hotplug, type the following:

# emerge --usepkg hotplug
# rc-update add hotplug default
Installing Seperate Kernel Modules

Finally, you should emerge ebuilds for any additional hardware that is on your system. Here is a list of kernel-related ebuilds that you could emerge:

nvidia-kernelAccelerated NVIDIA graphics for XFree86emerge --usepkg nvidia-kernelnforce-netOn-board ethernet controller on NVIDIA NForce(2) motherboardsemerge nforce-netnforce-audioOn-board audio on NVIDIA NForce(2) motherboardsemerge nforce-audioe100Intel e100 Fast Ethernet Adaptersemerge e100e1000Intel e1000 Gigabit Ethernet Adaptersemerge e1000emu10k1Creative Sound Blaster Live!/Audigy supportemerge emu10k1ati-driversAccelerated ATI Radeon 8500+/FireGL graphics for XFree86emerge ati-driversxfree-drm Accelerated graphics for ATI Radeon up to 9200, Rage128, Matrox, Voodoo and other cards for XFree86 VIDEO_CARDS="yourcard" emerge xfree-drm
Ebuild Purpose Command

Beware though, some of these ebuilds might deal with big dependencies. To verify what packages will be installed by emerging an ebuild, use emerge --pretend. For instance, for the emu10k1 package:

# emerge --pretend emu10k1

If you don't like the packages it wants to install, use emerge --pretend --verbose to see what USE-flags are checked when deciding the dependencies:

# emerge --pretend --verbose emu10k1
...
[ebuild  N    ] media-sound/aumix-2.8  +gpm +nls +gtk +gnome +alsa -gtk2

In the previous example you can see that one of emu10k1's dependencies (aumix) uses the gtk and gnome USE-flags, making gtk (which depends on XFree) be compiled with it.

If you don't want all this to be compiled, deselect all USE-flags, for instance:

# USE="-gpm -nls -gtk -gnome -alsa" emerge --pretend emu10k1

When you're happy with the results, remove the -p to start installing emu10k1.