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

现象:

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

原因:

正常情况下,有两个启动项,一个是“正常启动”,另一个是“救援模式启动”(rescue)。

如果启动项多于2个,说明当前系统有旧内核未删除。原因是CentOS更新后不会自动删除旧内核。

默认以新内核启动,可以在启动选项中临时选择,也可以修改配置永久指定。

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

[[email protected] ~]# uname -r   # 查看当前内核版本
3.10.0-693.5.2.el7.x86_64
[[email protected] ~]#
[[email protected] ~]# 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‘ {
[[email protected] ~]#
[[email protected] ~]# grub2-set-default ‘CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)‘
[[email protected] ~]#
[[email protected] ~]# grub2-editenv list  # 查看内核修改结果
saved_entry=CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
[[email protected] ~]# 

示例:删除无用内核

[[email protected] ~]# uname -r   # 查看当前内核版本
3.10.0-693.5.2.el7.x86_64
[[email protected] ~]#
[[email protected] ~]# rpm -qa |grep kernel-[0-9]  # 查看全部内核包
kernel-3.10.0-693.5.2.el7.x86_64
kernel-3.10.0-327.el7.x86_64
[[email protected] ~]#
[[email protected] ~]# 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!
[[email protected] ~]#
[[email protected] ~]# rpm -qa |grep kernel-[0-9]  # 查看全部内核包
kernel-3.10.0-693.5.2.el7.x86_64
[[email protected] ~]#
[[email protected] ~]# 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‘ {
[[email protected] ~]# 
时间: 2024-08-25 21:55:11

Linux - 修改内核启动顺序及删除无用内核的相关文章

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

转自 https://www.cnblogs.com/niyeshiyoumo/p/6762193.html centos7 选定默认启动内核,及删除无用内核 #使用cat /boot/grub2/grub.cfg |grep menuentry 查看系统可用内核 [[email protected]-slave27 ~]# cat /boot/grub2/grub.cfg |grep menuentry if [ x"${feature_menuentry_id}" = xy ];

Windows和linux双系统——修改默认启动顺序

电脑上装了Windows 7和Ubantu双系统,由于Linux系统用的次数比较少并且还是默认的启动项对此很不能容忍,因此得修改Windows为默认的启动项. 由于电脑上的系统引导程序是GRUB,因此修改当然也就落到Linux系统上啦. 修改/boot/grub/grub.cfg该文件中的默认加载启动项(默认自动加载第一个启动项,default="0"),由于该文件比较重要在修改前把他备份了一下(cp /boot/grub/grub.cfg /boot/grub/grub.cfg.ba

修改grub启动顺序

1. 其实就是修改/boot/grub/grub.cfg这个文件,从后缀就看得出这是一个配置文件,虽然linux不区分这后缀,这个后缀是个用户看的. 2. 看了下这个文件,其实我也不理解里面的全部东西,能够理解他的一些语法,但是没能理解他的本意,不过看到后面我既然发现menuentry的顺序就是开机的启动顺序,于是我把这个顺序修改了一下就好了.这样之后就是win7作为第一启动项了,之前我们看到的情况应该是"Ubuntu"在最前面,然后window7在最后面,这样修改后就ok,里面还有背

Linux学习随笔4——Windows和Linux双系统修改默认启动顺序

2015.8.30 本机电脑C盘装有Windows系统,后来因需要安装了个Linux系统,发现默认启动顺序变为Linux了, 因Windows使用比较多,需要将Windows设置为默认启动. 实现方法如下: 1.登入Linux系统 2.输入 cd /etc/boot(本人以root身份登入系统),找到该目录下的menu.lst 3.输入 vi menu.lst default=0  #修改启动顺序 timeout=5  #修改系统供选择的停留时间 数下文本中有几个"title",确认W

查看内核启动顺序 设置默认启动内核

查看内核 uname -r 查看默认启动顺序 awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg CentOS Linux (3.18.3-1.el7.elrepo.x86_64) 7 (Core) CentOS Linux, with Linux 3.10.0-123.el7.x86_64 CentOS Linux, with Linux 0-rescue-893b160e363b4ec7834719a7f06e67cf 默认启

Linux修改开机启动logo

默认开机LOGO会在液晶屏的左上脚显示一只小企鹅,分辨率为80*80,具体在kernel/drivers/video/logo下会有logo_linux_clut224.ppm这幅图像,程序会根据这幅图像生成logo_linux_clut224.c和 logo_linux_clut224.o两个文件,最终将小企鹅显示在液晶屏上. 这里我们需要修改开机画面,而且不限于仅显示80*80,如我们需要显示一幅铺满LCD屏的图像,该怎么办呢? 为了以后还能恢复显示这个小企鹅,这里我们另外再添加一组数据用于

linux bashrc /etc/profile ./profile ./bashrc linux 用户配置文件启动顺序

转:http://www.cnblogs.com/hongzg1982/articles/2101792.html bashrc与profile的区别 要搞清bashrc与profile的区别,首先要弄明白什么是交互式shell和非交互式shell,什么是login shell 和non-login shell. 交互式模式就是shell等待你的输入,并且执行你提交的命令.这种模式被称作交互式是因为shell与用户进行交互.这种模式也是大多数用户非常熟悉的:登录.执行一些命令.签退.当你签退后,

linux的开机启动顺序概述

1 加载BIOS硬件信息, 并获取第一个启动设备的代号;2 读取第一个启动设备的MBR的引导加载程序的启动信息;3 加载核心操作系统的核心信息, 核心开始解压缩, 并且尝试驱动所有的硬件设备;4 核心执行init程序并获取运行信息;5 init执行/etc/init.d的脚本;6 启动核心的外挂模块/etc/modeprobe.d/中的脚本;7 init执行运行各个批处理脚本;8 init执行/etc/init.d/rc.local文件;9 执行/bin/login程序, 等待用户登录;10 登

第3阶段——内核启动分析之make menuconfig内核配置(2)

目标: 分析make menuconfig内核配置过程 在上1小结中(内核编译试验)讲到了3种不同的配置: (1)通过make menuconfig 直接从头到尾配置.config文件 (2) 通过make s3c2410_deconfig 命令在默认的配置上进行自动修改.config文件 (3)使用厂家提供的配置config_ok文件覆盖.config文件 所以,所有的配置结果都是配置.config文件 1 在linux下通过vi指令查看.config内核配置文件 如上图所示:就是一堆配置项: