博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux - 修改内核启动顺序及删除无用内核
阅读量:6827 次
发布时间:2019-06-26

本文共 4047 字,大约阅读时间需要 13 分钟。

现象:

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_64kernel-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, langpacksResolving Dependencies--> Running transaction check---> Package kernel.x86_64 0:3.10.0-327.el7 will be erased--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================= Package                           Arch                              Version                                      Repository                            Size=============================================================================================================================================================Removing: kernel                            x86_64                            3.10.0-327.el7                               @anaconda                            136 MTransaction Summary=============================================================================================================================================================Remove  1 PackageInstalled size: 136 MIs this ok [y/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning 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 ~]#

 

转载于:https://www.cnblogs.com/fuyuteng/p/10824332.html

你可能感兴趣的文章
Node.js中流的使用
查看>>
ES6 常用新特性讲解
查看>>
关于直播几个视频格式的概念总结
查看>>
CentOS 7下安装Tomcat到服务
查看>>
[wireshark]实用技巧整理收集
查看>>
Es6 写的文件import 起来解决方案详解
查看>>
[译] ConstraintLayout基础系列之参照线guidelines
查看>>
JS中可能用得到的全部的排序算法
查看>>
actor ceo ex3ndr 介绍的actor,java,gwt,j2obj的框架体系
查看>>
Mysql 出现the right syntax to use near USING BTREE错误解决办法
查看>>
npm scripts 官方文档(译)
查看>>
C++考题
查看>>
Windows系统下angular2环境搭建
查看>>
PHP - 魔术常量、魔术方法
查看>>
Python技术点
查看>>
es5 操作符运算标准
查看>>
前端技术选型的遗憾和经验教训
查看>>
详解ChinaCache分层自动化测试平台
查看>>
亚马逊发布新的AWS Step Functions集成
查看>>
敏捷2016大会主题演讲:现代敏捷
查看>>