GRUB gone crazy after Fedora 41 beta update (file error)

Hello,

Yesterday I managed to install a grub theme using terminal and grub-customizer (I’m forced to use Windows Education alongside). This morning, I updated my computer to Fedora 41 beta, everything was good until I regenerated the grub config file and got this error (translated to english):

Syntax error on line 241
Syntax errors are detected in the configuration file by GRUB. Please check that there are no errors in the files /etc/default/grub and /etc/grub.d/*. If not, please report a bug by attaching the file /boot/grub.cfg.new.

How can I fix that?

Here’s my grub config file:

GRUB_TIMEOUT="20"
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT="Fedora Linux"
GRUB_DISABLE_SUBMENU="true"
#GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG="false"
GRUB_THEME="/boot/grub2/themes/Minegrub/theme.txt"
GRUB_DISABLE_OS_PROBER="false"
GRUB_SAVEDEFAULT="false"
#GRUB_HIDDEN_TIMEOUT="15"

Thanks in advance!

Using themes with grub is sometimes problematic.
Have you tried removing that theme line and running
grub2-mkconfig -o /boot/grub2/grub.cfg again to see if it is actually the problem.

Here is what a clean /etc/default/grub file looks like for both f40 & f41

$ cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

In yours I see several additional or changed lines

GRUB_DEFAULT="Fedora Linux"
GRUB_ENABLE_BLSCFG="false"
GRUB_THEME="/boot/grub2/themes/Minegrub/theme.txt"
GRUB_DISABLE_OS_PROBER="false"
GRUB_SAVEDEFAULT="false"
#GRUB_HIDDEN_TIMEOUT="15"

Any of those may cause the reported error if not syntactically correct, and looking at the suggested line in /boot/grub2/grub.cfg may reveal the actual error.

Thank you for helping me!

I copy/pasted your clean file and still got an error:

Generating grub configuration file ...
Found Windows Boot Manager on /dev/mmcblk1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
Adding boot menu entry for UEFI Firmware Settings ...
error: ../grub-core/script/lexer.c:352:syntax error.
error: ../grub-core/script/lexer.c:352:Incorrect command.
error: ../grub-core/script/lexer.c:352:syntax error.
Syntax error at line 225
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub2/grub.cfg.new file attached.

And it’s only the Fedora 41 update that missed things… Strange.

Anyway, do you know where the problem comes?

Not without the contents of /boot/grub2/grub.cfg.

There is another step required after changing /etc/default/grub. It is useful to add a reminder as the first line of /etc/default/grub:

$ head -1 /etc/default/grub
# after editing, use: sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Your error message in the first post showed this reminder.
The content of /etc/default/grub was my first guess since that seemed to be what you had posted and the theme appeared to be involved.

It also suggests that if you potentially edited any of the files in /etc/grub.d/ then it may occur there.

Finally, if by chance when you “updated grub” you may have altered the file at /boot/efi/EFI/fedora/grub.cfg it may be still giving the error.

Your latest post seems to indicate there may be a file /boot/grub2/grub.cfg.new and suggests that it may contain the answer. Please post that.

I have a suspicion that grub-customizer might have created the problem. Usually when people change GRUB_ENABLE_BLSCFG to “false” it is because grub-customizer can’t rearrange boot entries when GRUB_ENABLE_BLSCFG is set to “true”.

Problem no 1

GRUB_ENABLE_BLSCFG must be enabled for the kernel update to work properly.

Problem no 2

grub-customizer may rename files in /etc/grub.d and/or create new files there. When you then upgrade grub2 you will get a real mess.

I can confirm that the grub-customizer is not work correctly with RHEL based systems. It is made for Debian/Ubuntu based systems.

As I do remember Fedora not uses the same theme paths as other Linux distributions.

Chris @py0xc3 is absolutely right:

I also would like to remind all participants on the rules of our Discourse, and on common behaviors and practices that make it much more likely to trigger discussions into constructive directions and thus achieve value for everybody.

Theming Grub is definitely not a Fedora priority.
It comes with the opportunity to boot different kernel versions and to ensure rescuing the system when there is an issue.

Even if it appears pitch black it does the job!

We are on Beta with F41 and will solve primarily first cases to release it to stable.

@gosling203 if you want to do some technical chitchat about grub2 and how to beautify please use the The Water Cooler section.

From Ask Fedora to The Water Cooler

Added tech-talk and removed f41, grub

Even without themes, that’s the update which broke grub configuration update.

Thank you all for your help, but the problem is still here, even without theme.

Even when following the Fedora Bootloader guide to reinstall everything, it didn’t change things.
Maybe grub-customizer changed things, but I don’t know.

And finally, here is /boot/grub2/grub.cfg.new.

I hope this can help!

I am sorry but when you link a site of that sort we never will visit it. It does not even display the file as the first page but forces a download for viewing — which is a no-no.
Post the content of the file here using the preformatted text tags available with the </> button on the toolbar of the text entry window.

(I removed the actual link in the quote since we do not need to propagate such sites.)

I did not find a way to post it, so I did it like that. Sorry ! :sweat_smile:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="Fedora"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/02_grub-customizer_menu_color_helper ###
### END /etc/grub.d/02_grub-customizer_menu_color_helper ###

### BEGIN /etc/grub.d/08_fallback_counting ###
insmod increment
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
if [ -n "${boot_counter}" -a "${boot_success}" = "0" ]; then
  # if countdown has ended, choose to boot rollback deployment,
  # i.e. default=1 on OSTree-based systems.
  if  [ "${boot_counter}" = "0" -o "${boot_counter}" = "-1" ]; then
    set default=1
    set boot_counter=-1
  # otherwise decrement boot_counter
  else
    decrement boot_counter
  fi
  save_env boot_counter
fi
### END /etc/grub.d/08_fallback_counting ###

### BEGIN /etc/grub.d/10_linux_proxy ###
menuentry "Fedora" --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-6.11.3-300.fc41.x86_64-advanced-a9d46f31-3dd5-43e1-80ab-aa1122b20f10' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	search --no-floppy --fs-uuid --set=root e7cd4e44-931b-4058-abd9-e9f90f4c0e50
	echo	'Loading Linux 6.11.3-300.fc41.x86_64 ...'
	linux	/vmlinuz-6.11.3-300.fc41.x86_64 root=UUID=a9d46f31-3dd5-43e1-80ab-aa1122b20f10 ro rootflags=subvol=root rhgb quiet 
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-6.11.3-300.fc41.x86_64.img
}
### END /etc/grub.d/10_linux_proxy ###

### BEGIN /etc/grub.d/11_reset_boot_success ###
# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
  set menu_hide_ok=1
else
  set menu_hide_ok=0 
fi
# Reset boot_indeterminate after a successful boot
if [ "${boot_success}" = "1" ] ; then
  set boot_indeterminate=0
# Avoid boot_indeterminate causing the menu to be hidden more than once
elif [ "${boot_indeterminate}" = "1" ]; then
  set boot_indeterminate=2
fi
# Reset boot_success for current boot 
set boot_success=0
save_env boot_success boot_indeterminate
### END /etc/grub.d/11_reset_boot_success ###

### BEGIN /etc/grub.d/12_menu_auto_hide ###
if [ x$feature_timeout_style = xy ] ; then
  if [ "${menu_show_once}" ]; then
    unset menu_show_once
    save_env menu_show_once
    set timeout_style=menu
    set timeout=60
  elif [ "${menu_auto_hide}" -a "${menu_hide_ok}" = "1" ]; then
    set orig_timeout_style=${timeout_style}
    set orig_timeout=${timeout}
    if [ "${fastboot}" = "1" ]; then
      # timeout_style=menu + timeout=0 avoids the countdown code keypress check
      set timeout_style=menu
      set timeout=0
    else
      set timeout_style=hidden
      set timeout=1
    fi
  fi
fi
### END /etc/grub.d/12_menu_auto_hide ###

### BEGIN /etc/grub.d/14_menu_show_once ###
if [ x$feature_timeout_style = xy ]; then
  if [ "${menu_show_once_timeout}" ]; then
    set timeout_style=menu
    set timeout="${menu_show_once_timeout}"
    unset menu_show_once_timeout
    save_env menu_show_once_timeout
  fi
fi
### END /etc/grub.d/14_menu_show_once ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/21_ppc_terminfo ###
### END /etc/grub.d/21_ppc_terminfo ###

### BEGIN /etc/grub.d/25_bli ###
if [ "$grub_platform" = "efi" ]; then
        if [ ! insmod bli ]; then
                echo "bli module not available"
        fi
fi
### END /etc/grub.d/25_bli ###

### BEGIN /etc/grub.d/30_os-prober_proxy ###


# Other OS found, undo autohiding of menu unless menu_auto_hide=2
if [ "${orig_timeout_style}" -a "${menu_auto_hide}" != "2" ]; then
  set timeout_style=${orig_timeout_style}
  set timeout=${orig_timeout}
fi
menuentry "Vindoz" --class windows --class os $menuentry_id_option 'osprober-efi-0A2B-C693' {
	insmod part_gpt
	insmod fat
	search --no-floppy --fs-uuid --set=root 0A2B-C693
	chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
### END /etc/grub.d/30_os-prober_proxy ###

### BEGIN /etc/grub.d/31_linux_proxy ###






### END /etc/grub.d/31_linux_proxy ###

### BEGIN /etc/grub.d/32_uefi-firmware_proxy ###

if [ "$grub_platform" = "efi" ]; then
fi
### END /etc/grub.d/32_uefi-firmware_proxy ###

### BEGIN /etc/grub.d/33_linux_proxy ###
submenu "Autres machins"{
menuentry "Fedora Linux (6.11.3-300.fc41.x86_64) 41 (Workstation Edition Prerelease)" --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-6.11.3-300.fc41.x86_64-advanced-a9d46f31-3dd5-43e1-80ab-aa1122b20f10' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	search --no-floppy --fs-uuid --set=root e7cd4e44-931b-4058-abd9-e9f90f4c0e50
	echo	'Loading Linux 6.11.3-300.fc41.x86_64 ...'
	linux	/vmlinuz-6.11.3-300.fc41.x86_64 root=UUID=a9d46f31-3dd5-43e1-80ab-aa1122b20f10 ro rootflags=subvol=root rhgb quiet 
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-6.11.3-300.fc41.x86_64.img
}
menuentry "Fedora Linux (6.11.2-300.fc41.x86_64) 41 (Workstation Edition Prerelease)" --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-6.11.2-300.fc41.x86_64-advanced-a9d46f31-3dd5-43e1-80ab-aa1122b20f10' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	search --no-floppy --fs-uuid --set=root e7cd4e44-931b-4058-abd9-e9f90f4c0e50
	echo	'Loading Linux 6.11.2-300.fc41.x86_64 ...'
	linux	/vmlinuz-6.11.2-300.fc41.x86_64 root=UUID=a9d46f31-3dd5-43e1-80ab-aa1122b20f10 ro rootflags=subvol=root rhgb quiet 
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-6.11.2-300.fc41.x86_64.img
}
menuentry "Fedora Linux (6.10.12-200.fc40.x86_64) 41 (Workstation Edition Prerelease)" --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-6.10.12-200.fc40.x86_64-advanced-a9d46f31-3dd5-43e1-80ab-aa1122b20f10' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	search --no-floppy --fs-uuid --set=root e7cd4e44-931b-4058-abd9-e9f90f4c0e50
	echo	'Loading Linux 6.10.12-200.fc40.x86_64 ...'
	linux	/vmlinuz-6.10.12-200.fc40.x86_64 root=UUID=a9d46f31-3dd5-43e1-80ab-aa1122b20f10 ro rootflags=subvol=root rhgb quiet 
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-6.10.12-200.fc40.x86_64.img
}
menuentry "Fedora Linux (0-rescue-9a3ef5c26c0f4e13812cbd81268abc24) 41 (Workstation Edition Prerelease)" --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-9a3ef5c26c0f4e13812cbd81268abc24-advanced-a9d46f31-3dd5-43e1-80ab-aa1122b20f10' {
	load_video
	insmod gzio
	insmod part_gpt
	insmod ext2
	search --no-floppy --fs-uuid --set=root e7cd4e44-931b-4058-abd9-e9f90f4c0e50
	echo	'Loading Linux 0-rescue-9a3ef5c26c0f4e13812cbd81268abc24 ...'
	linux	/vmlinuz-0-rescue-9a3ef5c26c0f4e13812cbd81268abc24 root=UUID=a9d46f31-3dd5-43e1-80ab-aa1122b20f10 ro rootflags=subvol=root rhgb quiet 
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-0-rescue-9a3ef5c26c0f4e13812cbd81268abc24.img
}
menuentry "UEFI Firmware Settings" $menuentry_id_option 'uefi-firmware' {
			fwsetup
}
}
### END /etc/grub.d/33_linux_proxy ###

### BEGIN /etc/grub.d/35_fwupd ###
### END /etc/grub.d/35_fwupd ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###

The last error message was in line 225, in 33_linux_proxy:

Line 225 is shown here.
Apparently you have an error in a file within /etc/grub.d/

Now it’s line 214. It’s in 32_uefi-firmware_proxy, but what do I need to edit?

#!/bin/sh
#THIS IS A GRUB PROXY SCRIPT
'/etc/grub.d/proxifiedScripts/uefi-firmware' | /etc/grub.d/bin/grubcfg_proxy "-'UEFI Firmware Settings'~64e44c617bdc25f7157049e6ee844499~
+*
+#text
"

I had the same issue after update and managed to solve it by following the steps in this guide:

# Remove old grub configs
sudo rm /etc/grub.d/*
sudo rm /etc/sysconfig/grub
# Reinstall grub
sudo dnf reinstall grub2-efi shim grub2-tools
# Rebuild the grub.cfg
sudo grub2-mkconfig -o /boot/grub2/grub.cfg