refactor(grub): increased environment size to 2kB#650
Merged
HarryWaschkeit merged 8 commits intoMay 4, 2026
Merged
Conversation
Why: feature `flash-mode-3` allows to flash a device with an externally available (retrievable via HTTP[S]) image files. Two environment variables - beside the `flash-mode` variable which chooses among the available flash modes - control what is to be flashed: - one contains the URL to a `wic.xz` file containing the image to be flashed to the boot device - the other one holding the SHA256sum for the retrieved image file for verification **NOTE:** have a look at chapter "Flash Mode 3" in README.md file for full details. Mainly the URL can be rather lengthy, possibly exceeding the standard environmrent size, together with all other variables normally set. For this an possibly other future use cases the `grubenv` got extended. **NOTE:** grub documentation actually states to only use `grub-editenv <file> create` to create an ampty einvironment file, and also for any modification the `grub-editenv` program shall be used. However, the `grub` source code currently does not make any assumptions about the file size. The only check implemented to validate en environment file is whether it starts with the right signature (`# GRUB Environment Block`). Otherwise, free space to set new variables is the complete end region that is filled exclusively with `#` characters: the first newline that is detected marks the end of the stored variable settings where any line starting with a `#` character is treated as comment, hence ignored during variable/value pair parsing. Signed-off-by: Harry Waschkeit <44188360+HarryWaschkeit@users.noreply.github.com>
If for whatever reason not all variables required for flash mode 3 got set correctly, the flash-mode-3 init script could fail leaving a system behind with a shell in the initramfs. Even worse, it was possible that not even a power-cycle could revive the system, because the script left the flash mode operation panding by not cleaning up the environment. Admittedly, flash modes are generally devlopment-only feature, but possibly having to manually attend a device to sort things out could be rather inconvenient. This change improves the situation so that at least after having failed a flash mode (3) operation a power cycle brings up the system again as it was before. Signed-off-by: Harry Waschkeit <44188360+HarryWaschkeit@users.noreply.github.com>
… thereby hiding errors Signed-off-by: Harry Waschkeit <44188360+HarryWaschkeit@users.noreply.github.com>
…ader_env_grub.sh) Signed-off-by: Harry Waschkeit <44188360+HarryWaschkeit@users.noreply.github.com>
…6-04-29-refactor-grub-enlarged-environment
mlilien
reviewed
May 4, 2026
mlilien
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: feature
flash-mode-3allows to flash a device with an externally available (retrievable via HTTP[S]) image file.Two environment variables - beside the
flash-modevariable which chooses among the available flash modes - control what is to be flashed:wic.xzfile containing the image to be flashed to the boot deviceNOTE: have a look at chapter "Flash Mode 3" in README.md file for full details.
Mainly the URL can be rather lengthy, possibly exceeding the standard environmrent size, together with all other variables normally set.
For this an possibly other future use cases the
grubenvgot extended.NOTE: grub documentation actually states to only use
grub-editenv <file> createto create an ampty einvironment file, and also for any modification thegrub-editenvprogram shall be used. However, thegrubsource code currently does not make any assumptions about the file size.The only check implemented to validate en environment file is whether it starts with the right signature (
# GRUB Environment Block). Otherwise, free space to set new variables is the complete end region that is filled exclusively with#characters: the first newline that is detected marks the end of the stored variable settings where any line starting with a#character is treated as comment, hence ignored during variable/value pair parsing.