升级内核linux

 

随着新设备和技术的不断涌现,如果我们想充分利用它们,保持内核的最新很重要。此外,更新内核将帮助我们利用新的内核函数,并保护自己免受以前版本中发现的漏洞的影响。

准备更新CCENS 7上的内核或它们的衍生物之一,比如RHEL 7和FEDORA?如果是这样,继续阅读

注意 :必须在本地升级不能再远程升级不然没效果。本地必须可以登陆、

Step 1: Checking Installed Kernel Version

When we install a distribution it includes a certain version of the Linux kernel. To show the current version installed on our system we can do:
# uname -sr
The following image shows the output of the above command in a CentOS 7 server:
Check Kernel Version in CentOS 7
If we now go to https://www.kernel.org/, we will see that the latest kernel version is 4.17 at the time of this writing (other versions are available from the same site).
This new Kernel 4.17 version is a long-term release and will be supported for 6 years, earlier all Linux Kernel versions were supported for 2 years only.
One important thing to consider is the life cycle of a kernel version – if the version you are currently using is approaching its end of life, no more bug fixes will be provided after that date. For more info, refer to the kernel Releases page.

Step 2: Upgrading Kernel in CentOS 7

Most modern distributions provide a way to upgrade the kernel using a package management system such as yum and an officially-supported repository.
Important: If you looking to run custom compiled Kernel, then you should read our article that explains How to Compile Linux Kernel on CentOS 7 from sources.
However, this will only perform the upgrade to the most recent version available from the distribution’s repositories – not the latest one available in the https://www.kernel.org/. Unfortunately, Red Hat only allows to upgrade the kernel using the former option.
As opposed to Red Hat, CentOS allows the use of ELRepo, a third-party repository that makes the upgrade to a recent version a kernel.
To enable the ELRepo repository on CentOS 7, do:
Enable ELRepo in CentOS 7
Once the repository has been enabled, you can use the following command to list the available kernel.relatedpackages:
# yum –disablerepo=”*” –enablerepo=”elrepo-kernel” list available 
Yum – Find Available Kernel Versions
Next, install the latest mainline stable kernel:
# yum –enablerepo=elrepo-kernel install kernel-ml 
Install Latest Kernel Version in CentOS 7
Finally, reboot your machine to apply the latest kernel, and then select latest kernel from the menu as shown. 
Select Latest Kernel Version
Login as root, and run following command to check the kernel version:
# uname -sr 
Verify Kernel Version

Step 3: Set Default Kernel Version in GRUB

To make the newly-installed version the default boot option, you will have to modify the GRUB configuration as follows:
Open and edit the file /etc/default/grub and set GRUB_DEFAULT=0. This means that the first kernel in the GRUB initial screen will be used as default.
GRUB_TIMEOUT=5
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT=”console”
GRUB_CMDLINE_LINUX=”rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet”
GRUB_DISABLE_RECOVERY=”true”
Next, run the following command to recreate the kernel configuration.
# grub2-mkconfig -o /boot/grub2/grub.cfg 
Set Default Kernel Version in Grub
Reboot and verify that the latest kernel is now being used by default. 
Booting Default Kernel Version in CentOS 7
Congratulations! You have upgraded your kernel in CentOS 7!
Summary
In this article we have explained how to easily upgrade the Linux kernel on your system. There is yet another method which we haven’t covered as it involves compiling the kernel from source, which would deserve an entire book and is not recommended on production systems.
Although it represents one of the best learning experiences and allows for a fine-grained configuration of the kernel, you may render your system unusable and may have to reinstall it from scratch.
If you are still interested in building the kernel as a learning experience, you will find instructions on how to do it at the Kernel Newbies page.
As always, feel free to use the form below if you have any questions or comments about this article.

如果有不懂的地方请留言,SKY8G网站编辑者专注于研究IT源代码研究与开发。希望你下次光临,你的认可和留言是对我们最大的支持,谢谢!

上一篇: CSS3制作动画的方法

下一篇: apache的用处

登录 评论
avatar