3

I've been trying to configure Grub to give a hidden 3 second countdown, and then boot into the default option.

What appears to happen is that Grub will alternate randomly between doing just that, and showing the menu with a 25 second countdown.

This happens both on full reboot, and on restore from hibernate. I have not been able to establish any pattern which will predict when it happens. Sometimes it gives one config 2 or 3 times in a row, sometimes it switches.

How can I make it consistent?

Ubuntu Desktop 18.04

Contents of /etc/default/grub:

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=3
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT_STYLE=countdown
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nouveau.modeset=0"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=/dev/nvme0n1p3"
#GRUB_CMDLINE_LINUX_DEFAULT="text"
#GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
GRUB_INIT_TUNE="480 440 1"

I have also used grub-customizer 5.1.0.

Stewart
  • 586

1 Answers1

3

It turns out the problem is actually that a "recordfail" field is set in the file /boot/grub/grubenv

The way to reset that is with the command:

sudo /usr/bin/grub-editenv /boot/grub/grubenv unset recordfail

But what you really need is for this to be done as part of boot sequence, whether normal or from hibernate.

This can be done with a service.

Use this service descriptor:

[Unit]
Description=Unset recordfail in grubenv after hibernation.
After=hibernate.target

[Service]
Type=oneshot
ExecStart=/usr/bin/grub-editenv /boot/grub/grubenv unset recordfail

[Install]
WantedBy=hibernate.target hybrid-sleep.target

Then install it using the instructions from this answer:

Create the above descriptor as

/etc/systemd/system/grub-unset-recordfail.service

Then:

sudo systemctl start grub-unset-recordfail
sudo systemctl enable grub-unset-recordfail
sudo systemctl stop grub-unset-recordfail

Some references suggested you need to run sudo systemctl daemon-reload first, but I have not found this necessary.

Stewart
  • 586
  • 1
    thank u for this good idea. it works fine for me on my Ubuntu 19.10. I think, I'll include this in my script I'm writing to configure hibernate functionality. – almaceleste Mar 02 '20 at 18:45