码迷,mamicode.com
首页 > 系统相关 > 详细

Linux - 修改内核启动顺序及删除无用内核

时间:2017-12-02 00:33:58      阅读:353      评论:0      收藏:0      [点我收藏+]

标签:nsa   summary   set   packages   删除   solution   ras   lan   ase   

现象:
CentOS7开机启动界面显示多个内核选项

原因:
正常情况下,有两个启动项,一个是“正常启动”,另一个是“救援模式启动”(rescue)。
如果启动项多于2个,说明当前系统有旧内核未删除。原因是CentOS更新后不会自动删除旧内核。
默认以新内核启动,可以在启动选项中临时选择,也可以修改配置永久指定。

示例:修改默认启动的内核

[root@CentOS-7 ~]# uname -r   # 查看当前内核版本
3.10.0-693.5.2.el7.x86_64
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# cat /boot/grub2/grub.cfg |grep "menuentry "  # 查看所有可用内核
menuentry ‘CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)‘ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ‘gnulinux-3.10.0-327.el7.x86_64-advanced-88ae7d3d-ffaf-4402-9d44-56b6845789e4‘ {
menuentry ‘CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)‘ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ‘gnulinux-3.10.0-327.el7.x86_64-advanced-88ae7d3d-ffaf-4402-9d44-56b6845789e4‘ {
menuentry ‘CentOS Linux (0-rescue-8405cda22c0b421db40478edcf9c1fb2) 7 (Core)‘ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ‘gnulinux-0-rescue-8405cda22c0b421db40478edcf9c1fb2-advanced-88ae7d3d-ffaf-4402-9d44-56b6845789e4‘ {
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# grub2-set-default ‘CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)‘
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# grub2-editenv list  # 查看内核修改结果
saved_entry=CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
[root@CentOS-7 ~]# 

示例:删除无用内核

[root@CentOS-7 ~]# uname -r   # 查看当前内核版本
3.10.0-693.5.2.el7.x86_64
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# rpm -qa |grep kernel-[0-9]  # 查看全部内核包
kernel-3.10.0-693.5.2.el7.x86_64
kernel-3.10.0-327.el7.x86_64
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# yum remove kernel-3.10.0-327.el7.x86_64  # 删除指定的无用内核
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-327.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                           Arch                              Version                                      Repository                            Size
=============================================================================================================================================================
Removing:
 kernel                            x86_64                            3.10.0-327.el7                               @anaconda                            136 M

Transaction Summary
=============================================================================================================================================================
Remove  1 Package

Installed size: 136 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : kernel-3.10.0-327.el7.x86_64                                                                                                              1/1 
  Verifying  : kernel-3.10.0-327.el7.x86_64                                                                                                              1/1 

Removed:
  kernel.x86_64 0:3.10.0-327.el7                                                                                                                             

Complete!
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# rpm -qa |grep kernel-[0-9]  # 查看全部内核包
kernel-3.10.0-693.5.2.el7.x86_64
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# cat /boot/grub2/grub.cfg |grep "menuentry "
menuentry ‘CentOS Linux (3.10.0-693.5.2.el7.x86_64) 7 (Core)‘ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ‘gnulinux-3.10.0-327.el7.x86_64-advanced-88ae7d3d-ffaf-4402-9d44-56b6845789e4‘ {
menuentry ‘CentOS Linux (0-rescue-8405cda22c0b421db40478edcf9c1fb2) 7 (Core)‘ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ‘gnulinux-0-rescue-8405cda22c0b421db40478edcf9c1fb2-advanced-88ae7d3d-ffaf-4402-9d44-56b6845789e4‘ {
[root@CentOS-7 ~]# 

Linux - 修改内核启动顺序及删除无用内核

标签:nsa   summary   set   packages   删除   solution   ras   lan   ase   

原文地址:http://www.cnblogs.com/anliven/p/7944842.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!