update-grub ignoring some options in /etc/default/grub

Just installed another hard drive and noticed that grub automatically added the necessary menu entries to boot off it. I wanted to adjust these new entries by editing /etc/default/grub, but it seems some settings are ignored or overridden by the update-grub and grub-mkconfig scripts. Specifically these lines:

GRUB_TIMEOUT=2
GRUB_OS_PROBER_SKIP_LIST="469841589841479F"

I did remove the GRUB_HIDDEN_TIMEOUT=0 line as the documentation said it was deprecated and replaced it with:

GRUB_TIMEOUT_STYLE="hidden"

After running either script, the resulting grub.cfg file does contain:

if [ "${recordfail}" = 1 ] ; then
  set timeout=-1
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=hidden
    set timeout=2
  # Fallback hidden-timeout code in case the timeout_style feature is
  # unavailable.
  elif sleep --interruptible 2 ; then
    set timeout=0
  fi
fi
### END /etc/grub.d/00_header ###

So the timeout option is used here. The problem seems to be later with the /etc/grub.d/30_os-prober section. Before I had the second hard drive, there were obviously no entries from that. Now that there is, this gets added to grub.cfg:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (loader) (on /dev/sdb1)' --class windows --class os $menuentry_id_option 'osprober-chain-CA0E41BE0E41A3F3' {

[snip]
}
menuentry 'Windows Recovery Environment (loader) (on /dev/sdb2)' --class windows --class os $menuentry_id_option 'osprober-chain-469841589841479F' {

[snip]
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
  set timeout=10
fi
### END /etc/grub.d/30_os-prober ###

So, not only does it not ignore the partition I told it to, but the os-prober part of the script will not allow me to set a timeout of 0 AND forces a menu(I'm used to just holding down the left shift key when powering on if I ever want to change boot options).

A second or two timeout delay is only mildly annoying, but having a menu forced when I explicitly don't want one, and this menu including a partition that should never be listed is much more so.

Short of editing grub.cfg every time, or tweaking /etc/grub.d/30_os-prober (which may get overwritten during an upgrade?) is there a fix for this?

Thanks!


Solution 1:

Grub checks GRUB_OS_PROBER_SKIP_LIST against EXPUUID not UUID, so the proper format for GRUB_OS_PROBER_SKIP_LIST is UUID@/dev/???? for example:

GRUB_OS_PROBER_SKIP_LIST="A3F5-6DF3@/dev/sda1"

Solution 2:

How I cleaned up grub.cfg

0- when a new [Linux] distribution is installed grub-mkconfig will use /etc/grub.d/10_linux to implement the Linux kernel and recovery menuentries. OS-Prober will [/etc/grub.d/30_os-prober] use 30_os-prober to find other OS [Operating Systems]

often the start up menu may have unwanted, superfluous or even dead entries. ( a dead entry in my boot menu started me on this quest.) I looked at /boot/grub/grub.config to familiarize myself with menuentries.

to remove the unwanted entry I did the following as root:

1- the dead entry was found by 30_os-prober. I copied the entries [made by 30_os-prober in /boot/grub/grub.cfg] I wanted to 40_custom.

2- I put GRUB_DISABLE_OS_PROBER="true" in /etc/default/grub

3- I tested the new configuration in a boot backup directory. sudo grub-mkconfig -o menu-test.cfg [the filename is arbitrary]

4- when the test file looked the way I wanted it: sudo update grub

the next time I booted the unwanted entry was gone but those I wanted were at the end.

Solution 3:

The best way to find the UUID is this way:

sudo grub-probe --target=fs_uuid --device /dev/sda6

Finding the UUID with blkid will not work for Mac OS X partitions.