Linux CentOS 7.X 如何修改内核启动默认顺序

我们知道,centos 6.x是通过/etc/grub.conf就行内核启动顺序修改的,而且比较直观查看。但centos 7的系统和6就不一样了,是通过grub2为引导程序。下边简单说下centos 7的内核启动顺序如何修改。
1,首先查看当前系统有几个内核。比如:

[root@ ~]# cat /boot/grub2/grub.cfg |grep menuentry

if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (4.14.173-bbrplus) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.14.173-bbrplus-advanced-a77960f7-92f9-4d5c-84f0-80ec42f6c91e' {
menuentry 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-a77960f7-92f9-4d5c-84f0-80ec42f6c91e' {
menuentry 'CentOS Linux (0-rescue-fee00637de034df18da9e4815fff2aed) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-fee00637de034df18da9e4815fff2aed-advanced-a77960f7-92f9-4d5c-84f0-80ec42f6c91e' {

2,设置默认的启动内核。比如我们选择上边中的'CentOS Linux (4.14.173-bbrplus) 7 (Core)'这个内核为默认启动。

[root@ ~]# grub2-set-default 'CentOS Linux (4.14.173-bbrplus) 7 (Core)' 配置默认内核
验证是否修改成功:

[root@ ~]# grub2-editenv list
saved_entry=CentOS Linux (4.14.173-bbrplus) 7 (Core)
  

3,重启机器观察。
重启成功以后查看下机器的内核是不是该内核:

[root@21yunwei ~]# uname -r
4.14.173-bbrplus

Last modification:March 21st, 2020 at 01:10 am
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment