Kernel/Upgrade

This article describes the steps to upgrade to a new kernel.

Installation
A kernel upgrade is necessary when new kernel sources are installed after a system update or when you yourself installs new kernel sources.

Configuration
The configuration parallels that of the manual configuration, since only the config file is reused. All steps are mentioned here again for the sake of completeness, for a more verbose explanation see the other article.

Set symlink
First set the /usr/src/linux symlink, so it points to the new kernel sources. This can be done in one of three ways:


 * 1. Installing the kernel sources with active symlink USE flag
 * This will make the /usr/src/linux point to your newly installed kernel sources. If necessary, it can still be modified later with the following two methods:


 * 2. Setting 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:




 * 3. Setting the symlink manually:



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


 * In the procfs filesystem, if the kernel option Kernel .config support was activated in your present kernel:




 * In the /boot directory, if you installed the config file there:




 * In the kernel directory of the currently-running kernel:



make oldconfig
Now update the previous config file for your new kernel:

The following configuration parallels that of the text based configuration with make config. For every difference between the kernel versions, it asks if you want to activate the driver or feature. An 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

Reinstall external kernel modules
Any external kernel modules, such as VirtualBox modules, or the proprietary graphics drivers (nvidia and fglrx), need to be rebuilt for each new kernel. If the kernel hasn't been built yet, it has to first be prepared for the building of the external kernel modules:

Using stable portage
The packages can be reinstalled manually, or with the help of the tool :

After the installation, let module-rebuild search for external kernel modules and add it to its list:

module-rebuild stores this list, so this step is only necessary after installing or removing new external kernel modules.

The following command reinstalls the external kernel modules then:

Using portage-2.2
You can rebuild the packages using the @module-rebuild set in portage-2.2:

Build
For this step, follow the steps in the manual configuration article.

Protecting the new kernel sources
If you run --depclean frequently to clean out unused dependencies, it may remove the sources for the currently running kernel if a newer version has been merged. These sources may be needed in the future for updating external kernel modules as mentioned above, plus it's just generally a good idea to keep the sources for your currently running kernel. It's therefore good practice to add the specific kernel version to your world file to protect it from --depclean operations.

There are two ways to do this:

Using emerge
Note the slot notation, using a colon instead of a dash. Every kernel version is its own slot.

This will add the specific kernel version to the world file:

Edit the world file directly
This method will also let you to remove old kernel versions you no longer use, allowing --depclean to remove the sources. In this example, the first line would be replaced by the second line:

Removing old kernels
See the kernel removal article.

Links

 * kernel changelog with some explanations of new features