centos7多个启动项开机默认启动顺序设置

centos服务器每次重启都会启动最新内核版本,有时候我不希望启动最新的,由于和现在某些软件不兼容,还是想选择旧的版本,下面是如何开机启动你的旧版本内核

1.如果你想要删除最新的版本,很好办

使用:uname -r  查看现在使用的版本,现在这个内核版本也可能不是你想要的,如果你不知道你的内核版本,请重启,选择你想要的内核版本,记住你想要的内核版本,或者进入你所需要的内核版本,然后使用该命令查看

[root@root ~]# uname -r
3.10.0-514.21.2.el7.x86_64   #这个就是你的内核版本号

然后我们需要看我们当前都有哪些内核版本

[root@root ~]# rpm -qa | grep kernel
kernel-tools-libs-3.10.0-514.21.2.el7.x86_64
kernel-tools-3.10.0-514.21.2.el7.x86_64
kernel-3.10.0-514.el7.x86_64   #最老的版本
kernel-3.10.0-514.21.2.el7.x86_64  #现在的版本
kernel-3.10.0-693.11.6.el7.x86_64  #最新的版本,是我想要删除的版本,直接使用yum remove kernel-3.10.0-693.11.6.el7.x86_64
abrt-addon-kerneloops-2.1.11-45.el7.centos.x86_64
abrt-addon-kerneloops-2.1.11-48.el7.centos.x86_64
kernel-headers-3.10.0-693.11.6.el7.x86_64
kernel-headers-3.10.0-514.21.2.el7.x86_64
kernel-tools-libs-3.10.0-693.11.6.el7.x86_64
kernel-tools-3.10.0-693.11.6.el7.x86_64  

然后reboot即可

2.如果还想保留现在的版本

[root@root ~]# find / -name grub.cfg
/boot/grub2/grub.cfg
[root@root ~]# vi /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/10_linux ###  #下面的menuentry是你启动项,从上往下是启动顺序,你可以自己调整
menuentry 'CentOS Linux (3.10.0-693.11.6.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-429ab68a-d2a3-40ea-90b3-368bed7ccb64' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  24b97fca-87b5-4af0-a204-93aaeb7f286c
        else
          search --no-floppy --fs-uuid --set=root 24b97fca-87b5-4af0-a204-93aaeb7f286c
        fi
        linux16 /vmlinuz-3.10.0-693.11.6.el7.x86_64 root=/dev/mapper/cl_nodejs-root ro crashkernel=auto rd.lvm.lv=cl_nodejs/root rd.lvm.lv=cl_nodejs/swap rhgb quiet LANG=en_US.UTF-8
}
menuentry 'CentOS Linux (3.10.0-514.21.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-429ab68a-d2a3-40ea-90b3-368bed7ccb64' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  24b97fca-87b5-4af0-a204-93aaeb7f286c
        else
          search --no-floppy --fs-uuid --set=root 24b97fca-87b5-4af0-a204-93aaeb7f286c
        fi
        linux16 /vmlinuz-3.10.0-514.21.2.el7.x86_64 root=/dev/mapper/cl_nodejs-root ro crashkernel=auto rd.lvm.lv=cl_nodejs/root rd.lvm.lv=cl_nodejs/swap rhgb quiet LANG=en_US.UTF-8
        initrd16 /initramfs-3.10.0-514.21.2.el7.x86_64.img
}
menuentry 'CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-429ab68a-d2a3-40ea-90b3-368bed7ccb64' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  24b97fca-87b5-4af0-a204-93aaeb7f286c
        else
          search --no-floppy --fs-uuid --set=root 24b97fca-87b5-4af0-a204-93aaeb7f286c
        fi
        linux16 /vmlinuz-3.10.0-514.el7.x86_64 root=/dev/mapper/cl_nodejs-root ro crashkernel=auto rd.lvm.lv=cl_nodejs/root rd.lvm.lv=cl_nodejs/swap rhgb quiet LANG=en_US.UTF-8
        initrd16 /initramfs-3.10.0-514.el7.x86_64.img
}
menuentry 'CentOS Linux (0-rescue-353f5985435f32df26dfdb5d4f9bc2a9) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-353f5985435f32df26dfdb5d4f9bc2a9-advanced-429ab68a-d2a3-40ea-90b3-368bed7ccb64' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  24b97fca-87b5-4af0-a204-93aaeb7f286c
        else
          search --no-floppy --fs-uuid --set=root 24b97fca-87b5-4af0-a204-93aaeb7f286c
        fi
        linux16 /vmlinuz-0-rescue-353f5985435f32df26dfdb5d4f9bc2a9 root=/dev/mapper/cl_nodejs-root ro crashkernel=auto rd.lvm.lv=cl_nodejs/root rd.lvm.lv=cl_nodejs/swap rhgb quiet
        initrd16 /initramfs-0-rescue-353f5985435f32df26dfdb5d4f9bc2a9.img
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
上面代码中 menuentry 元素标记是你开机的默认启动项,将你项启动的版本调整一下顺序即可,然后reboot就可以按照你调整的顺序显示了。


猜你喜欢

转载自blog.csdn.net/u014239709/article/details/80790786