Kernel/Upgrade/zh-cn

这篇文章描述了升级到新内核步骤.

安装
当系统更新后安装了新的内核源代码，或者你自己安装了新的内核源代码，升级内核是必要的.

Installing new kernel sources doesn't provide the user with a new kernel. It is necessary to make and install a new kernel from the new sources and then reboot the system to actually run the new kernel.

Making a new kernel from the new sources is basically the same process as making a kernel when installing the system. The difference is that one can use the configuration of the old kernel to create a configuration for the new kernel. Using the old configuration saves the user from going through all the kernel options (like make menuconfig) again.

The configuration of the kernel is saved in a file named in the directory that holds the kernel sources. A new kernel may have options or features the old kernel does not have, or it might not have a feature or option anymore which the old kernel still has. The kernel configuration specifies whether the features and options of a kernel are to be enabled or not, perhaps built into the kernel, or perhaps built as modules which can be loaded into the running kernel on demand. Hence the configuration file of the new kernel may have new entries the configuration file of the old kernel doesn't have, and it might not have entries anymore which are present in the configuration file of the old kernel.

To deal with such changes of the configuration file, the configuration file of the old kernel needs to be converted to a configuration that can be used with the new kernel. This article shows how to make a new kernel from new kernel sources with converting the configuration file of the old kernel.

Make a backup of the current kernel configuration
It is wise to make a backup of the kernel configuration so that the previous configurations are not lost. After all, many users devote considerable time to figure out the best configuration for the system, and losing that information is definitely not wanted.

It is easy to make a backup of the current kernel configuration:

Provided that the symlink to the kernel sources has been set correctly, this copies the configuration of the currently used kernel to the home directory of root, renaming the configuration to followed by the version of the current running Linux kernel.

Set symlink to new kernel sources
符号链接 应该总是指向正在运行的内核的源代码. 有三种方法实现这一点：


 * 1) Installing the kernel sources with
 * 2) Setting the link with eselect
 * 3) Manually updating the symbolic link

Installing the kernel sources with the symlink USE flag
This will make the point to the newly installed kernel sources.

If necessary, it can still be modified later with one of the other two methods.

Setting the link with eselect
To set the symlink with eselect:

This outputs the available kernel sources. The asterisk indicates the chosen sources.

To change the kernel sources, e.g. to the second entry, do:

Manually updating the symbolic link
To set the symbolic link manually:

Copy previous kernel configuration
The configuration of the old kernel needs to be copied to the new one. It can be found in several places:


 * 如果在当前内核中选项Enable access to .config through /proc/config.gz是激活的，配置文件在procfs 文件系统：


 * 目录,如果你把配置文件安装到了这里:


 * 当前运行的内核的源代码目录：

Configure the new kernel
To use the configuration of the old kernel with the new kernel, it needs to be converted. The conversion can be done by running either make oldconfig or make silentoldconfig.

make oldconfig gives many choices, make silentoldconfig does not. Use either, not both.

make oldconfig
The following configuration is like the text based configuration with make config. For new configuration options, it gives a choice. For example:

The string (NEW) at the end of the line marks this option as new. Left to the string in square brackets are the possible answers: Yes, no, module or ? to show the help. The recommend answer is capitalized (here Y). The help explains the option or driver.

Unfortunately make oldconfig doesn't show - next to the help - a lot more information for each option, like the context, so that it is sometimes difficult to give the right answer. In this case the best way to go is to remember the option name and revise it afterwards through one of the graphical kernel configuration tools.

make silentoldconfig
If interactivity is not wanted (no questions should be asked), then use make silentoldconfig</tt>:

编译
这一步请参考 manual configuration.

重新安装外部内核模块
任何外部的内核模块，像 binary kernel modules, 需要为新的内核重新编译. 如果新内核还没有编译，需要首先为编译外部内核模块做准备：

你可以使用"@module-rebuild"命令重新编译包：

Solving build problems
如果你在重新编译当前内核的时候遇到问题，这也许有助于净化内核. 确保你首先备份了文件，因为操作过程会删除它. 确保备份文件不要以 或者 为后缀，因为 同样会删除这些文件.

删除旧内核
参考 kernel removal.

外部资源

 * kernel changelog with some explanations of new features