Why does grub2-mkconfig command not reflect configuration change in /etc/default/grub?
Environment
- Red Hat Enterprise Linux 7
- grub2
Issue
-
Why does grub2-mkconfig command not reflect configuration change in /etc/default/grub?
-
There are multiple same parameters in /etc/default/grub. The latest parameter is only affected.
$ /cat etc/default/grub GRUB_TIMEOUT=5 GRUB_DEFAULT=1 GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=512M" <--- This option is not present on boot line GRUB_DISABLE_RECOVERY="true" GRUB_CMDLINE_LINUX="audit=1" <--- This option is only one present at boot time
Resolution
-
This is an expected behavior. If there exist multiple same parameters, the latest one is only reflected. Because grub2-mkconfig command is a shell script. The last parameter in duplicate parameters is valid.
The parameters need to be consolidated in each line. For example,-
Invalid configuration.
$ /cat etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=1
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=512M" <--- This line is not used, is replaced by...
GRUB_DISABLE_RECOVERY="true"
GRUB_CMDLINE_LINUX="audit=1" <--- by this line, the last GRUB_CMDLINE_LINUX instance
-
Valid configuration
$ /cat etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=1
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=512M audit=1" <--- The line is merged and properly handled.
GRUB_DISABLE_RECOVERY="true"
-
Root Cause
- /etc/default/grub file is used by grub2-mkconfig command which is a shell script. These parameters need to be aligned with bash grammar.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.