5

After today's update, Ubuntu asked me to replace some files and I blindly accepted. After I restarted PC after the update, I saw duplicate entries in the grub menu:

enter image description here

Here's the image of the grub customizer.

enter image description here

Apparently, Grub Customizer can not save edited information.

Is there a way to remove duplicates from Ubuntu 12.04 grub menu and set Windows 7 on first position?

5 Answers 5

8

For permanent fix:

sudo mv /etc/grub.d/30_os-prober /etc/grub.d/07_os-prober

and Windows will be on top even after updates

4

While a sudo update-grub2 should remove the duplicate enties, to bring the Windows menu-item at first position additionally do :

  1. sudo gedit /boot/grub/grub.cfg
  2. Cut the portion of text starting from
    ### BEGIN /etc/grub.d/30_os-prober ###
    menuentry "Windows 7...
    to
    }
    ### END /etc/grub.d/30_os-prober ###
    and pest it just before
    menuentry 'Ubuntu, with Linux..

  3. save the file and reboot.

  4. You have to perform steps(1-4) every time grub-pc package-update or a kernel-update happens to keep Windows menu-item at first place.

3
  • Glad to know that helped, please accept the answer if you are not looking for other alternatives.
    – Samik
    Jun 5, 2012 at 14:35
  • The Menuentry 'ubuntu with Linux', there are multiple of those. Which one is right to paste it before?
    – denNorske
    Mar 5, 2013 at 10:56
  • Having this issue, sudo update-grub(2) does NOT remove duplicates.
    – Kyo Kazuto
    Apr 20, 2023 at 22:04
3

i think you've already been helped. But just in case a newbie needs an easy way to change the order of the grub menu and even delete (careful here!!) entries, there is a nice GUI way in linux to do so, with the grub-customizer.

Go to the terminal and type:

sudo add-apt-repository ppstrong texta:danielrichter2007/grub-customizer


sudo apt-get update

sudo apt-get install grub-customizer

Then look up the newly installed grub customizer, start it and you can move windows or ubuntu upwards / downwards in the list.

1

I have just went from an upgrade from 11.04 to 12.04 LTS.

While I cannot find an "expected" listing of /etc/grub.d/ for different OS versions anywhere, from another computer I have access to, the original 11.04 entries are:

$ ls /etc/grub.d/
00_header        10_linux      20_memtest86+  40_custom  README
05_debian_theme  20_linux_xen  30_os-prober   41_custom

On the updated PC, after the update, I have:

$ ls /etc/grub.d/
00_header        10_os-prober  30_memtest86+     40_custom
05_debian_theme  20_linux      30_os-prober      41_custom
10_linux         20_linux_xen  30_uefi-firmware  README

Obviously, I've gotten some entries there which are duplicates - so not even running sudo update-grub2 as @Samik suggest does not remove duplicate entries in this case.

The answer for this case would obviously be to remove the duplicate _os-prober and _linux entries, and then running sudo update-grub2.

1
  • Thanks. Of course the one that helps me is at the bottom..
    – Kyo Kazuto
    Apr 20, 2023 at 22:09
1

You can also remove old unused kernel packages and this effectively removes also the grub entries and frees harddrive space. To do that you need to check what kernels are installed using:

 sudo dpkg -l | grep linux-image

And then you can remove the kernel image using:

 sudo apt-get remove linux-image-version_number

where version_number is the kernel version you want to remove. I recommend you leave at least two kernel versions available just in case something goes wrong.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .