How to Stop update-grub from Scanning All Drives

debiangrub

Every time update-grub is run all hard drives are scanned. Each drives that is in standby state will spin up to go idle. This is a waste of energy. We use update-grub version 1.98:

# update-grub -v
grub-mkconfig (GRUB) 1.98+20100804-14+squeeze1

Regression

  1. There is a GRUB_DISABLE_OS_PROBER=true option in the /etc/default/grub file. But that seems to only work from version 2 and up. At least it doesn't stop scanning all drives in our version 1.98.

  2. There is a /etc/grub.d/20_linux_xen script that might be run as a part of update-grub. After removing execute rights for all users with chmod a-x /etc/grub.d/20_linux_xen all drives do still spin up.

How to stop update-grub from scanning each and every hard drive?

Best Answer

In file /etc/grub.d/30_os-prober the line

OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"

makes all drives spin (standby -> idle). Os-prober is a utility to find Linux installations at drives other then your boot drive. It is the os-prober that needs to be disabled.

  1. One way is to remove the package: apt-get --purge remove os-prober.
  2. Another way is to remove executable rights for os-prober. First find the location of os-prober using $ which os-prober. Output might look like: /usr/bin/os-prober. The remove the executable rights for all users for that file: # chmod a-x /usr/bin/os-prober
  3. Another way is to remove executable rights for 30_os-prober. Find the location of 30_os-prober using $ locate /30_os-prober. Output might look like: /etc/grub.d/30_os-prober. The remove the executable rights for all users for that file: # chmod a-x /etc/grub.d/30_os-prober
  4. Yet another way is to skip the execution of /etc/grub.d/30_os-prober. For example by making the GRUB_DISABLE_OS_PROBER=true option work in our grub version 1.98. This can be done by inserting in file /etc/grub.d/30_os-prober the code below the line set -e:

...

if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
  exit 0
fi
Related Question