Most of us do not have a recurring requirement for involvement with grubenv minutiae so I have unapologetically included what some might consider excessive detail.
Execution of command “grub2-mkconfig > /boot/grub2/grub.cfg” will cause creation or overwriting of files “/boot/grub2/grubenv” and “/boot/grub2/grub.cfg”. File “/boot/grub2/grubenv” variables “boot_success” and “boot_indeterminate” will be set to default values. After the first successful boot, values assigned to those variables will be as follows:
“boot_success=1”
“boot_indeterminate=0”
Ananaconda uses two globally unique indentifiers while installing Fedora 41. One GUID will be assigned to the installed file system partition. The other will be used when “/boot/loader/entries” files and “/boot” rescue files are created. Full paths to rescue files will be included in THE “/boot/loader/entries” rescue entry.
The “/boot/grub2/grubenv” variable “saved_entry” will store the name of a file contained in “/boot/loader/entries”. During boot, that info will be used to determine what to execute.
In EVERY case where the second GUID was used by ananaconda, replacing it with another GUID will be required if a migrated Fedora system is to be used concurrently with the original. CAUTION, file /boot/grub2/grubenv" MUST maintain a size of exactly 1024 bytes and should only be modified while the partition containing it is umounted. In addition, file “/EFI/fedora/grub.cfg” will require the same GUID that was applied to the migrated partition.
To edit grubenv:
Open a terminal as root at “/boot/grub2”
Enter command “vim”
Execute command to edit a binary file as follows:
I’d recommend using grub2-editenv to modify the environment block vice a text editor based on the warning in the file. # WARNING: Do not edit this file by tools other than grub-editenv!!!
Editing as a binary file with vim is simple and always works.
I provided a screenshot showing how to open grubenv as a binary file in vim. This method allows the value of any of its variables to be replaced with one of the SAME length without changing the mandated 1024 byte size.
The command grub2-editenv is designed to edit the grubenv file and ensure it is exactly formatted as designed, as well as being able (and needing) to edit it while the system is booted and the /boot file system is mounted.
All it takes is an inadvertent character add or deletion and the grubenv file would be broken. Grub2-editenv is designed to manage that file and ensure its format is correct.
There are several specialized editing tools to manage certain files and avoid the potential pitfalls of an inadvertent format error.
These include ‘visudo’ for editing the /etc/sudoers file and files placed in /etc/sudoers.d/, ‘grub2-editenv’ for editing the /boot/grub2/grubenv file, and ‘vipw’ for editing the /etc/passwd file; among others.
All those tools are intended to normally be used with the system actually booted, though the files being edited should not be open by some other app at the same time.
All are designed to check and verify syntax before saving the edited file.
Using vim directly does not have that safety net for the user.
Editing the /boot/grub2/grubenv with vi(m) is a really bad idea primarily due to the fact that the file MUST be 1024bytes , no less, no more … make just 1 error (like misplacing/removing/adding) a single character can make your OS un-bootable until you experience the pain of fixing it in single user mode.
The grubenv variable “saved_entry” should be exactly the same as one of the non-rescue files in “/boot/loader/entries” with the trailing “.conf” removed. Each of the other entries should be a single digit.
VIM binary editing and saving will indicate that 1024 bytes have been written unless the source filename copied as the “saved_entry” was incorrect. The syntax for those files is "<GUID>-<System_Info>:
“saved_entry=01ee60f708614f9d9ab6880e3b9dfd21-6.11.10-200.fc40.x86_64”
Following are screenshots of several successful VIM binary edits: