Grub menu no more matches choices in Grub-customizer

Asked by gonczi on 2014-02-21

Hi !

I use Grub-customizer for a long time without any trouble. After the installation of the last kernel (3.2.0-59) for ubuntu 12.04, I wanted to move the previous kernel in the "previous versions" sub-menu, but this change does not appear in the Grub menu. I also tried to change the timeout from 10s to 20s but Grub dit not took account of this change. Then I tried to run update-grub but this gave the messages:

error: line no: 121
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub

Here is the /etc/default/grub file:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

GRUB_DEFAULT="0"
#GRUB_HIDDEN_TIMEOUT="0"
GRUB_HIDDEN_TIMEOUT_QUIET="true"
GRUB_TIMEOUT="10"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL="console"

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE="1366x768x24"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID="true"

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

GRUB_SAVEDEFAULT="false"

Remark: exactly the same behaviour appears on an other computerwith the same OS

Thank you for help

Question information

Language:
English Edit question
Status:
Solved
For:
Grub Customizer Edit question
Assignee:
No assignee Edit question
Solved by:
Daniel Richter
Solved:
2014-02-22
Last query:
2014-02-22
Last reply:
2014-02-21

is there a grub.cfg.new? If so, what's the content? Of not, that's the output of "sudo grub-mkconfig"?

* Changed Status to needs information *

gonczi (gonczi) said : #3

