User:Zulu Foxtrott/Parts/Installation/Kernel

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

Downloading the sources
The recommended way to get the kernel sources is downloading them directly from upstream (the kernel developers themselves). Like with downloading the stage tarball, the only tool necessary is a web browser.

When installing kernel sources provided by Portage on a running Gentoo system, the package manager places them in the directory. Go to the directory that once the installation is finished and running on the target system will be found at :

Graphical browsers
In environments with fully graphical web browsers copy the kernel sources URL from. Right click on the big yellow button labeled "Latest Release" and featuring the current stable release's version number, then (Firefox) or  (Chromium) to copy the link to the clipboard, then paste the link to the  utility on the command-line to download the sources:

Command-line browsers
To download the kernel sources directly from a command line environment, use for example, the non-graphical, menu-driven browser.

To use an HTTP proxy with, pass on the URL with the  option:

Alternatively, use the (also non-graphical but not menu-driven) browser.

If a proxy needs to be defined, and it has not been done already, export the http_proxy and/or ftp_proxy variables:

Select the version number (or "Download" next to it) displayed below the line "Latest Release" and press to start the download.

Unpacking the sources
Create a directory on the storage device for the unpacked kernel sources:

Now unpack the downloaded kernel sources with into the newly created directory specified with the command line argument  :

This will install the Linux kernel sources under the path in a directory named "linux" followed by a version number. Change into that folder now:

Now it is time to configure and compile the kernel sources.

Introduction
Manually configuring a kernel is often seen as the most difficult procedure a Linux user ever has to perform. Nothing is less true - after configuring a couple of kernels no-one even remembers that it was difficult ;)

However, one thing is true: it is vital to know the system when a kernel is configured manually. Most information can be gathered by emerging which contains the  command:

Another source of system information is to run to see what kernel modules the installation CD uses as it might provide a nice hint on what to enable.

TODO: link to Preparing the environment

In case the host system's and the target system's architecture are not the same, it may be a good idea to double check now that the necessary environment variables are correctly set as outlined in "Preparing the environment" (the first step of the installation process). The list of all active environment variables can be displayed by using the command with the   argument. With the command it is possible to search for patterns of interest (in this case   and  ). To search the output of the command directly for the patterns of interest, hand it over to the  command using  (the pipe operator):

Now go to the kernel source directory and execute. This will fire up menu-driven configuration screen.

The Linux kernel configuration has many, many sections. Let's first list some options that must be activated (otherwise Gentoo will not function, or not function properly without additional tweaks). We also have a Gentoo kernel configuration guide on the Gentoo wiki that might help out further.

Activating required options
Make sure that every driver that is vital to the booting of the system (such as SCSI controller, etc.) is compiled in the kernel and not as a module, otherwise the system will not be able to boot completely.

Next select the exact processor type. It is also recommended to enable MCE features (if available) so that users are able to be notified of any hardware problems. On some architectures (such as x86_64), these errors are not printed to, but to. This requires the package.

Also select Maintain a devtmpfs file system to mount at /dev so that critical device files are already available early in the boot process ( CONFIG_DEVTMPFS and CONFIG_DEVTMPFS_MOUNT ):

Verify SCSI disk support has been activated ( CONFIG_BLK_DEV_SD ):

Now go to File Systems and select support for the filesystems you use. Don't compile the file system that is used for the root filesystem as module, otherwise the Gentoo system will not be able to mount the partition. Also select Virtual memory and /proc file system. Select one or more of the following options as needed by the system ( CONFIG_EXT2_FS, CONFIG_EXT3_FS , CONFIG_EXT4_FS , CONFIG_MSDOS_FS , CONFIG_VFAT_FS , CONFIG_PROC_FS , and CONFIG_TMPFS ):

If PPPoE is used to connect to the Internet, or a dial-up modem, then enable the following options ( CONFIG_PPP, CONFIG_PPP_ASYNC , and CONFIG_PPP_SYNC_TTY ):

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 ppp when configured to do kernel mode PPPoE.

Don't forget to include support in the kernel for the network (Ethernet or wireless) cards.

Most systems also have multiple cores at their disposal, so it is important to activate Symmetric multi-processing support ( CONFIG_SMP ):

If USB input devices (like keyboard or mouse) or other USB devices will be used, do not forget to enable those as well ( CONFIG_HID_GENERIC and CONFIG_USB_HID, CONFIG_USB_SUPPORT , CONFIG_USB_XHCI_HCD , CONFIG_USB_EHCI_HCD , CONFIG_USB_OHCI_HCD ):

Optional: Building an initramfs
In certain cases it is necessary to build an initramfs - an initial ram-based file system. The most common reason is when important file system locations (like or ) are on separate partitions. With an initramfs, these partitions can be mounted using the tools available inside the initramfs.

Without an initramfs, there is a huge risk that the system will not boot up properly as the tools that are responsible for mounting the file systems need information that resides on those file systems. An initramfs will pull in the necessary files into an archive which is used right after the kernel boots, but before the control is handed over to the init tool. Scripts on the initramfs will then make sure that the partitions are properly mounted before the system continues booting.

To install an initramfs, install first, then have it generate an initramfs:

In order to enable specific support in the initramfs, such as LVM or RAID, add in the appropriate options to. See for more information. In the next example support is enabled for LVM and software RAID :

The initramfs will be stored in. The resulting file can be found by simply listing the files starting with initramfs:

Configuring the modules
List the modules that need to be loaded automatically in files one module per line. Extra options for the modules, if necessary, should be set in files.

To view all available modules, run the following command. Don't forget to substitute " " with the version of the kernel just compiled:

For instance, to automatically load the module (which is the driver for a specific 3Com network card family), edit the  file and enter the module name in it. The actual file name is insignificant to the loader.

Continue the installation with Configuring the system.

Optional: Installing firmware
Some drivers require additional firmware to be installed on the system before they work. This is often the case for network interfaces, especially wireless network interfaces. Also, modern video chips, from vendors like AMD, NVidia, and Intel when using open source drivers, often need external firmware files. Most of the firmware is packaged in :