Grub2-mkconfig isn't applying settings in /etc/default/grub

I’m running RL 9.3 fully updated. When I increase the grub_timeout setting in the default grub file, the change isn’t applied when I run grub2-mkconfig -o /etc/grub2.cfg. I’m not sure why. Rebooting just gives the same 5 second timeout. I’d like it to be 60 seconds.

Thanks, all

Try this:

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

First, there is a thing about GRUB that is new in 9.3, although it is not about the timeout but kernel options: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/9.3_release_notes/new-features#new-features-boot-loader


The /etc has mere symlinks to grub.cfg. On all el9:

$ ls -l /etc/grub2*
lrwxrwxrwx. 1 root root   22 Oct  9 11:05 /etc/grub2-efi.cfg -> ../boot/grub2/grub.cfg
lrwxrwxrwx. 1 root root   22 Oct  9 11:05 /etc/grub2.cfg -> ../boot/grub2/grub.cfg

Logically, the grub2-mkconfig should detect whether is given a symlink, because it will write not only to the grub.cfg but also to files relative to its true location.

Well running grub2-mkconfig -o /etc/grub2.cfg as root does update /boot/grub2/grub.cfg for me. It should also work for user with sudo privileges with the command prefaced with sudo.

sudo grub2-mkconfig -o /etc/grub2.cfg

So there is the possibility of user error in typing the command.
Is RL9.3 the only OS on the machine? Assuming it is posting the contents of these two files may shed some light if no typo’s are involved.

sudo less /etc/default/grub
GRUB_TIMEOUT=8
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="resume=UUID=71da8f2b-df89-4d45-b763-9768884fea6f selinux=0 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
/etc/default/grub (END)
sudo less /boot/grub2/grubenv
# GRUB Environment Block
# WARNING: Do not edit this file by tools other than grub-editenv!!!
saved_entry=ba3fd5ffa1514c2bb468fa289f69faa0-5.14.0-362.18.1.el9_3.x86_64
menu_auto_hide=1
boot_success=1
boot_indeterminate=0
selinux=0
#########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
/boot/grub2/grubenv (END)

You can copy and paste highlighted text from a terminal using the mouse right click menu. In the forum use the </> code block menu option at the top of the editor field to post your output here.

I get the same result either using the -0 parameter or writing to the /etc location. The file is just not written. I’m running the command after using sudo to login. Do I have to actually be logged in as root instead of using sudo? It doesn’t matter what I change in /etc/default/grub. the cfg files isn’t updated at all.

See my post above. Use sudo to preface the command and not to logn.

Here is contents of both on my system. It’s dual booting Windows 11 and RL 9.3:

GRUB_TIMEOUT=90
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="resume=UUID=7101ee64-4965-41e1-9e3e-affad0737949 rd.lvm.lv=rockydesk/root rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

# GRUB Environment Block
# WARNING: Do not edit this file by tools other than grub-editenv!!!
saved_entry=1c2f459700c24f9fb6144322a120149f-5.14.0-362.18.1.el9_3.x86_64
menu_auto_hide=1
boot_success=1
boot_indeterminate=0
###############

I presume you truncated the “#” marks in your post of the grubenv file. If you did not then that file is invalid. Other than that those file contents are not the issue. I suspect you issue is at the command line either a typo or lack of sudo preface.

I’m running the command correctly with sudo preface and the grubenv file is truncated. Could there be any other explanation for why the settings in the /etc/defatult/grub file aren’t applied with the command?

So, deleting both /boot/grub2/grub.cfg and /boot/efi/EFI/rocky/grub.cfg and then running dnf reinstall grub2-efi* grub2-common did the trick. My changes in /etc/default/grub were applied, but now changes aren’t applied again if I run the grub-mkconfig command. I would say this is a bug. I’ll have to reinstall grub2-efi and grub2-common each time I want to update the default grub config file.

What is the size of the grub.cfg in /boot/efi/EFI/rocky/

Mine is 149 bytes. It is just a stub file pointing to your /boot partition where the real grub.cfg is

sudo ll /boot/efi/EFI/rocky/grub.cfg
-rwx------ 1 root root 149 Dec 22  2022 /boot/efi/EFI/rocky/grub.cfg

If it is 8000 bytes then I know what the problem is.
I can’t duplicate your issue on my rl9 system. When I change the timeout it is changed in /boot/grub2/grub.cfg.
If in the past you ran

sudo grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg

then you would have overwritten the stub file and made it the author of the boot menu. Your subsequent efforts editing the /boot/grub2/grub.cfg are no longer seen on boot because that file is nolonger read.

Mine is 159 bytes:

ll /boot/efi/EFI/rocky/grub.cfg
-rwx------ 1 root root 159 Jan 28 13:44 /boot/efi/EFI/rocky/grub.cfg

What you’re describing isn’t the issue, especially since I reinstalled grub and still get the same thing. It’s also happening on my laptop single booting RL 9.3.

Here is the contents of the /boot/efi/EFI/rocky/grub.cfg file:

