最新消息:

CentOS 8.x 和 RHEL 8.x 更改默认启动项

grub admin 175浏览 0评论

当前默认启动 "CentOS Linux (4.18.0-80.7.1.el8_0.x86_64) 8 (Core)"
如何修改使用 "CentOS Linux (4.18.0-80.11.2.el8_0.x86_64) 8 (Core)" 启动

安装 grubby

[root@aikaiyuan ~]# dnf install grubby

一般默认都以安装

查看默认启动项

[root@aikaiyuan ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64

查看所有内核

[root@aikaiyuan ~]# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-4.18.0-80.11.2.el8_0.x86_64"
args="ro crashkernel=auto resume=UUID=b9b14ba1-0b5c-49ac-842f-f11fa2081cfd console=ttyS0 $tuned_params"
root="UUID=3db5c437-b4f7-46cf-a20e-0345459003f3"
initrd="/boot/initramfs-4.18.0-80.11.2.el8_0.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-80.11.2.el8_0.x86_64) 8 (Core)"
id="f56bd0e5ce8b45e594c3fb6d1753d61d-4.18.0-80.11.2.el8_0.x86_64"
index=1
kernel="/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64"
args="ro crashkernel=auto resume=UUID=b9b14ba1-0b5c-49ac-842f-f11fa2081cfd console=ttyS0 $tuned_params"
root="UUID=3db5c437-b4f7-46cf-a20e-0345459003f3"
initrd="/boot/initramfs-4.18.0-80.7.1.el8_0.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-80.7.1.el8_0.x86_64) 8 (Core)"
id="f56bd0e5ce8b45e594c3fb6d1753d61d-4.18.0-80.7.1.el8_0.x86_64"
index=2
kernel="/boot/vmlinuz-4.18.0-80.el8.x86_64"
args="ro crashkernel=auto resume=UUID=b9b14ba1-0b5c-49ac-842f-f11fa2081cfd console=ttyS0 $tuned_params"
root="UUID=3db5c437-b4f7-46cf-a20e-0345459003f3"
initrd="/boot/initramfs-4.18.0-80.el8.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-80.el8.x86_64) 8 (Core)"
id="f56bd0e5ce8b45e594c3fb6d1753d61d-4.18.0-80.el8.x86_64"
index=3
kernel="/boot/vmlinuz-0-rescue-f56bd0e5ce8b45e594c3fb6d1753d61d"
args="ro crashkernel=auto resume=UUID=b9b14ba1-0b5c-49ac-842f-f11fa2081cfd console=ttyS0"
root="UUID=3db5c437-b4f7-46cf-a20e-0345459003f3"
initrd="/boot/initramfs-0-rescue-f56bd0e5ce8b45e594c3fb6d1753d61d.img"
title="CentOS Linux (0-rescue-f56bd0e5ce8b45e594c3fb6d1753d61d) 8 (Core)"
id="f56bd0e5ce8b45e594c3fb6d1753d61d-0-rescue"

查看指定内核启动项

[root@aikaiyuan ~]# grubby --info=/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64
index=1
kernel="/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64"
args="ro crashkernel=auto resume=UUID=b9b14ba1-0b5c-49ac-842f-f11fa2081cfd console=ttyS0 $tuned_params"
root="UUID=3db5c437-b4f7-46cf-a20e-0345459003f3"
initrd="/boot/initramfs-4.18.0-80.7.1.el8_0.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-80.7.1.el8_0.x86_64) 8 (Core)"
id="f56bd0e5ce8b45e594c3fb6d1753d61d-4.18.0-80.7.1.el8_0.x86_64"

修改默认启动

[root@aikaiyuan ~]# grubby --set-default /boot/vmlinuz-4.18.0-80.11.2.el8_0.x86_64
The default is /boot/loader/entries/f56bd0e5ce8b45e594c3fb6d1753d61d-4.18.0-80.11.2.el8_0.x86_64.conf with index 0 and kernel /boot/vmlinuz-4.18.0-80.11.2.el8_0.x86_64
[root@aikaiyuan ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-80.11.2.el8_0.x86_64

修改内核启动项参数

[root@aikaiyuan ~]# grubby --update-kernel=/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64 --args=console=ttyS0,115200

[root@aikaiyuan ~]# grubby --info=/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64
index=1
kernel="/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64"
args="ro crashkernel=auto resume=UUID=b9b14ba1-0b5c-49ac-842f-f11fa2081cfd $tuned_params console=ttyS0,115200"
root="UUID=3db5c437-b4f7-46cf-a20e-0345459003f3"
initrd="/boot/initramfs-4.18.0-80.7.1.el8_0.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-80.7.1.el8_0.x86_64) 8 (Core)"
id="f56bd0e5ce8b45e594c3fb6d1753d61d-4.18.0-80.7.1.el8_0.x86_64"

--update-kernel=/boot/vmlinuz-4.18.0-80.7.1.el8_0.x86_64
--update-kernel=ALL 也可以更新 所有内核
console=ttyS0,115200

转载请注明:爱开源 » CentOS 8.x 和 RHEL 8.x 更改默认启动项

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址