问题现象

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 - 修改内核启动顺序及删除无用内核的更多相关文章

  1. centos 修改默认启动内核,及删除无用内核

    #使用cat /boot/grub2/grub.cfg |grep menuentry 查看系统可用内核 [root@bigapp-slave27 ~]# cat /boot/grub2/grub.c ...

  2. 修改linux内核启动顺序

    修改linux内核启动顺序 # 修改内核启动顺序x86_64 centos:cat /boot/grub2/grub.cfg |grep "menuentry" grub2-set ...

  3. centos7 选定默认启动内核,及删除无用内核

    #使用cat /boot/grub2/grub.cfg |grep menuentry 查看系统可用内核 [root@bigapp-slave27 ~]# cat /boot/grub2/grub.c ...

  4. CentOS7修改内核启动顺序

    CentOS7修改内核启动顺序: 1.首先查看当前系统有几个内核 cat /boot/grub2/grub.cfg |grep menuentry   2.查看当前默认内核 grub2-editenv ...

  5. linux服务开机启动顺序

    今天遇到了一个问题,我们写了一个服务脚本A,该服务需要优先于mysql启动.脚本是从其他地方拷来的模板,前面的默认配置没改,只是实现了自己的功能.写完,chkconfig A on,reboot,启动 ...

  6. Centos7 内核升级及删除无用内核

    导入key rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 安装elrepo的yum源 rpm -Uvh http://www.e ...

  7. centos7 设置内核启动顺序

    1.查看设备上安装了几个内核 cat /boot/grub2/grub.cfg |grep menuentry 2.查看当前内核 grub2-editenv list saved_entry=Cent ...

  8. CentOS7设置内核启动顺序

    1.查看设备上安装了几个内核 cat /boot/grub2/grub.cfg |grep menuentry 2.查看当前内核 grub2-editenv list saved_entry=Cent ...

  9. ubuntu的boot分区报警,删除无用内核文件。

    1. 查看当前使用内核:uname -r4.4.0-97-generic 2. 查看安装的内核dpkg --list 'linux-image*' 3. 删除旧内核sudo apt-get remov ...

随机推荐

  1. JavaScript资源网址

    JavaScript 全栈工程师培训教程 http://www.ruanyifeng.com/blog/2016/11/javascript.html

  2. [剑指Offer]8-二叉树的下一个节点

    链接 https://www.nowcoder.com/practice/9023a0c988684a53960365b889ceaf5e?tpId=13&tqId=11210&tPa ...

  3. 426. Convert Binary Search Tree to Sorted Doubly Linked List把bst变成双向链表

    [抄题]: Convert a BST to a sorted circular doubly-linked list in-place. Think of the left and right po ...

  4. ios tableView的header高度不对

    tableView的header高度不对,一般都是header是从xib加载出来的 第一步: 新建xib的时候选择的是View,当选择 Size 为 Freeform 时,view的约束就变成这样了, ...

  5. node.js中stream流中可读流和可写流的使用

    node.js中的流 stream 是处理流式数据的抽象接口.node.js 提供了很多流对象,像http中的request和response,和 process.stdout 都是流的实例. 流可以 ...

  6. django.template.exceptions.TemplateDoesNotExist: rest_framework/api.html

    django.template.exceptions.TemplateDoesNotExist: rest_framework/api.html setting文件中的 INSTALLED_APPS加 ...

  7. for循环,列表,元组

    依旧是python基础 for循环 s = 'woeudbwieb' for i in s:#s代表可迭代对象 print(i) if 'c' not in s: print('没有c') 列表 每个 ...

  8. Golang中的三个点

    之前提到了把一个切片追加到另外一个切片时使用到了... 今天我们好好研究一下这三个点,博客写着写着又成了,回字有四种写法 ...第一种用法,可变长的参数 package main import &qu ...

  9. day 6 元组、字典、字符串

    本节内容 : 1,元组 2,字典 3,字符串作业 produce = [('mac', 9000), ('bicycle', 800), ('computer', 8000), ('book', 50 ...

  10. 关于双重for循环封装数据问题

    1.问题描述 在使用双重for循环进行封装数据时出现一个问题,就是有的数据封装上了,有的数据未封装上,找了很久原因: for (A a:ListA) { for (B b: ListB) { if(a ...