Gentoo Linux Kernel update guide __linux

Source: Internet
Author: User
Tags symlink

Original website: http://www.gentoo.org/doc/zh_cn/kernel-upgrade.xml


1. Introduction

The kernel is one of the few packages in the portage tree that requires partial human intervention to complete the update. Portage will download and install the kernel source code for you, but it will require you to manually compile the new kernel in order for the changes to take effect.

This guide is about how to update from one kernel version to another, but it is also useful for users who want to switch to another kernel package.

This article uses gentoo-sources as an example, however, the operation here applies to the other kernel packages in our tree.

2. Why update the kernel.

In general, small kernel version updates do not make a big difference. There are several reasons to update the kernel, including using the latest drivers or some of the latest features to protect them from security vulnerabilities, or simply to keep the system in the latest and healthy state.

Even if you choose not to update every new kernel version, we also recommend that you update to the latest kernel at a time. When the new kernel resolves a security issue, it is strongly recommended that you update to this version.

3. Get the new kernel through portage

Update kernel source code and update other packages like this: Use the Emerge tool. When you see a new kernel version in the World Update list, you may want to do a kernel update. For example:

Code 3.1: The new kernel source list is now updated

# emerge-dup World
Calculating dependencies ... done!
[Ebuild    NS] SYS-KERNEL/GENTOO-SOURCES-2.6.9-R2 [2.6.8-R5]

Note: the "NS" flag in the above output means that the new kernel will be installed into the new slot, meaning that the old kernel source will remain until you manually remove it.

You can go ahead and perform the update, for example:

Code 3.2: Update your kernel source

# Emerge-u Gentoo-sources

The kernel source is then installed into a subdirectory of the/USR/SRC. For the above example, the new kernel source code will be installed in/USR/SRC/LINUX-2.6.9-GENTOO-R2.

4. Update/usr/src/linux Symbolic link

Gentoo requires the symbolic link/usr/src/linux to point to the source code of the running kernel.

When you emerge new kernel source code, portage can automatically update this link. What you need to do is add the SYMLINK flag to the use variable in/etc/make.conf.

Code 4.1: Example of a use variable in/etc/make.conf

(add keyword symlink)
use= "symlink x86 3dnow 3dnowex X AAC aalib adns Alsa"

You can also choose to use App-admin/eselect to modify the symbolic link.

Code 4.2: Manage Symbolic links with Eselect

(if not yet installed Eslect)
# emerge Eselect
(view list of available kernels)
# eselect kernel list
Available kernel the symlink targets:
  [1]   linux-2.6.9-gentoo-r1
  [2]   linux-2.6.9-gentoo-r2
(select the correct kernel)
# Eselect Kernel set 1

If you really want to do it yourself, the following example shows how to point the link to linux-2.6.9-gentoo-r2:

Code 4.3: Manually update the/usr/src/linux symbolic link

# cd/usr/src
# LN-SFN LINUX-2.6.9-GENTOO-R2 Linux

5. Configure, compile, and install a new kernel

For each of the following ways, you should refer to the instructions in the Gentoo manual for configuring the kernel and configuring the bootstrapper. The following is an overview of the required actions:

Mode one: Automatically set the kernel with Genkernel

If you are a genkernel user, you just need to repeat the steps you made the first time you installed the kernel.

Normal operation Genkernel on the line:

Code 5.1: Running Genkernel

# Genkernel All

With additional parameters, you can use the other features of Genkernel. For example, if you want to configure additional kernel options with Menuconfig and automatically update the Grub bootstrapper configuration, you can start the Genkernel as follows:

Code 5.2: Attach common parameters when running Genkernel

# Genkernel--menuconfig--bootloader=grub All

For more information, refer to the Gentoo Linux Genkernel Guide, or refer to the Gentoo manual. Many options can be specified in the Genkernel configuration file/etc/genkernel.conf.

Mode two: manual configuration

First, use the Menuconfig tool in the Kernel code tree:

Code 5.3: Running Menuconfig

# cd/usr/src/linux
# make Menuconfig

Please select the options you need for your hardware and operating environment. For more information on kernel configuration, see the chapter in the Gentoo manual titled Configuring the Kernel.

Next, compile your kernel and copy it to the boot partition. Also, refer to the steps listed in the Gentoo Manual for configuring the bootstrapper chapter. If the/boot is a separate partition, verify that it is mounted before copying the compiled kernel. Otherwise, you will not be able to start the system running the new kernel.

Code 5.4: Compiling and installing a new kernel

# make && make Modules_install
# mount/boot
CP ARCH/I386/BOOT/BZIMAGE/BOOT/BZIMAGE-2.6.9-GENTOO-R2

Finally, you should update the bootstrapper configuration file to add new kernel entries (do not delete the old ones first.) ), and then uninstall the/boot partition. Also, refer to the Gentoo manual for more detailed instructions on this process.

