内核

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Kernel and the translation is 49% complete.
Outdated translations are marked like this.

内核是操作系统的核心。 内核包含大多数设备驱动器,为程序提供访问系统硬件的接口,例如内存,显卡和块设备。

虽然Gentoo过去提供了不同的内核,但目前仅支持Linux内核。

另请参阅
See also the handbook on installing and setting up a kernel.

我该安装哪一个内核?

Gentoo 提供了多种方法来启动和运行内核,从大多数发行版提供的标准二进制内核到自定义配置和编译的内核。

提示
刚开始时,gentoo-kernel-bin 提供了一种快速、简单的方法来获得一个可以启动和运行的内核,同时仍然提供轻量级、高性能的内核(就像任何现代发行版一样)。 一旦系统安装并正常运行,如果需要,可以选择不同的内核。 sys-kernel/gentoo-kernel-bin 可以保留,以防启动自定义内核时出现问题。

gentoo-sources

当手动编译内核源代码或使用 Genkernel 自动化执行某些过程时,Gentoo 建议大多数用户使用 sys-kernel/gentoo-sources 软件包。 其稳定版本遵循上游 kernel.org 的长期稳定 (LTS) 内核。

Distribution kernels

项目 发行版内核 提供了通过 Portage 安装和管理内核的软件包。 像任何其他软件包一样,这些内核只需使用 emerge 命令即可编译(如果需要编译)并安装,这样可以减轻管理负担。 更新系统时会执行内核更新(即,emerge -avuDN @world),唯一的手动步骤是让引导加载程序(bootloader)使用新内核。

以下内核带有默认配置,应该“适合”大多数系统。 对于对从头开始配置自己的内核不感兴趣的用户,这些内核可以更快地设置好:

gentoo-kernel

sys-kernel/gentoo-kernel 软件包提供了一个在emerge时会被编译和安装的内核。 它带有一份默认配置,应该在大多数系统上开箱即用,但如果需要的话也可以使用自定义配置。

gentoo-kernel-bin

sys-kernel/gentoo-kernel-bin 是一个包含预编译内核的二进制包,可以加快安装速度。 该软件包是 gentoo-kernel 软件包的预编译版本,具有默认配置。

重要
由于 gentoo-kernel* 软件包自动执行配置和编译过程 - 独立于通常的手动编译和安装内核的方式 - 本文的剩余部分将讨论使用 sys-kernel/gentoo-sources 软件包的安装。 有关分发内核的更多信息,请参阅发行版内核项目

安装内核源码

要构建内核,必须先安装内核源码归档。对于桌面系统来说,我们推荐使用 sys-kernel/gentoo-sources。它由 Gentoo 开发者维护,提供修复安全漏洞,功能问题,以及兼容少见的系统架构所需的补丁。

USE flags

USE flags for sys-kernel/gentoo-sources Full sources including the Gentoo patchset for the 6.8 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

安装 sys-kernel/gentoo-sources:

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

可选的其它内核

Portage 中还有许多其他内核包。 有关其中许多内容的详细信息,请参阅内核源码概述内核源概述文章。 有关选择内核的更多帮助,请参阅内核开发人员 Greg Kroah-Hartman 的文章“What Stable Kernel Should I Use?”。

查看所有可选项

所有内核的详细名单和简单的描述都可以通过emerge查询:

root #emerge --search sources

管理内核

配置

Template:Genkernel/zh-cn
genkernel 是一个用来自动化构建内核和initramfs 的工具。在内核构建过程中帮助用户。
手工配置
手工配置使得用户——通过一些努力——可以创建一个定制的内核配置。
Gentoo 内核配置指南
Gentoo内核配置指南。
内核安全
说明内核的安全性
Modules
Modules are object files that contain code to extend the kernel.
Optimization
Descriptions of various optimizations for the kernel.
Command-line parameters
Descriptions of some commonly useful command-line parameters which can be passed to the kernel at boot time for troubleshooting.

升级

升级
通过已有的内核配置升级新内核。

移除

移除
如何移除旧的内核。

故障排除

内核中的配置支持

请查看 IKCONFIG 支持子条目。

内核命令行参数

当从启动引导器启动时,Linux 内核可以接受命令行参数来改变它的行为。这可以帮助在启动时排除内核的故障,将某个不应该加载的模块列入黑名单等。

Kernel.org 有一个格式良好的可用内核命令行参数列表供查看。

参考

  • Linux firmware — 是与 Linux 内核一起发行的软件包,它包含了某些硬件设备部分或全部功能所需固件的二进制 blob
  • LVFS — a daemon that provides a safe, reliable way of applying firmware updates on Linux.
  • Kernel/IKCONFIG support — Enabling In-kernel Config (IKCONFIG) support for the Linux kernel enables the inspection of kernel configuration for running kernels.
  • The kernel category - 在wiki-上的所有与内核相关的文章。
  • The hardware category - 具有相关内核配置的硬件堆栈列表。

外部资源

References