tencent cloud

TencentOS Server

GRUB Management (grubby)

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-10-19 17:22:48
AI翻訳
This document describes how to use grub2 and grubby on TencentOS Server to manage kernel boot entries, including viewing the current boot configuration, modifying the default boot kernel, and adjusting kernel boot parameters.
TencentOS Server manages kernel boot entries primarily through the following tools:
Tool
Applicable Versions
Description
grubby
TencentOS Server 3 / 4
fedora community tool, recommended for use
grub2-*
TencentOS Server 2
Native GRUB 2 command

Must-Knows

Permission requirements: Ensure that you have obtained root privileges.
Applicable scenarios: switching the default boot kernel and adjusting kernel boot parameters in a multi-kernel environment

Managing Boot with grubby

For TencentOS Server 3 and 4, it is recommended to use grubby for kernel boot configuration.
View the current default boot kernel:
grubby --default-kernel
The returned result is as follows:
/boot/vmlinuz-5.4.241-24.0017.41.3
View information about all available kernels on the system:
grubby --info=ALL
The returned result is as follows:
index=0
kernel="/boot/vmlinuz-5.4.241-24.0017.28"
args="ro quiet elevator=noop console=ttyS0,115200 console=tty0 vconsole.keymap=us crashkernel=3G-16G:256M,16G-64G:384M,64G-128G:512M,128G-486G:768M,486G-972G:1024M,972G-:2048M vconsole.font=latarcyrheb-sun16 net.ifnames=0 biosdevname=0 intel_idle.max_cstate=1 intel_pstate=disable iommu=pt amd_iommu=on nopvspin"
root="UUID=1cdbeeff-b545-47c3-8442-9038c7ad903b"
initrd="/boot/initramfs-5.4.241-24.0017.28.img"
title="TencentOS Server (5.4.241-24.0017.28) 3.3 (Final)"
id="30e472194cb8417c88b24ec0b1915e7f-5.4.241-24.0017.28"
View detailed information about a specified kernel:
grubby --info=/boot/vmlinuz-\\<version> #Example version: 5.4.241-24.0017.28
View detailed information about the current default kernel:
grubby --info=$(grubby --default-kernel)

Setting the Default Boot Kernel

Warning:
After the default kernel is set, a system restart is required for the change to take effect. Before restarting, verify that the target kernel version is correct to avoid setting an incorrect kernel version, which may prevent the system from booting.
Set the default boot kernel by kernel path:
grubby --set-default /boot/vmlinuz-\\<version> #Example version: 5.4.241-24.0017.28
Take setting 5.4.241-24.0017.28 as the default kernel as an example:
grubby --set-default /boot/vmlinuz-5.4.241-24.0017.28
The returned result is as follows:
The default is /boot/loader/entries/30e472194cb8417c88b24ec0b1915e7f-5.4.241-24.0017.28.conf with index 0 and kernel /boot/vmlinuz-5.4.241-24.0017.28

Modifying Kernel Boot Parameters

Warning:
After the default kernel or kernel parameters are modified, a system restart is required for the changes to take effect. Before restarting, verify that the parameters are correct to avoid setting incorrect parameters, which may prevent the system from booting.
Add boot parameters to the default kernel:
grubby --update-kernel=$(grubby --default-kernel) --args="\\<parameter>"
Take adding the debug parameter as an example:
grubby --update-kernel=$(grubby --default-kernel) --args="debug"
Add boot parameters to all kernels:
grubby --update-kernel=ALL --args="\\<parameter>"
Remove boot parameters from the default kernel:
grubby --update-kernel=$(grubby --default-kernel) --remove-args="\\<parameter>"
Take removing the quiet parameter as an example:
grubby --update-kernel=$(grubby --default-kernel) --remove-args="quiet"

Managing Boot with grub2

The following commands apply to TencentOS Server 2 and are not recommended for use on TencentOS Server 3/4.
View the current default boot entry:
grub2-editenv list
The returned result is as follows:
saved_entry=TencentOS Server (5.4.119-19.0009.67.1) 2.4
View all available boot entries:
awk -F\\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg
The returned result is as follows:
0 : TencentOS Server (5.4.119-19.0009.67.1) 2.4
1 : TencentOS Server (5.4.120-19.0009.67.1) 2.4 #This version does not exist and is for demonstration only.

Setting the Default Boot Entry (by Index)

Set the default boot entry by index:
grub2-set-default <index>
Verify that the setting takes effect:
grub2-editenv list

Verification

After completing the kernel boot configuration, restart the system to verify that the changes take effect.
Confirm the current default kernel (run after restart):
grubby --default-kernel
Confirm the actual running kernel version:
uname -r

FAQs

After the default kernel is set, the System Still Boots into the Old Kernel.

Possible cause: grub2-set-default was used, but the GRUB configuration file was not updated.
Solution: Reconfigure grub
Regenerate the GRUB configuration:
grub2-mkconfig -o /boot/grub2/grub.cfg
Verify the default kernel:
grubby --default-kernel

How to Boot Once with a Specified Kernel Without Changing the Default?

Use grub2-reboot to specify the kernel for the next boot:
grub2-reboot \\<kernel title or index>
View the kernel index:
grubby --info=ALL | grep index

How to Recover from a System Boot Failure Caused by Incorrect Kernel Parameters?

1. Restart the system to enter the GRUB boot menu (press the Esc or Shift key).
2. Select the kernel to boot, and press e to enter edit mode.
3. Locate the line that starts with linux and manually delete the incorrect parameters.
4. Press Ctrl+X to boot the system.
5. After boot, use grubby --update-kernel to repair the configuration.


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック