failed saving grub configuration

Bug #1308833 reported by Terri Yu
64
This bug affects 13 people
Affects Status Importance Assigned to Milestone
Grub Customizer
New
Undecided
Unassigned

Bug Description

I'm running a dual-boot Windows 7 64-bit and Ubuntu 12.04 64-bit machine. Grub Customizer used to work for the first 1-2 kernel updates, but after that the grub configuration wasn't saving properly. It would save, but when I booted my machine, the GRUB menu entries were in a different order than what I had specified. Today, I updated Grub Customizer to 4.0.6 and now saving the configuration doesn't work at all. It gives an error message (see below).

-----------------------

Failed saving grub configuration!

Please take a look at the command line output below. If you think this is a bug of Grub Customizer, please create one at https://launchpad.net/grub-customizer! Generally Grub Customizer should prevent errors like this.

failed running 'grub-mkconfig -o "/boot/grub/grub.cfg"' output:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.5.0-48-generic
Found initrd image: /boot/initrd.img-3.5.0-48-generic
Found linux image: /boot/vmlinuz-3.5.0-47-generic
Found initrd image: /boot/initrd.img-3.5.0-47-generic
Found linux image: /boot/vmlinuz-3.5.0-46-generic
Found initrd image: /boot/initrd.img-3.5.0-46-generic
Found linux image: /boot/vmlinuz-3.5.0-23-generic
Found initrd image: /boot/initrd.img-3.5.0-23-generic
Found Windows 7 (loader) on /dev/sda1
Found linux image: /boot/vmlinuz-3.5.0-48-generic
Found initrd image: /boot/initrd.img-3.5.0-48-generic
Found linux image: /boot/vmlinuz-3.5.0-47-generic
Found initrd image: /boot/initrd.img-3.5.0-47-generic
Found linux image: /boot/vmlinuz-3.5.0-46-generic
Found initrd image: /boot/initrd.img-3.5.0-46-generic
Found linux image: /boot/vmlinuz-3.5.0-23-generic
Found initrd image: /boot/initrd.img-3.5.0-23-generic
Found memtest86+ image: /boot/memtest86+.bin
error: syntax error.
error: Incorrect command.
error: syntax error.
error: Incorrect command.
error: syntax error.
error: line no: 141
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.
done

Revision history for this message
Terri Yu (terriyu) wrote :
Revision history for this message
Terri Yu (terriyu) wrote :
Revision history for this message
Jaymax (v-email) wrote :

Adding to this since it seems sufficiently similar. Error text at bottom

I had to muck about a bit with my partitions to get grub into a primary MBR partition. I should probably have just re-installed mint after rearranging things, but now I'd far rather fix the existing install.

I can boot to mint from grub rescue with
set prefix=(hd0,msdos2)/grub
set root=(hd0,msdos2)
insmod linux
linux /vmlinuz-11.3.0-etc root=/dev/hda5
initrd /initrd.img-11-etc
boot

but I can't seem to get grub to show me the menu, and I can't seem to save the config file...

Please take a look at the command line output below. If you think this is a bug of Grub Customizer, please create one at https://launchpad.net/grub-customizer! Generally Grub Customizer should prevent errors like this.

failed running 'grub-mkconfig -o "/boot/grub/grub.cfg"' output:
Generating grub.cfg ...
using custom appearance settings
Found background image: /home/pauline/Desktop/green-background-2_00450547.jpg
Found linux image: /boot/vmlinuz-3.11.0-12-generic
Found initrd image: /boot/initrd.img-3.11.0-12-generic
Found memtest86+ image: /memtest86+.bin
Found linux image: /boot/vmlinuz-3.11.0-12-generic
Found initrd image: /boot/initrd.img-3.11.0-12-generic
File descriptor 11 (/proc/2690/mounts) leaked on lvs invocation. Parent PID 3948: /bin/sh
  No volume groups found
Found Windows 7 (loader) on /dev/sda1
Found Windows Recovery Environment (loader) on /dev/sda6
error: syntax error.
error: Incorrect command.
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 157
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.done

Revision history for this message
Paddy Landau (paddy-landau) wrote :

@Jaymax, I have had the problem on two different machines of Grub Customizer causing my Grub to become unmodifiable (so, when the kernel was updated, Grub was not).

I solved the problem in both cases by booting from a Live Ubuntu USB, installing Boot Repair, and repairing Grub. That will be the easiest way for you by far.

Boot Repair:
https://help.ubuntu.com/community/Boot-Repair#A2nd_option_:_install_Boot-Repair_in_Ubuntu

Revision history for this message
Jaymax (v-email) wrote : Re: [Bug 1308833] Re: failed saving grub configuration

Yup, boot repair did the trick. I needed to hand edit fstab a bit
afterwards, which was odd. But all good now. Thanks.

Revision history for this message
2CV67 (2cv67) wrote :

I have the same problem with an Asus Eeepc running Ubuntu 12.04LTS (32 bit) & Windows7.

It occurred today when I updated from kernel 3.11.0-19 to 3.11.0-23.20 & then tried to use GC to tidy up the grub screen.
:::::::::::::::::QUOTE:::::::::::::::::::::::::::::::
Failed saving grub configuration!

Please take a look at the command line output below. If you think this is a bug of Grub Customizer, please create one at https://launchpad.net/grub-customizer! Generally Grub Customizer should prevent errors like this.

failed running 'grub-mkconfig -o "/boot/grub/grub.cfg"' output:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.11.0-23-generic
Found initrd image: /boot/initrd.img-3.11.0-23-generic
Found linux image: /boot/vmlinuz-3.11.0-19-generic
Found initrd image: /boot/initrd.img-3.11.0-19-generic
Found Windows 7 (loader) on /dev/sda1
Found Windows Recovery Environment (loader) on /dev/sda2
Found Windows 7 (loader) on /dev/sda1
Found Windows Recovery Environment (loader) on /dev/sda2
error: syntax error.
error: Incorrect command.
error: syntax error.
error: Incorrect command.
error: syntax error.
error: line no: 98
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.
done
:::::::::::::::::::::::::::::::::

Revision history for this message
2CV67 (2cv67) wrote :
Revision history for this message
Jim Remington (remington) wrote :

I have the same problem, the failure is in line 151 of grub.cfg.new ( which defines function gfxmode).

boot-repair does not work. It asks me to remove GRUB 2 entries, but none are found as follows. boot repair then refuses to go futher, stating that "GRUB is still present. Please try again."

jims-dell:~/Desktop> sudo apt-get purge -y --force-yes grub*
sudo: No match.
jims-dell:~/Desktop>

Revision history for this message
Michael (miketut) wrote :

Please take a look at the command line output below. If you think this is a bug of Grub Customizer, please create one at https://launchpad.net/grub-customizer! Generally Grub Customizer should prevent errors like this.

failed running 'grub-mkconfig -o "/boot/grub/grub.cfg"' output:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.13.0-40-generic
Found initrd image: /boot/initrd.img-3.13.0-40-generic
Found linux image: /boot/vmlinuz-3.13.0-37-generic
Found initrd image: /boot/initrd.img-3.13.0-37-generic
Found linux image: /boot/vmlinuz-3.11.0-26-generic
Found initrd image: /boot/initrd.img-3.11.0-26-generic
Found linux image: /boot/vmlinuz-3.11.0-15-generic
Found initrd image: /boot/initrd.img-3.11.0-15-generic
File descriptor 8 (/proc/4417/mounts) leaked on lvs invocation. Parent PID 12625: /bin/sh
  No volume groups found
Found Windows 7 (loader) on /dev/sda1
Found Calculate Linux Desktop 14 KDE on /dev/sda3
Found linux image: /boot/vmlinuz-3.13.0-40-generic
Found initrd image: /boot/initrd.img-3.13.0-40-generic
Found linux image: /boot/vmlinuz-3.13.0-37-generic
Found initrd image: /boot/initrd.img-3.13.0-37-generic
Found linux image: /boot/vmlinuz-3.11.0-26-generic
Found initrd image: /boot/initrd.img-3.11.0-26-generic
Found linux image: /boot/vmlinuz-3.11.0-15-generic
Found initrd image: /boot/initrd.img-3.11.0-15-generic
Found memtest86+ image: /boot/memtest86+.bin
Found plpbt image: /boot/plpbt.bin
File descriptor 8 (/proc/4417/mounts) leaked on lvs invocation. Parent PID 14670: /bin/sh
  No volume groups found
Found Windows 7 (loader) on /dev/sda1
Found Calculate Linux Desktop 14 KDE on /dev/sda3
ошибка: syntax error.
ошибка: Incorrect command.
ошибка: syntax error.
ошибка: Incorrect command.
ошибка: syntax error.
error: line no: 143
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.
done

Revision history for this message
tuxayo (tuxayo) wrote :

# Same error
I also got this bug on 4 installs at least (Arch, Manjaro, Linux Mint) since the last two years at least. After doing modifications with grub-customizer (usually deleting many redundant entries), my config wouldn't apply although the the GUI and console output show no errors (that seems a separate issue to have grub-mkconfig failing and grub-customizer not noticing it).

So now when running grub-mkconfig I got:

Generating grub configuration file ...
Found theme: /boot/grub/themes/Antergos-Default/theme.txt
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initramfs image: /boot/initramfs-linux-fallback.img
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initramfs image: /boot/initramfs-linux-fallback.img
Found Antergos Linux release 16.4 (ISO-Rolling) on /dev/sda8
Found memtest86+ image: /boot/memtest86+/memtest.bin
Found memtest86+ image: /boot/memtest86+/memtest.bin
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 218
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.
done

# New detail to help finding the cause
I've found that my grub.cfg.new has CRLF end of lines at the exact line of the error.
As you can see in the attached screenshots @miketut, @remington, @terriyu have the same issues.
However, this in not the case for @2cv67, so you might suffer an unrelated bug.

The main question now is how do these CRLF EOLs end up in our generated files?
None of the files in my /etc/grub.d/ contains CRLF EOLs

# Workaround
I was able to apply my new grub config by doing:
dos2unix grub.cfg.new
And then replace the old grub.cfg by the now sanitized one.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.