Handbook:Parts/Installation/Kernel/zh-cn

安装源码
Linux内核是所有发行版的核心. 它位于用户程序和系统硬件之间. Gentoo提供给用户一些可选的内核源码. 完整的带描述的列表在内核概述页面.

针对基于系统的Gentoo，建议使用包.

选择一个合适的内核并使用来安装它.

这将在中安装Linux内核源码，并有一个符号连接叫作将指向安装的内核源码：

现在是时候来配置和编译内核源代码了. 有两种方法：


 * 1) 手动配置并生成内核.
 * 2) 一个叫作的工具用来自动化生成并安装Linux内核.

我们在这里解释做为默认选择的手动配置，它是优化环境的最好方式.

介绍
手动配置内核经常被Linux用户认为是最困难的步骤. 事实并非如此——但是当您手动配置几次内核之后，你就不会再觉得它有多么难了：）

无论如何，有一件事是真实的：当手动配置内核时，了解（硬件）系统是至关重要的. 大多数信息可以通过安装包含命令的来收集：

另一个系统信息来源是运行来查看安装CD使用什么内核模块，它可能对启用什么提供了一个好的暗示.

现在进入内核源码目录并执行. 这将启动一个菜单驱动的配置屏幕.

Linux内核配置有很多很多的章节. 我们先列出一些必须激活的选项（否则Gentoo将无法工作，或者离开附加的调整将无法正常工作）. 我们同时在Gentoo维基上有一个Gentoo内核配置指南可能会在将来有帮助.

激活必要的选项
确保引导系统的每一个至关重要的驱动（比如SCSI控制器……）是编译进内核而不是作为一个模块，否则系统将无法完全引导.

接下来选择最控制的CPU类型. 同时建议启用MCE功能（如果可用）能在硬件出现问题时通知用户. 在一些架构（比如x86_64），这些错误不会打印到dmesg，但是会到. 这需要包.

同时选择Maintain a devtmpfs file system to mount at /dev来让重要的设备文件在引导过程的早期就已就绪.

现在进入File Systems并选择你使用的文件系统. 不要作为模块来编译根文件系统所使用的文件系统，否则Gentoo系统将不能挂载这个分区. 同时选择Virtual memory和/proc file system.

如果使用PPPoE连接到互联网，或者使用一个拨号调制解调器，则启用下面的选项：

这两个压缩选项将是无害的，但是它们一定是不需要的，包括基于以太网的PPP选项也是一样，只有在配置内核模式PPPoE时才会需要.

不要忘记在内核中包括网（以太网或无线）卡.

大多数系统会有多核心处理，所以激活Symmetric multi-processing support是重要的：

如果使用USB输入设备（比如键盘和鼠标），不要忘记启用那些：

可选：生成一个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.

如果没有initramfs的，存在着巨大的风险，系统将无法正常开机，因为这是负责安装的文件系统工具需要驻留在这些文件系统的信息. initramfs中的一个将在必要的文件拉进它的内核启动之后使用的档案，但控制被移交前转移到初始化工具. 在initramfs的脚本，然后将确保分区正确地安装在系统继续启动之前.

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 we enables support for LVM and software raid (mdadm):

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

现在继续到内核模块.

备选：使用genkernel
If a manual configuration looks too daunting, then using is recommended. It will configure and build the kernel automatically.

works by configuring a kernel nearly identically to the way the installation CD kernel is configured. This means that when is used to build the kernel, the system will generally detect all  hardware at boot-time, just like the installation CD does. Because 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 ebuild:

Next, edit the file so that the line containing  as second field has the first field pointing to the right device. If the partitioning example from the handbook is followed, then this device is most likely with the ext2 file system. This would make the entry in the file look like so:

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

Once genkernel completes, a kernel, full set of modules and initial ram disk (initramfs) 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 this information is used when the boot loader configuration file is edited. The initrd will be started immediately after booting to perform hardware autodetection (just like on the installation CD) before the "real" system starts up.

配置模块
List the modules that need to be loaded automatically in. Extra options can be added to the modules too if necessary.

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.

Continue the installation with Configuring the system.

可选：安装固件
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. Most of the firmware is packaged in :