Terry : GRUB2

The config file of grub2, /boot/grub/grub.cfg is read only by default. It is not recommended to update the file directly. Like in legacy grub, we normally directly edit /boot/grub/menu.lst.

GRUB2 File Structure


This is the file most closely resembling GRUB's /boot/grub/menu.lst. This file contains the GRUB 2 menu information but unlike GRUB's menu.lst the grub.cfg file is not meant to be edited.

  • Each section is clearly delineated with "(### BEGIN)" and references the file in the /etc/grub.d directory from which the information was generated.
  • grub.cfg is updated by running the update-grub command as root. The update-grub command is a stub for sudo grub-mkconfig -o /boot/grub/grub.cfg. For standardization, the command update-grub will be employed, run as "root" with the sudo.
  • The file is automatically updated with kernel installations/removals or other updates which would affect its output.
  • By default, and whenever the update-grub command is executed, this file is made "read-only". This is in keeping with the intent that the file should not be edited manually.

The user will also see a multitude of *.mod files in the /boot/grub directory. These files relect the modular nature of GRUB 2 and are loaded as necessary by the GRUB 2 bootloader.


This configuration file contains information formerly contained in the upper section of GRUB Legacy's menu.lst and items contained on the end of the kernel line. The entries in this file can be edited by a user with administrator (root) privileges and are incorporated into grub.cfg when it is updated. Specific configuration settings are detailed in the Configuring GRUB 2 later in this section.

  • The files in this directory are read during execution of the update-grub command and their instructions are incorporated into /boot/grub/grub.cfg.
  • The placement of the menu items in the grub.cfg menu is determined by the order in which the files in this directory are run. Files with a leading numeral are executed first, beginning with the lowest number. 10_linux is run before 20_memtest, which would run before 40_custom. If files with alphabetic names exist, they are run after the numerically-named files.
  • Custom entries can be added to the 40_custom file or in a newly created file. Based on its name, 40_custom entries by default appear at the bottom of the menu. A custom file beginning with 06_ would appear at the top of the menu since its alphanumeric sorting would place it ahead of 10_ through 40_ files.
  • Only executable files generate output to grub.cfg during execution of update-grub.

The default files in this directory are:

  • 00_header Sets initial appearance items such as the graphics mode, default selection, timeout, etc. These settings are normally imported from information from /etc/default/grub. Users normally do not need to make changes to this file.
  • 05_debian_theme The settings in this file set splash image, text colors, selection highlighting and themes. In the absence of a splash image, this file sets a monochromatic theme for the initial menu display. How to set font renderings and splash images are discussed in detail in the Splash Images and Themes section.
  • 10_hurd Locates Hurd kernels. Not currently used.
  • 10_linux Locates kernels on the root device for the operating system currently in use. It takes this information and establishes the names displayed on the menu for these kernels. Thanks to the code in 10_linux, it is not necessary (or even possible) to explicitly contruct the list of kernel names displayed on the menu. Note: If you don't want all your old kernels to appear in the menu list, remove their files from /boot.
  • 20_memtest86+ Searches for /boot/memtest86+.bin and includes it as an option on the GRUB 2 boot menu. There is currently no line option to remove this entry from the menu. The display of memtest86+ can be inhibited by removing the executable bit from this file: sudo chmod -x /etc/grub.d/20_memtest86+ and then running sudo update-grub.
  • 30_os-prober This file uses os-prober, which searches for Linux and other operating systems. Results are placed in grub.cfg based on the scripts in this file. The file is divided into 4 sections, representing the types of operating systems handled by the scripts: Windows, Linux, OSX, and Hurd. Variables in this file determine the format of the displayed names in /boot/grub/grub.cfg and on the GRUB 2 menu. Users familiar with basic scripting can alter these variables to change the format of the displayed menu entries. Alternatively, the user can insert an entry into /etc/default/grub which disables this script. (See below) By default os-prober ignores any disks that possess dmraid signatures, which can be listed via sudo dmraid -r -c.
  • 40_custom A template for adding custom menu entries which will be inserted into grub.cfg upon execution of the update-grub command. The contents of this file, below the "exec tail -n +3 $0" line and the default comments, are imported directly into /boot/grub/grub.cfg without any changes.
  • Files in these directories must be executable to be used by update-grub. Files which are not executable will be ignored. To make a file executable, run sudo chmod +x filename

Configuring GRUB2

Important note: Configuration changes are normally made to /etc/default/grub and to the custom files located in /etc/grub.d. The /boot/grub/grub.cfg file should not be edited by the user; changes to this file are made by configuration scripts. After editing /etc/default/grub, you need to run sudo update-grub for your changes to take effect on the next boot.

Recommended steps to update grub.cfg:

1. update /etc/default/grub

2. run update-grub(2) to generate a new config file