首页 > 系统相关 >centos8/rocky8使用grubby修改内核启动参数

centos8/rocky8使用grubby修改内核启动参数

时间:2022-09-27 18:44:10浏览次数:83  
标签:x86 cl boot el8 grubby 64 root rocky8 centos8

转: https://blog.csdn.net/qq_36885515/article/details/112531114

grubby是一个用于更新和显示有关各种体系结构特定的引导程序的配置文件信息的命令行工具。 它主要设计用于安装新内核并需要查找有关当前引导环境的信息的脚本,同时也可以对启动内核的各项信息参数进行修改。

本文主要介绍如何在centos8中使用grubby工具来对系统的内核启动参数和启动顺序进行调整。

使用yum或者dnf可以直接安装grubby工具。

[root@tiny-server ~]# yum install grubby
Last metadata expiration check: 1:29:38 ago on Wed 18 Nov 2020 09:44:26 AM +08.
Package grubby-8.40-38.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

查看当前的默认启动内核:

[root@tiny-server ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64

查看系统安装的全部内核:

[root@tiny-server ~]# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-5.9.1-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.9.1-1.el8.elrepo.x86_64) 8.2 (Ootpa)"
id="12ab47b22fef4c02bcdc88b340d5f706-5.9.1-1.el8.elrepo.x86_64"
index=1
kernel="/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-4.18.0-193.28.1.el8_2.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.28.1.el8_2.x86_64) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.28.1.el8_2.x86_64"
index=2
kernel="/boot/vmlinuz-4.18.0-193.19.1.el8_2.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-4.18.0-193.19.1.el8_2.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.19.1.el8_2.x86_64) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.19.1.el8_2.x86_64"
index=3
kernel="/boot/vmlinuz-4.18.0-193.el8.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-4.18.0-193.el8.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.el8.x86_64) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.el8.x86_64"
index=4
kernel="/boot/vmlinuz-0-rescue-12ab47b22fef4c02bcdc88b340d5f706"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-0-rescue-12ab47b22fef4c02bcdc88b340d5f706.img"
title="CentOS Linux (0-rescue-12ab47b22fef4c02bcdc88b340d5f706) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-0-rescue"

设置新的默认启动内核:

# 使用路径来指定内核,可以使用--set-default=kernel-path
[root@tiny-server ~]# grubby --set-default=/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64
The default is /boot/loader/entries/12ab47b22fef4c02bcdc88b340d5f706-5.9.1-1.el8.elrepo.x86_64.conf with index 0 and kernel /boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64
[root@tiny-server ~]# grubby --default-kernel
/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64

# 使用index来指定内核,则使用--set-default-index=entry-index
[root@tiny-server ~]# grubby --set-default-index=1
The default is /boot/loader/entries/12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.28.1.el8_2.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64
[root@tiny-server ~]# grubby --default-kernel
/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64

添加/删除内核启动参数:

# 对所有的内核都删除某个参数  
[root@tiny-server ~]# grubby --update-kernel=ALL --remove-args=intel_iommu=on

# 对所有的内核都添加某个参数  
[root@tiny-server ~]# grubby --update-kernel=ALL --args=intel_iommu=on

# 对某个的内核添加启动参数  
[root@tiny-server ~]# grubby --update-kernel=/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64 --args=intel_iommu=on

查看特定内核的具体信息:

[root@tiny-server ~]# grubby --info=/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64
index=0
kernel="/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-5.9.1-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.9.1-1.el8.elrepo.x86_64) 8.2 (Ootpa)"
id="12ab47b22fef4c02bcdc88b340d5f706-5.9.1-1.el8.elrepo.x86_64"

标签:x86,cl,boot,el8,grubby,64,root,rocky8,centos8
From: https://www.cnblogs.com/colin88/p/16735568.html

相关文章