grub-editenv
Modify GRUB environment variables
TLDR
Set a default boot entry (Assuming the boot entry already exists)
Display all GRUB environment variables
Reset the saved_entry variable to the default
SYNOPSIS
grub-editenv [OPTION...] FILE COMMAND [ARG...]
PARAMETERS
-v, --verbose
Print verbose messages, showing more details about the operation being performed.
-h, --help
Display a help message and exit. This provides a summary of the command's usage and available options.
-V, --version
Display version information about grub-editenv and exit.
DESCRIPTION
grub-editenv is a utility program designed to create, list, set, or unset variables within GRUB's persistent environment block file. This file, typically located at /boot/grub/grubenv, stores environment variables that GRUB can access during the boot process. It's crucial for functionalities like grub-set-default and grub-reboot, which use this block to store information about the default boot entry or a one-time boot selection. Unlike the main grub.cfg configuration file, which is often regenerated, the environment block provides a persistent, writable storage for dynamic settings. Administrators can use grub-editenv to manually inspect or modify these variables, though direct manipulation should be done with care to avoid boot issues. It provides a simple interface to manage the key-value pairs that influence GRUB's behavior across reboots.
CAVEATS
grub-editenv comes with several caveats:
1. Direct manual editing of the GRUB environment block can lead to boot issues if not done carefully.
2. Ensure the correct environment block file path is specified. Typically, this is /boot/grub/grubenv.
3. Changes made manually might conflict with other GRUB tools that automatically manage this file (e.g., grub-set-default, grub-reboot).
4. The environment block has a limited size, usually 1024 bytes. Exceeding this limit will cause issues.
COMMAND OPERATIONS
grub-editenv supports several command operations to manage the GRUB environment block:
create: Creates an empty GRUB environment block file. If the file already exists, it is truncated (emptied) and reinitialized.
list: Displays all variables and their current values currently stored in the environment block file.
set VAR=VALUE [...]: Sets one or more variables to specified values. If a variable already exists, its value is updated. New variables are added.
unset VAR [...]: Removes one or more specified variables from the environment block.
delete VAR [...]: An alias for unset, providing the same functionality to remove variables.
The FILE argument must always be specified before the command operation, pointing to the GRUB environment block (e.g., /boot/grub/grubenv).
GRUB ENVIRONMENT BLOCK FILE
The GRUB environment block file (commonly /boot/grub/grubenv) is a small, dedicated file used by GRUB to store persistent environment variables. These variables are accessible to GRUB during the boot process and can influence its behavior. Unlike the main grub.cfg configuration file, which is often static or generated by a script, the environment block provides a writable area for dynamic settings that can persist across reboots, such as the saved_entry variable used by grub-set-default.
HISTORY
grub-editenv is an integral part of GRUB 2, which superseded GRUB Legacy. Its introduction reflects a design philosophy in GRUB 2 to provide more dynamic and persistent control over boot behavior, allowing for changes to GRUB's environment variables without requiring a regeneration of the entire grub.cfg file. This command emerged as GRUB 2 matured, offering a robust method for other GRUB utilities and system administrators to manage boot-time preferences, like the default boot entry or one-time boot selections, in a persistent manner across reboots.
SEE ALSO
grub-set-default(8), grub-reboot(8), grub.cfg(5), grub(8), grub-mkconfig(8)


