grub2-mkconfig – Generate grub.cfg configuration file

The grub2-mkconfig command is used to generate the grub.cfg configuration file for the GRUB2 bootloader. This file contains the menu entries and settings for booting the operating system. This command is typically used after installing or updating the kernel or other system components that require changes to the bootloader configuration.


To generate the grub.cfg file, run the following command as root:

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

This command will scan the system for installed operating systems and generate a menu with entries for each one. It will also detect any changes to the system’s hardware configuration and update the bootloader accordingly.

By default, grub2-mkconfig looks for configuration files in /etc/grub.d and includes them in the generated grub.cfg file. These files contain scripts that define the menu entries and settings for specific operating systems or system components.

To customize the generated configuration, you can modify the scripts in /etc/grub.d or create your own. The scripts are executed in numerical order, so you can control the order in which menu entries are displayed by renaming the files with appropriate prefixes (e.g., 00_header, 10_linux, 20_memtest86+).


The following table lists the available options for grub2-mkconfig:

Option Description
-o FILE, --output=FILE Specify the output file for the generated configuration. Default is /boot/grub2/grub.cfg.
-d DIR, --directory=DIR Specify the directory containing the GRUB2 configuration files. Default is /boot/grub2.
-v, --verbose Print verbose output.
-h, --help Display help information.

Troubleshooting Tips

  • If the generated grub.cfg file does not contain the expected menu entries, check that the configuration scripts in /etc/grub.d are properly configured and executable.
  • If the system fails to boot after updating the grub.cfg file, try booting from a live CD or USB and regenerate the configuration with grub2-mkconfig.
  • If the system still fails to boot, check that the bootloader is installed correctly and that the correct partition is set as the boot device in the system’s BIOS or UEFI settings.


  • The grub.cfg file is automatically updated when the kernel or other system components are updated with the system package manager (e.g., yum, apt-get).
  • Changes to the configuration files in /etc/grub.d will not take effect until grub2-mkconfig is run again.
  • The grub.cfg file should not be edited manually, as changes may be overwritten by future updates or cause the system to fail to boot.