1

There are two menu entries that I want to remove from my GRUB boot menu, so I commented them out of the /boot/grub/grub.cfg file:

menuentry 'Windows Boot Manager (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-efi-FCD5-F73E' {
    ...
}
# menuentry 'Ubuntu 16.04.3 LTS (16.04) (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-844ea196-bb78-4f18-b7fd-58be4c491e92' {
#   ...
# }
# submenu 'Advanced options for Ubuntu 16.04.3 LTS (16.04) (on /dev/sdb1)' $menuentry_id_option 'osprober-gnulinux-advanced-844ea196-bb78-4f18-b7fd-58be4c491e92' {
#   menuentry 'Ubuntu (on /dev/sdb1)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.10.0-37-generic.efi.signed--844ea196-bb78-4f18-b7fd-58be4c491e92' {
#       ...
#   }
#   ...
# }

I then run sudo update-grub as usual. However, doing so brings back the menu entries, which get uncommented from the grub.cfg file.

How can I get the menu entries to stay commented out after running update-grub so that they don't show up in the boot options? I realize that not running update-grub will keep out the menu entries, but I'd like to get rid of this unwanted behaviour from update-grub so that I don't have to manually comment out the menu entries each time I run this command.

Notes:

  • Both update-grub and update-grub2 bring back the unwanted menu entries.
  • The unwanted menu entries are duplicates. I already have menu entries for Ubuntu.
1

As stated above, editing /boot/grub/grub.cfg is not a good way to do this. There's a good chance you'll break it, and even if you don't, you'll probably find it reverted when a system update rolls in later at some point.

Explicitly adding a GRUB_OS_PROBER_SKIP_LIST value to /etc/default/grub is not a great solution either, as it requires you to manually find and block out the UUIDs of every bootable disk you could possibly plug into your machine. I'm also not sure that editing files in /etc/default is the preferred way to customize your Linux distribution's behaviour.

It's also not necessarily a great idea to disable /usr/bin/os-prober outright, as other programs could potentially depend on it for other purposes.

The best solution, then, is probably to work within the configuration files belonging grub and specifically purposed for manual human customization.

On Debian and Ubuntu, the automatically generated boot entries seem to be handled by /etc/grub.d/30_os-prober.

Simply delete this file or disable execution permissions on it, then regenerate the grub configuration to get rid of the automatically added entries. This worked on my machine:

sudo chmod -x /etc/grub.d/30_os-prober

sudo grub-mkconfig -o /boot/grub/grub.cfg sudo update-grub

You can watch the output of the configuration generation and check /boot/grub/grub.cfg to verify that the extraneous entries have been removed before rebooting.

| improve this answer | |
0

/boot/grub/grub.cfg

#

DO NOT EDIT THIS FILE

#

It is automatically generated by grub-mkconfig using templates

from /etc/grub.d and settings from /etc/default/grub

#

The proper way to edit grub entries is via /etc/default/grub and the files in /etc/grub.d/.

| improve this answer | |
0

This entries are generated from os-prober. Os-prober:

Description: utility to detect other OSes on a set of drives This package detects other OSes available on a system and outputs the results in a generic machine-readable format.

Take a look in /usr/bin there is a shell-skript from package os-prober.

You can remove the executable flag from the skript, Or deinstall os-prober.

Edit: Wrong place I mean /usr/bin/os-prober. Nott in /etc/grub.d

| improve this answer | |
0

I was able to remove entries generated by os-prober using following Grub configuration:

1.Check UUIDs for the disks using the command:

sudo blkid

2.Update /etc/default/grub file by adding the line:

GRUB_OS_PROBER_SKIP_LIST="UUID_OF_DISK_YOU_DONT_WANT_SCAN1 UUID_OF_DISK_YOU_DONT_WANT_SCAN2"

3.Regenerate Grub configuration:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

NOTE: grub2-mkconfig due to some reasons still displays information about the ignored disk, but it wasn't generated to final /boot/grub2/grub.cfg file.

| improve this answer | |

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.