0

I run Ubuntu 20.04 and have this error when I do an update-grub command:

root@ubuntu:/# update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Création du fichier de configuration GRUB…
Image Linux trouvée : /boot/vmlinuz-5.8.0-25-generic
Image mémoire initiale trouvée : /boot/initrd.img-5.8.0-25-generic
Image Linux trouvée : /boot/vmlinuz-5.4.0-53-generic
CentOS Linux 8 (Core) trouvé sur /dev/sdb9
Image Linux trouvée : /boot/vmlinuz-5.8.0-25-generic
Image mémoire initiale trouvée : /boot/initrd.img-5.8.0-25-generic
Image Linux trouvée : /boot/vmlinuz-5.4.0-53-generic
CentOS Linux 8 (Core) trouvé sur /dev/sdb9
Image Linux trouvée : /boot/vmlinuz-5.8.0-25-generic
Image mémoire initiale trouvée : /boot/initrd.img-5.8.0-25-generic
Image Linux trouvée : /boot/vmlinuz-5.4.0-53-generic
Image Linux trouvée : /boot/vmlinuz-5.8.0-25-generic
Image mémoire initiale trouvée : /boot/initrd.img-5.8.0-25-generic
Image Linux trouvée : /boot/vmlinuz-5.4.0-53-generic
CentOS Linux 8 (Core) trouvé sur /dev/sdb9
Image Linux trouvée : /boot/vmlinuz-5.8.0-25-generic
Image mémoire initiale trouvée : /boot/initrd.img-5.8.0-25-generic
Image Linux trouvée : /boot/vmlinuz-5.4.0-53-generic
Adding boot menu entry for UEFI Firmware Settings
erreur : syntax error.
erreur : Incorrect command.
erreur : syntax error.
erreur : Incorrect command.
erreur : syntax error.
Erreur de syntaxe à la ligne 159
Des erreurs de syntaxe sont détectées dans le fichier de configuration
de GRUB. Veuillez vérifier qu'il n'y a pas d'erreur dans les fichiers
/etc/default/grub et /etc/grub.d/*. Sinon veuillez signaler un bogue
en joignant le fichier /boot/grub/grub.cfg.new.

I checked the file /boot/grub/grub.cfg.new at line 159 as suggested, and here is the snippet corresponding to the line and its surroundings:

152 ### END /etc/grub.d/31_linux_xen ###
153 
154 ### BEGIN /etc/grub.d/34_memtest86+ ###
155 ### END /etc/grub.d/34_memtest86+ ###
156 
157 ### BEGIN /etc/grub.d/35_os-prober_proxy ###
158 submenu "Options avancées pour Ubuntu"{
159 function gfxmode {
160         set gfxpayload="${1}"
161         if [ "${1}" = "keep" ]; then
162                 set vt_handoff=vt.handoff=7
163         else
164                 set vt_handoff=
165         fi
166 }
167 if [ "${recordfail}" != 1 ]; then
168   if [ -e ${prefix}/gfxblacklist.txt ]; then
169     if hwmatch ${prefix}/gfxblacklist.txt 3; then
170       if [ ${match} = 0 ]; then
171         set linux_gfx_mode=keep
172       else
173         set linux_gfx_mode=text
174       fi
175     else
176       set linux_gfx_mode=text
177     fi
178   else
179     set linux_gfx_mode=keep
180   fi
181 else
182   set linux_gfx_mode=text
183 fi
184 export linux_gfx_mode

I can see that there seems to be a problem with line 158 submenu "Options avancées pour Ubuntu"{ which never closes its "{" but I am unable to find where this comes from...

I already tried running boot-repair (as suggested on this answer GRUB error: syntax error. error: Incorrect command) but the first command asked to launch is: sudo chroot "/mnt/boot-sav/mapper/isw_cbgbbifgbg_Volume1p2" dpkg --configure -a and it gives me the same problem of syntax error.

6
  • Proxy files are not grub2, but from grub customizer. If Customizer not working, you have to do a total reinstall of grub2. I once had a missing } and it showed error at end of file when it was really in the middle somewhere. But it was my own 40_custom that had the error. Did you change settings in /etc/default/grub? If those are not correct they can cause similar errors.
    – oldfred
    Nov 29 '20 at 3:34
  • I didn't change my /etc/defaut/grub but I had grub-customizer. How can I do a total reinstall of grub ? I am from a live USB key.
    – Gabriel C
    Nov 29 '20 at 16:00
  • From live installer, probably easiest is Boot-Repair. help.ubuntu.com/community/Boot-Repair & sourceforge.net/p/boot-repair/home/Home Other option is a full chroot into your system and use that to update/modify system. askubuntu.com/questions/53578/…
    – oldfred
    Nov 29 '20 at 16:56
  • Thank you for your help. I figured out that the issue came from the installation of my third OS (Centos) which broke up the execution order somehow of grub-update. Some instructions in the file /boot/grub/grub.cfg.new had "^M" ending lines... anyway I didn't have time to repair in time I had to reinstall my Ubuntu and remove my Centos.
    – Gabriel C
    Nov 30 '20 at 21:05
  • If os-prober does not correctly create a new boot entry due to some logic issue, often better to just turn it off and copy a good boot stanza from the other install into 40_custom.
    – oldfred
    Nov 30 '20 at 22:01
1

The update-grub command executes grub-mkconfig -o /boot/grub/grub.cfg "$@", which in turn executes the scripts in directory /etc/grub.d/. Those scripts create the contents of grub.cfg, and the comment lines like

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

will indicate which script is responsible for each part of the grub.cfg file.

In your case, you should probably investigate the /etc/grub.d/35_os-prober_proxy script, and possibly the scripts immediately after it in the directory (in default ASCII alphanumberical sorting order).

On the other hand, in my Debian 10 system, the function gfxmode { line is part of the output of /etc/grub.d/10_linux, which is responsible for generating the plain Linux boot entries, then there is another script 20_linux_xen to create boot entries for Xen-style virtualization if it's installed, and then 30_os-prober to detect and add boot entries for other operating systems. Apparently Ubuntu does things somewhat differently, but it makes me suspect the parts of grub.cfg may have been produced out of order somehow.

1
  • Thank you for your help. I figured out that the issue came from the installation of my third OS (Centos, alongside my dual boot) which broke up the execution order somehow of grub-update. Some instructions in the file /boot/grub/grub.cfg.new had "^M" ending lines... anyway I didn't have time to repair in time I had to reinstall my Ubuntu and remove my Centos because I had to work on monday...
    – Gabriel C
    Nov 30 '20 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.