grub2-mkconfig crashes with "free(): invalid next size (normal)" message or fails with "error: environment block too small"
Environment
- Red Hat Enterprise Linux 8
- grub2 prior to version 2.02-90.el8
Issue
-
When executing
grub2-mkconfigto rebuild the Grub menu, the command dumps core and print the following message# grub2-mkconfig -o /etc/grub2.cfg Generating grub configuration file ... free(): invalid next size (normal) /etc/grub.d/10_linux: line 128: PID Aborted (core dumped) -
When executing
grub2-mkconfigto rebuild the Grub menu, the command fails with the following message# grub2-mkconfig -o /etc/grub2.cfg Generating grub configuration file ... /usr/bin/grub2-editenv: error: environment block too small.
Resolution
- Red Hat investigated the issue under This content is not included.BZ 1761496 - grub2-editenv segfaults when called through grub2-mkconfig. A fix was released on 2020-11-03 through grub2 bug fix and enhancement update RHBA-2020:4513.
Workaround
-
Delete current
/boot/grub/grubenvfile# rm /boot/grub/grubenv -
Disable BLS in Grub's configuration file
# sed -i "s/GRUB_ENABLE_BLSCFG=true/GRUB_ENABLE_BLSCFG=false/" /etc/default/grub -
Rebuild the Grub menu
# grub2-mkconfig -o /etc/grub2.cfgNote: on UEFI file systems, specify
/etc/grub2-efi.cfginstead of/etc/grub2.cfg
Root Cause
- Grub corrupts the
/boot/grub/grubenvfile or file is too big to be handled properly
SBR
Product(s)
Components
Category
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.