Kernel

From Gentoo Wiki
Jump to:navigation Jump to:search

The kernel is the core of the operating system. Containing most of the device drivers, the kernel offers interfaces for programs to access system hardware such as memory, graphic cards, and block devices.

Though Gentoo has offered different kernels in the past, currently only the Linux kernel is supported.

See also
See also the handbook on installing and setting up a kernel.

Which kernel to install?

Gentoo provides a choice of methods to get a kernel up and running, from a standard binary kernel as would be supplied by most distributions, to custom configured and compiled kernels.

Tip
When starting out, the gentoo-kernel-bin provides a quick and easy way to get a kernel up and running, while still providing a light, high performance kernel - just like any modern distribution would. Once a system is installed and functioning correctly, a different kernel may be selected if needed. The sys-kernel/gentoo-kernel-bin can be kept around in case of issues booting a custom kernel.

gentoo-sources

When manually compiling kernel sources, or using Genkernel to automate some of the process, Gentoo recommends the sys-kernel/gentoo-sources package for most users. Its stable versions follow the long term stable (LTS) kernels from upstream kernel.org.

Distribution kernels

The distribution kernel project provides packages to install and manage kernels through Portage. These kernels are complied (if needed) and installed with just an emerge command, like any other package, which can lessen the administrative burden. Kernel updates are performed when updating the system (i.e. emerge -avuDN @world), and the only manual step is to have the bootloader use the new kernel.

These kernels come with a default configuration that should "just work" for most systems. For users not interested in configuring their own kernel from scratch, these kernels can get things up and running quicker.

See also
For more information on gentoo-kernel see the distribution kernel project.
gentoo-kernel

The sys-kernel/gentoo-kernel package provides a kernel that will be compiled and be installed when the package is emerged. This comes with a default configuration that should work out of the box on most systems, but allows customization, if desired.

gentoo-kernel-bin

The sys-kernel/gentoo-kernel-bin is a binary package containing a precompiled kernel, allowing faster installation. This package is a precompiled version of the gentoo-kernel package, with the default configuration.

Important
Since the gentoo-kernel* packages automate the configuration and compilation process - independently from the usual, manual way of compiling and installing kernels - the rest of this article concerns installation using the sys-kernel/gentoo-sources package. See the distribution kernel project for further information on distribution-kernels

Installation

This section covers installation when using sys-kernel/gentoo-sources.

USE flags

To obtain a kernel, it is necessary to install the kernel source code. The Gentoo recommended kernel sources for a desktop system are, of course, sys-kernel/gentoo-sources. These are maintained by the Gentoo developers, and patched when necessary to fix security vulnerabilities, functional problems, as well as to improve compatibility with rare system architectures.

USE flags for sys-kernel/gentoo-sources Full sources including the Gentoo patchset for the 6.5 kernel tree

build !!internal use only!! DO NOT SET THIS FLAG YOURSELF!, used for creating build images and the first half of bootstrapping [make stage1]
experimental Apply experimental patches; for more information, see "https://wiki.gentoo.org/wiki/Project:Kernel/Experimental".
symlink Force kernel ebuilds to automatically update the /usr/src/linux symlink

Emerge

Now install sys-kernel/gentoo-sources:

root #emerge --ask sys-kernel/gentoo-sources

Alternative kernels

Although all stable kernel Gentoo provides is sys-kernel/gentoo-sources, there are many other kernel packages in the Portage tree. See the Kernel sources overview article, which gives details on most of them.

For which to pick, see also the blog article What Stable Kernel Should I Use? by Greg Kroah-Hartman, a major kernel developer.

Searching all kernel packages

A full list of kernel sources with short descriptions can be found by searching with emerge:

root #emerge --search "%@^sys-kernel/.*sources"

Managing the kernel

Configuration

Automatic configuration
genkernel is a tool used to automate the build process of the kernel and initramfs. The goal of genkernel is to help users through the kernel building process.
Manual configuration
Manual configuration enables the user, with some effort, to create a custom-fit kernel configuration.
Gentoo kernel configuration guide
Gentoo's kernel configuration guide.
Kernel security
Instructions for hardening the kernel.
Managing kernel modules
Kernel modules are object files that contain code to extend the kernel.
Kernel Optimizations
Describes various optimizations for the kernel, like performance.

Upgrade

Upgrade
Steps to upgrade to a new kernel using an existing configuration.

Removal

Removal
Steps to completely remove old kernels.

Troubleshooting

In-kernel configuration support

See the IKCONFIG support sub-article.

Kernel command-line parameters

When booting from a bootloader, the Linux kernel can accept command-line parameters to change its behavior. This can aid in troubleshooting the kernel at boot time, to blacklist a certain module that should not loading, etc.

Kernel.org has a nicely formatted list of available kernel command-line parameters in their admin guide.

Specifically, the following command-line parameters may be helpful when booting Gentoo:

  • earlyprintk=
  • module_blacklist=
  • nomodule
  • loglevel=
  • rootdelay=

See also

  • fwupd — a daemon that provides a safe, reliable way of applying firmware updates on Linux.
  • Genkernel — a tool created by Gentoo used to automate the build process of the kernel and initramfs.
  • Kernel/IKCONFIG support — Enabling In-kernel Config (IKCONFIG) support for the Linux kernel enables the inspection of kernel configuration for running kernels.
  • Kernel/Migrate 2.4 to 2.6 -- Since the Linux kernel codebase has significantly moved past 2.6, these migration steps are no longer relevant, but may be useful for helping administrators understand.
  • Linux firmware — is a package distributed alongside the Linux kernel that contains firmware binary blobs necessary for partial or full functionality of certain hardware devices.
  • Project:Distribution Kernel — aims to maintain sys-kernel/*-kernel packages.
  • The kernel category - All the kernel related articles on the wiki.
  • The hardware category - Lists of hardware stacks with associated kernel configurations.

External resources

References