So I have my grub set up to show at every boot, with a timeout of 10 seconds.
Lately, though, it's been reverting to 30 seconds. I tracked this down to what is known as a 'recordfail'... the machine failed to properly record a clean shutdown... apparently... but not really.
In perusing the code in /etc/grub.d/00_header, it shows:
quick_boot="1"
Then further down it shows:
if [ "$quick_boot" = 1 ]; then
cat <<EOF
function recordfail {
set recordfail=1
EOF
There's that fake recordfail!
And if recordfail:
make_timeout ()
{
cat << EOF
if [ "\${recordfail}" = 1 ] ; then
set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
else
EOF
That's a bug. Not really sure how quick_boot got set to 1. Perhaps when I disabled suspend, hibernation, sleep and hybrid sleep?
sudo systemctl stop sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl disable sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
However, when I set quick_boot="0", it still reverts to 30 seconds!
So I continued tracking down the problem... in /etc/grub.d/10_linux, it sets quick_boot="1", so I set it to "0" there, too.
And in that file:
if [ "$quick_boot" = 1 ]; then
echo " recordfail" | sed "s/^/$submenu_indentation/"
fi
And the same in /etc/grud.d/10_linux_zfs:
quick_boot="1"
and...
if [ "${quick_boot}" = 1 ]; then
echo "${submenu_indentation} recordfail"
fi
And the same thing in /etc/grub.d/30_os_prober:
quick_boot="1"
and...
adjust_timeout () {
if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
cat << EOF
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
set timeout=30
fi
EOF
fi
}
This thing's just insistent on setting quick_boot="1", which triggers a fake recordfail, which makes grub show up for 30 seconds!
I set quick_boot="0" for all of the above. Now to reboot...
[EDIT]
Nope, still at 30 seconds. Anyone got any ideas?
[EDIT 2]
Trying:
sudo sed -i "/recordfail_broken=/{s/1/0/}" /etc/grub.d/00_header
sudo update-grub
sudo reboot
[EDIT 3]
Nope, still at 30 seconds.
[EDIT 4]
Trying this:
In /etc/grub.d create two files and make them executable...
/etc/grub.d/25_pre-os-prober
#! /bin/sh
set -e
# Save the $timeout and $timeout_style values set by /etc/grub.d/00_header
# before /etc/grub.d/30_os-prober messes them up.
cat << EOF
set timeout_bak=\${timeout}
set timeout_style_bak=\${timeout_style}
EOF
/etc/grub.d/35_post-os-prober
#! /bin/sh
set -e
# Reset $timeout and $timeout_style to their original values
# set by /etc/grub.d/00_header before /etc/grub.d/30_os-prober messed them up.
cat << EOF
set timeout=\${timeout_bak}
set timeout_style=\${timeout_style_bak}
EOF
[EDIT 5]
Nope, that didn't work, either. Ok, I'm hacking the code.
/etc/grub.d/00_header:
make_timeout ()
{
cat << EOF
#if [ "\${recordfail}" = 1 ] ; then
if true=true ; then
set timeout=${GRUB_RECORDFAIL_TIMEOUT:-15}
else
EOF
If that doesn't work, then the timeout is being set elsewhere.
[EDIT 6]
Nope, that didn't work, either.
Trying:
/etc/grub.d/30_os-prober
adjust_timeout () {
# Line below is added 23 Dec 2022
set timeout=15
if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
cat << EOF
set timeout_style=menu
if [ "\${timeout}" = 0 ]; then
set timeout=15
fi
EOF
fi
}
[EDIT 7]
Nope, that didn't work, either. Something else has got to be setting the grub menu timeout. I'm reverting all the changes until I can do more research.