Grub2 creates multiple identical entries in menu

Asked by Stan McGregor on 2011-12-11

On my Dell Inspiron 510m I installed Ubuntu 11.10 in addition to Win XP to make a dual boot system. Now I have also installed OpenSuse 12.1 to make a triple boot system. In order not to destroy the boot process as set up by Ubuntu, I selected not to install a boot loader while installing OpenSuse. After rebooting into Ubuntu, I ran update-grub, which found the OpenSuse system and added it to the Grub boot menu. Now the triple boot works fine. However, Grub created 6 identical menu entries for the OpenSuse system.
I traced this to the 30_os-prober script in /etc/grub.d, which, in the section named 'linux', calls 'linux-boot-prober'.
When I ran linux-boot-prober to see what it does, I got this result:

/dev/sda7:/dev/sda7::/boot/vmlinuz:/boot/initrd:root=/dev/sda7
/dev/sda7:/dev/sda7::/boot/vmlinuz:/boot/initrd-3.1.0-1.2-default:root=/dev/sda7
/dev/sda7:/dev/sda7::/boot/vmlinuz:/boot/initrd:root=/dev/sda7
/dev/sda7:/dev/sda7::/boot/vmlinuz:/boot/initrd-3.1.0-1.2-default:root=/dev/sda7
/dev/sda7:/dev/sda7::/boot/vmlinuz-3.1.0-1.2-default:/boot/initrd-3.1.0-1.2-default:root=/dev/sda7
/dev/sda7:/dev/sda7::/boot/vmlinux-3.1.0-1.2-default.gz::root=/dev/sda7

which is obviously the cause of the 6 identical entries in the menu. I do not know why linux-boot-prober does this, but must
assume that there are good reasons for it.
I see two ways to avoid these multiple entries in the menu: either to manually edit the 'boot.cfg' file, which the documentation recommends not to do, or to modify the 30_os-prober script so as to suppress any menuentry lines which are identical to immediately preceding ones. I would prefer the latter. Can anyone suggest a solution?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu os-prober Edit question
Assignee:
No assignee Edit question
Solved by:
Stan McGregor
Solved:
2011-12-17
Last query:
2011-12-17
Last reply:
2011-12-12
Ubfan (ubfan1) said : #1

You can put the other OSes you want into the /etc/grub.d/40_custom, and move (or make non-executable?) the 30_os-prober. Getting rid of the Suse /boot/grub/grub.cfg file may also remove some duplication, try that first. Grub is a bit aggressive on "finding" other oses, even to the point of creating non-existent ones from old config files.

delance (olivier-delance) said : #2

Please convert this question into a bug, so perhaps developer will fix it for next release.
If you edit manually grub.cfg file, it will be overwritten at the next kernel delivery, and you will have to do it again.
Ubfan solution to move boot lines into 40 and to remove 30 seems to be the right solution for me.

Stan McGregor (stan-mcgregor) said : #3

Thank you for the advice and suggestions.
In my initial question I mistakenly wrote 'boot.cfg' which should of course have been 'grub.cfg'.
As stated there the OpenSuse installation was done without installing a boot loader, so there is no /boot/grub/grub.cfg file
in the OpenSuse filesystem, in that directory there are only a number of files with names containing either 'stage1' or 'stage2'.
I have examined the 30_os-prober script and the output from 'os-prober' and 'linux-boot-prober' and I understand
how the 6 identical menu items are generated by Grub2 under Ubuntu 11.10, but not why. If the intention is to find different releases of a Linux system, then in this particular case it isn't working.
The multiple identical entries in the Grub menu are not a problem for me, but I thought I should report what I had found.

For completeness here is some additional information:

Grub2 version: 1.99-12ubuntu5

Partitions:

Device Type Contents

/dev/sda1 vfat DellUtility
/dev/sda2 ntfs Windows XP C-drive
/dev/sda3 vfat Windows XP D-drive
/dev/sda4 extended partition
/dev/sda5 ext4 Ubuntu 11.10
/dev/sda6 linux swap
/dev/sda7 ext4 Open Suse 12.1 root partition
/dev/sda8 ext4 Open Suse 12.1 /home

os-prober run under Ubuntu 11.10 produces:

/dev/sda2:Microsoft Windows XP Professional:Windows:chain
/dev/sda7:openSUSE 12.1 (i586):SuSE:linux

Both the os-prober and linux-boot-prober scripts call /usr/share/os-prober/common.sh