Grub Cleanup After August Manjaro Update

Hey Guys,

I was trying to remove some entrees from my Grub Menu after today’s Manjaro update. Specifically the, “UEFI Firmware Settings” entree (which is new). Is there an easy way I can update my Grub menu and cleanup this entree?

Any help would beg greatly appreciated. TIA!

Have a look at your /etc/default/grub, and at the scripts under /etc/grub.d. Don’t forget to update the boot loader configuration again after making any changes to those files.

sudo update-grub

Hope this helps. :wink:

Hi. I think that entry is created by update-grub according to /etc/grub.d/30_uefi-firmware helper script. So you can try to remove it and then run update-grub. Though I guess it will be back after next grub package update.

It suffices to remove the execute permission on that script. :wink:

sudo chmod 644 /etc/grub.d/30_uefi-firmware

:wink:

1 Like

Thanks guys! Before doing anything, I just tested out update-grub, and got a syntax error:

[aahmad@aahmad-pc grub.d]$ sudo update-grub
Generating grub configuration file ...
Found theme: /usr/share/grub/themes/manjaro/theme.txt
Found linux image: /boot/vmlinuz-5.8-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.8-x86_64.img
Found initrd fallback image: /boot/initramfs-5.8-x86_64-fallback.img
Found linux image: /boot/vmlinuz-5.7-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.7-x86_64.img
Found initrd fallback image: /boot/initramfs-5.7-x86_64-fallback.img
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 244
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.

Any thoughts on what the issue might be? TIA.

Add nvme to the line reading…

GRUB_PRELOAD_MODULES="some_stuff_here"

… in /etc/default/grub and then run update-grub again. :slight_smile:

Output:
# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES=“part_gpt part_msdos nvme”

Ran it again, and it looks like the same error:

[aahmad@aahmad-pc ~]$ sudo update-grub
Generating grub configuration file …
Found theme: /usr/share/grub/themes/manjaro/theme.txt
Found linux image: /boot/vmlinuz-5.8-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.8-x86_64.img
Found initrd fallback image: /boot/initramfs-5.8-x86_64-fallback.img
Found linux image: /boot/vmlinuz-5.7-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.7-x86_64.img
Found initrd fallback image: /boot/initramfs-5.7-x86_64-fallback.img
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings …
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 245
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.

It seems the error is not related to nvme warning. Maybe there were some other changes to the grub configuration files? If so, you should try to revert them.

EDIT. You can run sudo grub-mkconfig with no arguments and see if its output contains more informative error messages. Maybe you will be able to find “line 245”.

No errors that I can see, copying output below:
https://justpaste.it/2m618

I think you can run sudo update-grub and then after the error message look into /boot/grub/grub.cfg.new file, particularly at line 245.

The last line of the file is Line 242. Is there an easier way to fix this issue? Such as copying the original file or regenerating it somehow?

The original /etc/default/grub file can be found here:

Yet it is still a mystery how that error appeared.

Can I just replace it? Or do I need to make any other config changes?

Yes.
Maybe you should make a copy of the old file. Also note if there are any custom settings, for example, kernel parameters. And just in case keep a bootable installation media at hand.

Output with running update-grub with the original grub file:

[aahmad@aahmad-pc default]$ sudo update-grub
[sudo] password for aahmad: 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.8-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.8-x86_64.img
Found initrd fallback image: /boot/initramfs-5.8-x86_64-fallback.img
Found linux image: /boot/vmlinuz-5.7-x86_64
Found initrd image: /boot/intel-ucode.img /boot/initramfs-5.7-x86_64.img
Found initrd fallback image: /boot/initramfs-5.7-x86_64-fallback.img
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 222
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.

Can you check again that line in this file:

EDIT. I’m running out of ideas…

I think we found the syntax errors! Output below:

A lot of ‘^M’ in the config!

Possibly I need the original 60_memtest86+_proxy config file? Thoughts?

1 Like

I’m pretty sure those don’t belong there. They are probably what is causing the syntax error. How did they get there?

1 Like

I was using grub-customizer to try and remove some of the grub entrees as an earlier attempt (as someone recommended on Reddit). I’m assuming that it inserted these characters somehow and that’s causing the syntax error. Either way, I removed the application and will no longer use it.

What’s the easiest way to clean things up and get grub working again at this point?

A ^M ─ i.e. Ctrl+M ─ appearing at the end of every line in a plain text file is without any doubt the result of the file having been edited in Microsoft Windows (and/or MS-DOS).

DOS used/uses two characters as the end-of-line, being a newline character and a carriage return. Microsoft Windows has a lot of legacy behavior that it inherited from DOS, and as such it has also adopted this dual-character end-of-line. (Legacy macOS from before OS X in turn used a single carriage return as the end-of-line, without a newline character.)

UNIX systems ─ like GNU/Linux ─ on the other hand use only a single newline character as the end-of-line. Therefore, when opening a text file that has been edited in Microsoft Windows, you get to see the carriage return character Ctrl+M, which is usually represented as a ^M in UTF-8 character encoding, and as a in ISO-8859-1/ISO-8859-15.

I have seen many botched up configuration files in my time, back when I was running an IRC network with a couple of other people. I myself have been exclusively running GNU/Linux for over 20 years now, but my colleagues were all running Microsoft Windows on their machines, and the servers also ran GNU/Linux. So instead of logging into the servers by way of ssh and editing the configuration files there, they would simply download the file onto their local Windows PCs, edit it with Windows’ NotePad, and then uploaded the file to the server again by way of ftp. And that’s when you then got those syntax errors.

Many of the GNU/Linux editors can automatically convert a file with DOS/Windows-style line endings to UNIX line-endings and vice versa, but the dos2unix command line utility ─ it’s in the Community repository ─ can also be used.

3 Likes