Three ways to update the kernel with Linux

Source: Internet
Author: User

Three ways to upgrade the CentOS kernel



In the process of working on the CentOS platform, it is unavoidable to upgrade or downgrade the kernel to verify functionality, debug performance, or update the entire system. If you recompile a kernel from scratch, because of the complexity of the kernel features now, the number of libraries or tools to rely on, plus the time-consuming recompilation, it is necessary to understand the various ways to update the kernel. The following according to the author's recent work, summed up three ways for everyone to reference.



Method One

If the machine is not networked, you can download the existing kernel package to the local machine and update it locally



1. Download the required rpm from http://ftp.scientificlinux.org/linux/scientific/7.0/x86_64/updates/security/;

2.[[email protected] os2]# scp[email protected]:/home/worker/kernel-3.10.0-123.1.2.el7.x86_64.rpm.

[Email protected] ' Spassword:

kernel-3.10.0-123.1.2.el7.x86_64.rpm 100% 29MB 28.9mb/s 00:00

[Email protected]os2]# man Yum

[Email protected]os2]# yum Install kernel-3.10.0-123.1.2.el7.x86_64.rpm

Loadedplugins:fastestmirror, LangPacks

Examiningkernel-3.10.0-123.1.2.el7.x86_64.rpm:kernel-3.10.0-123.1.2.el7.x86_64

MARKINGKERNEL-3.10.0-123.1.2.EL7.X86_64.RPM to be installed

Resolvingdependencies

-->running transaction Check

--->package kernel.x86_64 0:3.10.0-123.1.2.el7 'll be installed

-->finished Dependency Resolution

Epel/x86_64/metalink |5.2 KB 00:00:00

epel/x86_64 | 4.3 KB 00:00:01

Epel/x86_64/updateinfo |517 KB 00:00:01

epel/x86_64/primary_db |4.0 MB 00:02:36



Dependenciesresolved



=============================================================================================================== =

Package Arch Version Repository Size

=============================================================================================================== =

Installing:

Kernel x86_64 3.10.0-123.1.2.el7/kernel-3.10.0-123.1.2.el7.x86_64 127 M



Transactionsummary

=============================================================================================================== =

Install 1 Package



totalsize:127 M

installedsize:127 M

Isthis OK [y/d/n]: Y

Downloadingpackages:

Runningtransaction Check

Runningtransaction Test

Transactiontest succeeded

Runningtransaction

Installing:kernel-3.10.0-123.1.2.el7.x86_64 1/1



Verifying:kernel-3.10.0-123.1.2.el7.x86_64 1/1



Installed:

Kernel.x86_640:3.10.0-123.1.2.el7



complete!



Method Two

If the machine is already networked, directly with the Package management tool update, it should be noted that more than 3.0 of the kernel introduced a signature mechanism, the need to import the signed key, the reference steps are as follows:



1. Import Key
Rpm--import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

Of course, if you have modified the repo gpgcheck=0, you can not import the key
2, installation of Elrepo Yum source

RPM-UVH http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

3. Install the kernel
In the Elrepo source of Yum, there are mainline promulgated, which can be installed as follows:
Yum--enablerepo=elrepo-kernel Install Kernel-ml-develkernel-ml-y

Of course, you can also install longterm:

Yum--enablerepo=elrepo-kernelinstallkernel-lt-y



Method Three

The actual work often encountered the need to modify the kernel configuration, compile drivers, adjust the relevant parameters, etc., this requires a custom kernel, for this need to manually generate a new kernel. Or take 3.10.0-123.el7 as an example, the general steps are as follows:



1. Download the kernel First:

wget http://vault.centos.org//7.0.1406/os/Source/SPackages/kernel-3.10.0-123.el7.src.rpm

Then unzip the relevant code:

rpm2cpiokernel-3.10.0-123.el7.src.rpm |cpio-div

By default, there is a kernel header file in/usr/src, so that you can compile your own kernel modules without having to download the entire kernel source code, and if you have patches to play, use the PATCH-P1 *.patch command to patch the kernel accordingly.



2. Update the configuration file. config

You can get the current config file for your system, or you can use the default configuration file, such as X86_64_defconfig:

cp/boot/config-3.10.0-123.el7.x86_64. config and makeoldconfig production of config consistent

Then use Makemenuconfig to configure.



3. Compiling and installing

By default, the kernel and INITRD will be installed under/boot, and the driver module will be installed under/lib/modules/' Uname-r, and if you can install the default location, run the following command directly:

Make-j8;make modules; Make Modules_install;make install;

If you need to install to the path you specify, set the following environment variables:

Exportinstall_path= ....

Exportinstall_mod_path=



4. Create Initrd.img

Initrd.img is the initialized RAMDisk file, which is a memory image file. It is a package of some of the most basic drivers and command tools, the role is to ensure that the system does not mount the root partition before the system can perform basic initialization and load some basic drivers, such as Mount SCSI driver. The traditional way of making initrd is to use MKINITRAMFS as a system tool, and now MKINITRD will call Dracut to do the actual work. For example, the following command is performed:



Mkinitrd3.0.4-o/boot/initrd.img-3.0.4

Then copy the resulting INITRD image to/boot below.



5. Update Grub

In order for bootloader to be able to find the kernel and INITRD images that were just generated, grub needs to be modified. Note If you are using GRUB2, it is not appropriate to modify the/boot/grub2/grub.cfg file directly, but you should modify the GRUB2 configuration file. GRUB2 The default configuration file in/etc/grub2.cfg. After updating this file, you need to run the following file:

Grub2-mkconfig

As for starting that Linux image, it is up to/etc/default/grub's grub_default=saved to decide;

It means the value that was last used;

To modify the kernel default boot entry

Grub2-set-default0



This approach requires attention to kernel and module signature issues, and if the module signature is not checked through the kernel, it will not be loaded, which may cause the build system to fail to start.



In summary, engineers and maintenance personnel need to assemble the actual situation flexibly choose the appropriate method to update the kernel.

This article is from the "Store Chef" blog, so be sure to keep this source http://xiamachao.blog.51cto.com/10580956/1755354

Three ways to update the kernel with Linux

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.