Skip to content

Need way to set GRUB environment variables when using external environment block (like with /boot on Btrfs) #2922

@Conan-Kudo

Description

@Conan-Kudo

In Fedora Linux, we have this Hidden GRUB Menu feature that relies on variables being set in grubenv. This is part of the larger boot counting mechanism that exists in the RH/Fedora grub2 package.

When /boot is an ext4 volume, GRUB relies on a grubenv file stored as /boot/grub2/grubenv. This is easily written to in config.sh stage by calling grub2-editenv (or grub-editenv in Debian/Ubuntu). This is done like so in Fedora kiwi descriptions:

## Write `menu_auto_hide=1` into grubenv to match Fedora anaconda installs
## Set boot_indeterminate to avoid displaying the grub menu on first boot
grub2-editenv /boot/grub2/grubenv set menu_auto_hide=1 boot_indeterminate=1

However, if /boot is a Btrfs (sub)volume, grub2-editenv needs to be run from within the fully mounted and synced disk root to initialize the environment block properly. It would look something like this:

grub2-editenv - set menu_auto_hide=1 boot_indeterminate=1

grub2-editenv will then locate the volume that /boot/grub2/grubenv is part of, realize it's btrfs, and write to the backing volume's external environment block in the Btrfs header instead.

So I need a way to declare GRUB environment variables to be set when we declare grub2 as the bootloader in the description so that they can be set properly for things like Btrfs where we use the external environment block feature.

This external environment block for Btrfs feature is available in Fedora Rawhide and openSUSE Tumbleweed grub2 packages today, and will be part of the upcoming GRUB 2.14 release.

Metadata

Metadata

Assignees

Projects

Status

To do

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions