• Linux


    问题现象

    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 ~]# 
    
  • 相关阅读:
    三角函数都快忘光了
    Windows 10 LTSC 2019(1809) WSL 安装 CentOS 7
    随手写了个京东发票助手
    ASP 封装基本身份认证( HTTP Basic Authenticate)辅助类
    WebBrowser中打开新页面
    将QT窗口嵌入到WinForm窗口
    [摘录]如何按需前端显示指定的窗口
    实现TabControl 选项卡首个标签缩进的方法
    玩转时间操作
    Java 并发包中的高级同步工具
  • 原文地址:https://www.cnblogs.com/anliven/p/7944842.html
Copyright © 2020-2023  润新知