grub.cfg gets larger and larger when menu entries are generated in another language

Bug #1176652 reported by Kees Bakker
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
os-prober (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The script in 40grub2 has some code to skip certain entries from grub.cfg. It goes like this:

    elif echo "$title" | grep -q '(on /dev/[^)]*)$'; then
        log "Skipping entry '$title':"
       log "appears to be an automatic reference taken from another menu.lst"
       ignore_item=1

(( Notice the "on" ))

However, if the grub.cfg was created on a system with a non standard LANG the grep does not find the match. This is particular nasty on a system with one boot partition and a few Linux root partitions. The end result of update-grub is a bigger grub.cfg after each run. It gets bigger and bigger. Also update-grub takes longer and longer to finish.

Here is an example of a menuentry on my system

    menuentry 'Ubuntu 11.04 (11.04) (op /dev/mapper/vol1-root1004)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/vmlinuz-3.5.0-28-generic--29cff8d9-4fb2-49ec-8c62-e13f2a961abd' {

Here is a session with running update-grub twice in a row.

root@rockie:~# echo $LANG
nl_NL.UTF-8
root@rockie:~# grep menuentry /boot/grub/grub.cfg|wc -l
34
root@rockie:~# update-grub
Aanmaken van 'grub.cfg'...
Linux-afbeelding is gevonden: /boot/vmlinuz-3.5.0-28-generic
Initrd-image gevonden: /boot/initrd.img-3.5.0-28-generic
Found memtest86+ image: /memtest86+.bin
Ubuntu 10.04.2 LTS (10.04) is gevonden op /dev/sda2
Ubuntu 11.04 (11.04) is gevonden op /dev/mapper/vol1-clayrootbackup
Ubuntu 10.04.1 LTS (10.04) is gevonden op /dev/mapper/vol1-root1004
voltooid
root@rockie:~# grep menuentry /boot/grub/grub.cfg|wc -l
88

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in os-prober (Ubuntu):
status: New → Confirmed
Revision history for this message
Benno Schulenberg (bennoschulenberg) wrote :

Indeed, grub.cfg gets larger and larger with _every_ run of the script (all my systems are localized to Dutch, which uses "op" not "on"). Yesterday, booting on my old laptop had become so slow, that I finally looked into it. It resulted that grub.cfg had grown to *seventeen thousand* lines, with hundreds and hundreds of repetitions of "[name of distro] (op /dev/sda3) (op /dev/sda7) (op /dev/sda3) ...". The grub.cfg files on the other partitions looked similar -- whenever any of them gets a new kernel, it copies all menu and submenu items from the other grub.cfg files, which of course include its own items, plus older copies of those items, plus still older copies, plus... A horrendous tangle.

So, I would suggest to change:

  elif echo "$title" | grep -q '(on /dev/[^)]*)$'; then

to:

  elif echo "$title" | grep -q '(\w\+ /dev/\w\+)$'; then

to hopefully make it translation resistant.

summary: - 40grub2 gets confused for menuentry generated in other languages
+ grub.cfg gets larger and larger when menu entries are generated in
+ another language
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.