Skip to main content
Topic: GRUB update issue (Read 744 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

GRUB update issue

I'm having trouble updating GRUB, and it seems to have something to do with scripts being generated by grub-customizer with incorrect syntax. I'm not very experienced with shell scripting, so I need some help with figuring out what's causing the following error messages.

This is the output I get from sudo update-grub:
Code: [Select]
Generating grub configuration file ...
Found theme: /boot/grub/themes/artix_modified_16:9/theme.txt
Found linux image: /boot/vmlinuz-linux-lts
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux-lts.img
Found fallback initrd image(s) in /boot:  intel-ucode.img amd-ucode.img initramfs-linux-lts-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot:  intel-ucode.img amd-ucode.img initramfs-linux-fallback.img
Found memtest86+ image: /boot/memtest86+/memtest.bin
Adding boot menu entry for UEFI Firmware Settings ...
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 241
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/grub/grub.cfg.new file attached.

This is what the end of my /boot/grub/grub.cfg.new looks like (except there are ^Ms on the end of some lines):
Code: [Select]
### BEGIN /etc/grub.d/61_linux_xen ###
### END /etc/grub.d/61_linux_xen ###

### BEGIN /etc/grub.d/62_os-prober ###
### END /etc/grub.d/62_os-prober ###

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

fwsetup --is-supported
if [ "$grub_platform" = "efi" -a "$?" = 0 ]; then

fi
### END /etc/grub.d/63_uefi-firmware_proxy ###

### BEGIN /etc/grub.d/64_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/64_custom ###

### BEGIN /etc/grub.d/65_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/65_custom ###

### BEGIN /etc/grub.d/66_memtest86+_proxy ###

if [ "${grub_platform}" == "pc" ]; then

fi
### END /etc/grub.d/66_memtest86+_proxy ###

And I found code that matches those blank if statements, except there's stuff inside them. The first bit is in /etc/grub.d/proxifiedScripts/uefi-firmware:
Code: [Select]
#! /bin/sh
set -e

# grub-mkconfig helper script.
# Copyright (C) 2020  Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.

prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"

export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"

. "$pkgdatadir/grub-mkconfig_lib"

LABEL="UEFI Firmware Settings"

gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2

cat << EOF
fwsetup --is-supported
if [ "\$grub_platform" = "efi" -a "\$?" = 0 ]; then
menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' {
fwsetup
}
fi
EOF

The other bit is in /etc/grub.d/proxifiedScripts/memtest86+:
Code: [Select]
#!/usr/bin/env bash
########################################################
# This script generates a memtest86+ entry on grub.cfg #
# if memtest is installed on the system.               #
########################################################

prefix="/usr"
exec_prefix="${prefix}"

datarootdir="/usr/share"
datadir="${datarootdir}"

. "${datadir}/grub/grub-mkconfig_lib"

MEMTEST86_IMAGE="/boot/memtest86+/memtest.bin"
CLASS="--class memtest86 --class gnu --class tool"

if [ -e "${MEMTEST86_IMAGE}" ] && is_path_readable_by_grub "${MEMTEST86_IMAGE}" ; then
    ## image exists, create menu entry
    echo "Found memtest86+ image: ${MEMTEST86_IMAGE}" >&2
    _GRUB_MEMTEST_HINTS_STRING="$(${grub_probe} --target=hints_string ${MEMTEST86_IMAGE})"
    _GRUB_MEMTEST_FS_UUID="$(${grub_probe} --target=fs_uuid ${MEMTEST86_IMAGE})"
    _GRUB_MEMTEST_REL_PATH="$(make_system_path_relative_to_its_root ${MEMTEST86_IMAGE})"
    cat << EOF
if [ "\${grub_platform}" == "pc" ]; then
    menuentry "Memory Tester (memtest86+)" ${CLASS} {
        search --fs-uuid --no-floppy --set=root ${_GRUB_MEMTEST_HINTS_STRING} ${_GRUB_MEMTEST_FS_UUID}
        linux16 ${_GRUB_MEMTEST_REL_PATH} ${GRUB_CMDLINE_MEMTEST86}
    }
fi
EOF
fi

How do I fix this issue and what's causing it?

 

Re: GRUB update issue

Reply #1
grub-customizer has a checkered past.  Web searches will show that.

The grub-customizer may be out of sync with the current file schema formats of the latest grub in Arch.  Unless the dev makes some changes to work with that support, which is only Arch at this time, I think is a longshot.

You may want to consider undoing grub-customizer.  I believe recent versions had an Undo type of functionality.  Or so did the one I gave up on about 10 years ago for a similar issue.

Ensure you have an Artix ISO USB that you can boot into in case the undo goes south.  If you do have to chroot in, maybe removing the grub package and a reinstall would do it.  Unless others have better advice.

If you got around it, do tell how you did so.

Re: GRUB update issue

Reply #2
grub-customizer has a checkered past.  Web searches will show that.

The grub-customizer may be out of sync with the current file schema formats of the latest grub in Arch.  Unless the dev makes some changes to work with that support, which is only Arch at this time, I think is a longshot.

You may want to consider undoing grub-customizer.  I believe recent versions had an Undo type of functionality.  Or so did the one I gave up on about 10 years ago for a similar issue.

Ensure you have an Artix ISO USB that you can boot into in case the undo goes south.  If you do have to chroot in, maybe removing the grub package and a reinstall would do it.  Unless others have better advice.

If you got around it, do tell how you did so.
What exactly is the allure of grub-customizer that people are willing to give it a shot despite it's problems?

Re: GRUB update issue

Reply #3
What exactly is the allure of grub-customizer that people are willing to give it a shot despite it's problems?
grub is a horrendous complex monstrosity which can be hard to customize beyond basic setups.
Some people want to customise grub and don't know how. I guess that is part of the allure ?
I haven't used grub for years on my desktop PC. Long ago I did, and did experiment with grub-customizer but didn't like it so I uninstalled it. Grub followed it not long after.

rEFInd for the win.

@tristanbay
Quote
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.

Are you sure it's not something in /etc/default/grub ?
How many more files are under /etc/grub.d/* other than what you've posted ?