6. Reinstall the External module

If you use kernel modules that are not included in the kernel code tree, but are provided by other parts of the portage (such as the ALSA driver, and Nvidia or ATI display drivers), then you will need to reinstall these modules after you update the kernel. It's simple, just re-emerge the packages involved. For more information, refer to the chapter on configuring the kernel in the Gentoo manual.

We provide you with a simple tool (Sys-kernel/module-rebuild) that will recompile all the standalone (ebuild) kernel modules you have installed (with the/usr/src/linux kernel). It's very intuitive to use. After installation, run Module-rebuild populate build a database that contains a list of all the packages that need to be recompiled after the kernel has been updated. After you complete the update and recompile the kernel, run Module-rebuild rebuild recompile the driver for the new kernel.

For more information, run Module-rebuild with no parameters, which displays a list of supported commands.

7. Reboot to the new kernel

Next, close all applications and reboot the system. If the steps above do not do anything wrong, the new kernel entry will appear in the Bootstrapper menu. Select the new kernel and start the system.

If all goes well, the new kernel starts successfully and you can continue working after you log in. In this case, the update is announced.

If you make a mistake and the new kernel fails to start, reboot the system and select the kernel that was last able to run in the bootstrapper. You can then reconfigure, compile, and install the new kernel to make appropriate corrections to the error. In some cases, you can do this without even rebooting, such as a sound card driver, a NIC driver, and so on.

8. Running multiple cores

You may have noticed that the source code for the existing kernel was not removed when the source code for the new kernel was installed. This is intentional, so you can easily switch between running different cores.

Switching between multiple cores is simple. All you need to do is keep the kernel source code in the/usr/src/and keep the binaries in the/boot partition Bzimage, which corresponds to one of the bootstrapper configurations. Each time you start, you have the opportunity to choose which kernel to boot to.

9. Delete the old kernel

In the last section, you may be satisfied with the new kernel and no longer need to keep the old kernel. To remove other versions of the kernel source other than the latest kernel, you can take advantage of the prune option in emerge. Here is an example for gentoo-sources:

Code 9.1: Delete the old version

# emerge-p Gentoo-sources

In general, temporary files generated during compilation will still remain in the corresponding directory under/USR/SRC. You can safely delete these files with RM.

You can also safely remove all modules used by the old kernel. This can be done by removing the subdirectory corresponding to the deleted kernel version in the/lib/modules/directory. Be careful not to delete the modules of the kernel that are still in use.

Finally, you can mount the/boot partition and delete the Bzimage file for the kernel you just unloaded. You should also edit the configuration of the bootstrapper to delete the items that correspond to the unloaded kernel.

10. Advanced: Configure the new kernel with your old. config file

Sometimes, the configuration files that reuse the old kernel when configuring a new kernel can save time. It should be noted that this is generally not safe--each version update brings a lot of change, making this update path unreliable.

The only occasion for this approach is to upgrade from one Gentoo kernel revision to another. For example, changes from GENTOO-SOURCES-2.6.9-R1 to GENTOO-SOURCES-2.6.9-R2 are very small, so you can generally use the following methods. However, this method does not apply to the example that has been used in this article, that is, the update from 2.6.8 to 2.6.9. There are too many changes between the official releases, and the method described below does not prompt the user enough information, which often causes the user to have problems with disabling options that they do not want to disable.

Using your old. config file, just copy it over and run make oldconfig. In the following example, we use the GENTOO-SOURCES-2.6.9-R1 configuration file and are used in GENTOO-SOURCES-2.6.9-R2.

Code 10.1: Reusing Old configurations

# CD/USR/SRC/LINUX-2.6.9-GENTOO-R2
# CP. /linux-2.6.9-gentoo-r1/.config.
# Make Oldconfig

Code 10.2: Reusing the old configuration for Genkernel

# cd/etc/kernels #
CP kernel-config-x86-2.6.9-gentoo-r1 KERNEL-CONFIG-X86-2.6.9-GENTOO-R2
# Genkernel All

At this point, you need to answer a number of questions to determine which configuration options to change between two versions. When you are done, you can compile and install the kernel normally without having to menuconfig the configuration process.

A more secure approach is to copy your profile in the same way, and then run make menuconfig. This can be a problem with the make oldconfig mentioned above because make menuconfig displays as much of the old configuration file as possible in the menu. All you need to do now is browse through each menu, look for new options, delete options, and more. By using Menuconfig, you can learn about all the changes and make it easier to view new choices and learn about help. You can even use this method to perform updates such as 2.6.8 to 2.6.9, just to make sure you look at each option carefully. When finished, the kernel is compiled and installed normally.

11. The problem occurs after the kernel is updated.

The Linux kernel is developing rapidly, and changes in version updates may cause problems that cannot be avoided. If you find something in the latest version of the Gentoo supported kernel, please report it to us.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.