When I update grub, the file /etc/default/grub is sourced. What is that about? [duplicate]

I have seen that grub2 configuration files exist in so many different locations.

  1. /etc/grub.d
  2. /etc/default/grub
  3. /boot/grub2/grub.cfg

Can anyone tell me the purpose of each directory/file?


/etc/default/grub is where you can set simple options for many GRUB settings. It is parsed as a shell script.

/etc/grub.d contains shell scripts which generate GRUB configuration (based on settings on /etc/default/grub). update-grub (aka grub-mkconfig) runs these scripts to generate actual GRUB configuration.

/boot/grub2/grub.cfg is where the generated configuration is saved for GRUB to use.

Ordinarily, for setting GRUB options, you edit /etc/default/grub. If you need to generate additional GRUB entries or alter the entries generated, then add or change scripts in /etc/grub.d. Don't manually edit /boot/grub2/grub.cfg.