Modify boot entries and kernel command-line parameters in Alibaba Cloud Linux 3 AI Extension Edition

更新时间:
复制 MD 格式
Important

Modifying kernel command-line parameters can cause unexpected system behavior or prevent the system from booting. Test all changes in a non-production environment before applying them to production systems.

Use the grubby command-line tool to add or remove kernel command-line parameters in Alibaba Cloud Linux 3 AI Extension Edition. This document covers global and per-entry parameter changes, plus steps to verify that changes take effect.

How boot entries work

All GRand Unified Bootloader (GRUB) boot entry configurations are stored in /boot/loader/entries/. Each configuration file is named using the machine-id (from /etc/machine-id) and the kernel version—for example, c8742e47872643a6839300623c28b57c-5.10.134-19.101.al8.x86_64.conf.

A typical boot entry configuration file:

title Alibaba Cloud Linux (5.10.134-19.101.al8.x86_64) 3 (OpenAnolis Edition)
version 5.10.134-19.101.al8.x86_64
linux /boot/vmlinuz-5.10.134-19.101.al8.x86_64
initrd /boot/initramfs-5.10.134-19.101.al8.x86_64.img $tuned_initrd
options $kernelopts $tuned_params
id alinux-20250707132428-5.10.134-19.101.al8.x86_64
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel

The options line references the kernelopts variable, which defines kernel parameters shared across all boot entries. Its value is stored in /boot/grub2/grubenv. Modifying this variable affects all kernel versions at once.

Rather than editing these files directly—which can introduce formatting errors that prevent the system from booting—use grubby. It handles configuration updates atomically and correctly.

Prerequisites

Before you begin, make sure that:

  • Root access: You are logged on to the ECS instance as a root user.

  • (Recommended) Snapshot: For production environments, create a snapshot of the instance before making changes so you can recover quickly if needed.

  • One-time setup for AI Extension Edition: Run the following command once before running any grubby modification commands. This links the grubenv file correctly; without it, your changes will not take effect.

    efibootmgr -q && test -f /boot/efi/EFI/alinux/grubenv && ln -sf ../efi/EFI/alinux/grubenv /boot/grub2/grubenv

    Running this command multiple times has no adverse effects.

Modify parameters for all boot entries

Use this method to apply a parameter to all installed kernel versions. grubby updates the kernelopts variable in /boot/grub2/grubenv, so every boot entry that references it picks up the change.

Add a parameter:

grubby --update-kernel=ALL --args="<NEW_PARAMETER>"

For example, to add NVMe I/O timeout support:

grubby --update-kernel=ALL --args="nvme_core.io_timeout=4294967295"

Remove a parameter:

grubby --update-kernel=ALL --remove-args="<PARAMETER_TO_REMOVE>"

Modify parameters for a single boot entry

Use this method to add or remove a parameter for one specific kernel version without affecting other versions.

Add a parameter:

grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="<NEW_PARAMETER>"

Remove a parameter:

grubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="<PARAMETER_TO_REMOVE>"
Important

When you modify a single boot entry, grubby expands the kernelopts variable and writes its value directly into the entry's configuration file at /boot/loader/entries/<ENTRY>.conf. The entry no longer references the kernelopts variable. To modify this entry again, specify it explicitly by its kernel path (as shown above) rather than using ALL.

Verify the changes

After modifying parameters, reboot and confirm that the changes took effect.

  1. Reboot the ECS instance.

  2. Check the active kernel parameters:

    cat /proc/cmdline

    The output lists all parameters passed to the running kernel. Confirm that your added parameter appears in the output—for example, nvme_core.io_timeout=4294967295.