search --no-floppy --root-dev-only --fs-uuid --set=dev 9e81e5dc-7e40-46e9-91c2-92681168f07a
set prefix=($dev)/grub2
export $prefix
configfile $prefix/grub.cfg

The fs-uuid is correct based on lsblk -f

The place, where the value of GRUB_TIMEOUT from /etc/default/grub is used is the
/etc/grub.d/00_header (which is called by grub2-mkconfig) and it creates content for the grub.cfg.


I do get:

$ sudo grub2-mkconfig | grep -3 timeout=10
Generating grub configuration file ...
terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=10
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###

Adding boot menu entry for UEFI Firmware Settings ...
done

based on:

$ cat /etc/default/grub
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="resume=UUID=af95..042 rd.driver.blacklist=nouveau"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_DISABLE_OS_PROBER=true

(but that is with grub2-tools-2.06-70.el9_3.1.alma.1.x86_64)

I get the same output that you do. This is with grub2-tools-2.06-70.el9_3.2.rocky.0.2.x86_64. The variable for timeout is being read properly in the 00_header script but it isn’t getting written info the /boot/grub2/grub.cfg file.

If grub2-mkconfig does write what one expects into stdout, but not to file specified with -o, then one could redirect the stdout to a file.

Then question remains, why the -o fails to write?

Is there an official bug reporting location for Rocky where I could report it and have the Rocky team take a look at it?

You can report it by reading this link, but as you can see other users are not exhibiting the problem you’re describing. Thus, this may be an isolated issue.

[root@xmpp01 grub2]# grep timeout= /boot/grub2/grub.cfg
  set timeout=5
  set timeout=5
    set timeout=60
    set orig_timeout=${timeout}
      # timeout_style=menu + timeout=0 avoids the countdown code keypress check
      set timeout=0
      set timeout=1
    set timeout="${menu_show_once_timeout}"
[root@xmpp01 grub2]# grep TIMEOUT /etc/default/grub
GRUB_TIMEOUT=10
[root@xmpp01 grub2]# grub2-mkconfig -o /etc/grub2.cfg
Generating grub configuration file ...
Adding boot menu entry for UEFI Firmware Settings ...
done
[root@xmpp01 grub2]# grep timeout= /boot/grub2/grub.cfg
  set timeout=10
  set timeout=10
    set timeout=60
    set orig_timeout=${timeout}
      # timeout_style=menu + timeout=0 avoids the countdown code keypress check
      set timeout=0
      set timeout=1
    set timeout="${menu_show_once_timeout}"

You will need to verify that /etc/grub2.cfg is indeed a symlink to /boot/grub2/grub.cfg.

Yes, /etc/grub2.cfg is an active symlink, but only to the root user.

It would really help to see the command input you typed in the terminal as well as the following lines of output, for example:

$ sudo grub2-mkconfig -o /etc/grub2.cfg 
[sudo] password for jbk: 
Generating grub configuration file ...
Found Rocky Linux 8.7 (Green Obsidian) on /dev/sdc2
Adding boot menu entry for UEFI Firmware Settings ...
done

and then check the modification time on grub.cfg and post:

$ sudo ls -la /boot/grub2/
total 48
drwx------. 5 root root  4096 Jan 30 17:13 .
dr-xr-xr-x. 5 root root  4096 Jan 26 07:07 ..
-rw-r--r--. 1 root root    64 Dec 15  2022 device.map
drwx------. 2 root root  4096 Jan 26 07:07 fonts
-rw-------  1 root root  8567 Jan 30 17:15 grub.cfg

This might help in diagnosing why you are not succeeding. Today I created a new instance of rl9 in a vm using a boot install image so I would download the latest 9.3 files. I then changed the timeout with the means discussed here to 12 seconds. I rebooted and was shown a menu screen with a 12 second countdown. The default was 5 seconds.

ROCKY-DESK ddev-projects]$ sudo grub2-mkconfig -o /etc/grub2.cfg
Generating grub configuration file ...
Adding boot menu entry for UEFI Firmware Settings ...
done
[stalkert@ROCKY-DESK ddev-projects]$ sudo ls -la /boot/grub2/
total 20
drwx------. 3 root root   68 Jan 30 16:22 .
dr-xr-xr-x. 5 root root 4096 Jan 26 16:12 ..
-rwx------  1 root root  232 Jan 29 15:33 custom.cfg
drwx------. 2 root root   25 Jan 30 14:58 fonts
-rwx------  1 root root 6544 Jan 30 16:24 grub.cfg
-rw-------  1 root root 1024 Jan 30 16:17 grubenv

Great, so now it’s updating after several reinstalls. I was also running the output to /boot/grub2/grub.cfg. This boot directory has never had a device.map file, if that matters. Another issue is that when I reboot after logging into Rocky, I just boot right back to the OS, The grub menu never appears. I can’t select Windows that I add with the custom.cfg file you see in the directory. grubenv doesn’t get updated. What triggers that to update?