How to re-generate the grubenv file if missing or corrupted ?
Environment
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
Issue
-
The
grubenvfile is corrupted or missing in BIOS and UEFI systems. -
Detected a corrupted
grubenvfile in the/var/log/leapp/leapp-report.txt. -
Following messages were repeatedly observed in the /var/log/messages:
grub2-set-bootflag[736726]: Error reading from /boot/grub2/grubenv: Invalid argument systemd[732552]: grub-boot-success.service: Main process exited, code=exited, status=1/FAILURE systemd[732552]: grub-boot-success.service: Failed with result 'exit-code'. systemd[732552]: Failed to start Mark boot as successful.
Resolution
-
check the size of
grubenvfile , this should be1024in size , else the file is corrupted.For BIOS # ls -l /boot/grub2/grubenv For UEFI # ls -l /boot/efi/EFI/redhat/grubenv -
Remove the corrupted remove
grubenvfile.For BIOS # rm /boot/grub2/grubenv For UEFI # rm /boot/efi/EFI/redhat/grubenv -
Re-generate the
grubenvfile.# grub2-mkconfig
Root Cause
-
The
leapp-report.txthad a inhibitor of missing files.Risk Factor: high (inhibitor) Title: Detected a corrupted grubenv file Summary: The grubenv file must be valid to pass the upgrade correctly: - an exact size of 1024 bytes is expected - it cannot end with a newline. The corruption could be caused by a manual modification of the file which is not recommended.
Diagnostic Steps
-
For a UEFI system the
grubenvfile was 953 in size which should be1024.-rwx------. 1 root root 953 Apr 21 2023 /boot/efi/EFI/redhat/grubenv
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.