Yes there is a grub.cfg.new in /boot/grub:

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

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
set default="0"
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 recordfail {
  set recordfail=1
  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=1366x768x24
  load_video
  insmod gfxterm
  insmod part_msdos
  insmod ext2
  set root='(hd0,msdos6)'
  search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
  set locale_dir=($root)/boot/grub/locale
  set lang=fr_FR
  insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
  set timeout=-1
else
  set timeout=20
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
  clear
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux_proxy ###
menuentry "Ubuntu, avec Linux 3.2.0-59-generic-pae" --class ubuntu --class gnu-linux --class gnu --class os {
 recordfail
 gfxmode $linux_gfx_mode
 insmod gzio
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 linux /boot/vmlinuz-3.2.0-59-generic-pae root=UUID=0199f84e-2d97-4923-bcb0-e5c3b148a393 ro quiet splash $vt_handoff
 initrd /boot/initrd.img-3.2.0-59-generic-pae
}
menuentry "Ubuntu, with Linux 3.2.0-59-generic-pae (recovery mode)" --class ubuntu --class gnu-linux --class gnu --class os {
 recordfail
 insmod gzio
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 echo 'Chargement de Linux 3.2.0-59-generic-pae ...'
 linux /boot/vmlinuz-3.2.0-59-generic-pae root=UUID=0199f84e-2d97-4923-bcb0-e5c3b148a393 ro recovery nomodeset
 echo 'Chargement du disque mémoire initial ...'
 initrd /boot/initrd.img-3.2.0-59-generic-pae
}
submenu "Versions précédentes"{
menuentry "Ubuntu, avec Linux 3.2.0-58-generic-pae" --class ubuntu --class gnu-linux --class gnu --class os {
 recordfail
 gfxmode $linux_gfx_mode
 insmod gzio
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 linux /boot/vmlinuz-3.2.0-58-generic-pae root=UUID=0199f84e-2d97-4923-bcb0-e5c3b148a393 ro quiet splash $vt_handoff
 initrd /boot/initrd.img-3.2.0-58-generic-pae
}
menuentry "Ubuntu, with Linux 3.2.0-58-generic-pae (recovery mode)" --class ubuntu --class gnu-linux --class gnu --class os {
 recordfail
 insmod gzio
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 echo 'Chargement de Linux 3.2.0-58-generic-pae ...'
 linux /boot/vmlinuz-3.2.0-58-generic-pae root=UUID=0199f84e-2d97-4923-bcb0-e5c3b148a393 ro recovery nomodeset
 echo 'Chargement du disque mémoire initial ...'
 initrd /boot/initrd.img-3.2.0-58-generic-pae
}
function gfxmode {
 set gfxpayload="${1}"
 if [ "${1}" = "keep" ]; then
  set vt_handoff=vt.handoff=7
 else
  set vt_handoff=
 fi
}
if [ "${recordfail}" != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
menuentry "Ubuntu, avec Linux 3.2.0-57-generic-pae" --class ubuntu --class gnu-linux --class gnu --class os {
 recordfail
 gfxmode $linux_gfx_mode
 insmod gzio
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 linux /boot/vmlinuz-3.2.0-57-generic-pae root=UUID=0199f84e-2d97-4923-bcb0-e5c3b148a393 ro quiet splash $vt_handoff
 initrd /boot/initrd.img-3.2.0-57-generic-pae
}
menuentry "Ubuntu, avec Linux 3.2.0-57-generic-pae (mode de dépannage)" --class ubuntu --class gnu-linux --class gnu --class os {
 recordfail
 insmod gzio
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 echo 'Chargement de Linux 3.2.0-57-generic-pae ...'
 linux /boot/vmlinuz-3.2.0-57-generic-pae root=UUID=0199f84e-2d97-4923-bcb0-e5c3b148a393 ro recovery nomodeset
 echo 'Chargement du disque mémoire initial ...'
 initrd /boot/initrd.img-3.2.0-57-generic-pae
}
}
### END /etc/grub.d/10_linux_proxy ###

### BEGIN /etc/grub.d/11_linux_xen ###
### END /etc/grub.d/11_linux_xen ###

### BEGIN /etc/grub.d/14_memtest86+ ###
menuentry "Memory test (memtest86+)" {
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 0199f84e-2d97-4923-bcb0-e5c3b148a393
 linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/14_memtest86+ ###

### BEGIN /etc/grub.d/15_os-prober ###
menuentry "Windows 7 (loader) (on /dev/sda2)" --class windows --class os {
 insmod part_msdos
 insmod ntfs
 set root='(hd0,msdos2)'
 search --no-floppy --fs-uuid --set=root F224BB3524BAFBA3
 chainloader +1
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
  set timeout=10
fi
### END /etc/grub.d/15_os-prober ###

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

### BEGIN /etc/grub.d/17_custom ###
if [ -f $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/17_custom ###

### BEGIN /etc/grub.d/18_uefi-firmware ###
### END /etc/grub.d/18_uefi-firmware ###

The problem is because of this script code:

function gfxmode {
 set gfxpayload="${1}"
 if [ "${1}" = "keep" ]; then
  set vt_handoff=vt.handoff=7
 else
  set vt_handoff=
 fi
}

It has been moved into the submenu, but grub doesn't allow function declarations inside of submenus. Grub Customizer moved this (hidden) script-code entry into the submenu while you've moved the menuentry into this location. Seems like I have to change the logic…

Here's your solution:
 - click "Affichage" or "View" -> "Show Placeholders"
 - then look at the submenu named "Versions précédentes". There should be an entry namend "(script du code)".
 - move it to the top of the list (or at least out of the submenu)

gonczi (gonczi) said : #5

Thanks Daniel Richter, that solved my question.

Will Cicola (wcicola) said : #6

Many thanks, Daniel...you have solved my problem as well!

Temporal (joaoplim) said : #7

This change fixed this problem I had on this new bug:
https://bugs.launchpad.net/grub-customizer/+bug/1494998

Bruno Bruzzano (brunano21) said : #8

Thanks a lot Daniel, you solved the same problem.
https://answers.launchpad.net/grub-customizer/+question/244345

I just move the script code outside the submenu and update-grub worked as expected.
Thanks again!

Bruno Bruzzano (brunano21) said : #9

sorry, the issue description is at https://answers.launchpad.net/ubuntu/+question/271308.

dusoft (dusoft-staznosti) said : #10

Also other "scripts" and "Incoming versions" needs to be moved out of submenu.

Seems that grub-customizer just does not have basic error checks!! What a fail.