The submenu feature was introduced by Ubuntu in GRUB 1.99. The default submenu title is "Previous Linux versions" and appears immediately below the first kernel menuentry (and its associated recovery mode option, if enabled) in the main GRUB menu.
The purpose of the submenu is to streamline the main menu. In previous versions of GRUB 2, as new kernels were added to the system each kernel and its associated recovery mode entry were added to the main menu. Over time, the main menu display grew and could contain many kernels no longer regularly selected by the user. The submenu structure limits main menu entries to present a more manageable display.
Features & Considerations
Key features of the GRUB 2 Submenu include:
A submenu is automatically added only for the main Ubuntu OS when more than one kernel is found by GRUB. These kernel entries are listed in the 10_linux section of grub.cfg
- Submenus are not created for kernels on other partitions or for non-Linux operating systems such as Windows.
- The main menu will display only one kernel (and recovery mode, if enabled) for the current Ubuntu OS on the main Grub screen. Additional kernels, if available, are listed in the submenu.
Users who wish to automatically boot a kernel not displayed on the main menu will need to designate the kernel in the /etc/default/grub file. The designation is made in a different manner than previous versions of GRUB 2 and is discussed in this section.
- The submenu feature can be manually incorporated in a custom menu to reduce the total number of entries in other sections of the main menu.
The submenu feature currently cannot be turned off using settings in /etc/default/grub.
Submenu Display
The Grub2 menu will look unchanged until more than one kernel is available for selection. When more than one kernel is available, Grub2 will automatically add a submenu.
- The latest kernel is displayed on the main menu. Additional (older) kernels are displayed in the submenu.
- The submenu is a special menuentry with a title of "Previous Linux versions".
In GRUB 2.0 (Ubuntu 12.10, Quantal Quetzel and later) the submenu title is "Advanced options ..."
- Users access additional kernels by highlighting the "Previous Linux versions" menuentry and pressing the ENTER key.
- Once the submenu is selected additional kernels will be displayed on a secondary menu.
- When a newer kernel is installed, the previous kernel on the main menu will be moved to the submenu.
- The submenu feature is only created by default on the currently running Linux system.
New Kernel Introduction
When a new kernel is installed by Ubuntu:
- The GRUB menu is automatically updated.
- The newest kernel is placed on the main GRUB menu.
- If an older kernel is subsequently installed, it will be placed in the submenu.
- If the "Previous Linux versions" submenu did not exist, it is created.
- The previous kernel (and its recovery option if enabled) are moved off the main menu and placed at the top of the "Previous Linux versions" submenu.
- Previously-existing submenu entries are moved lower in the submenu to accommodate the new submenu entry.
The default kernel to boot is automatically changed to the new kernel if the /etc/default/grub GRUB_DEFAULT setting is 0 (the default setting) or the current default moves into the submenu.
- This happens in GRUB 1.99 even if the 'title' mode is used in the "GRUB_DEFAULT=" setting.
- GRUB 2.0 will introduce a more robust submenu structure to better allow retention of default settings.
- This happens in GRUB 1.99 even if the 'title' mode is used in the "GRUB_DEFAULT=" setting.
Manually Setting a Specific Kernel as the Default
To manually set a specific kernel to boot, the user must edit the /etc/default/grub file as the superuser/root.
gksu gedit /etc/default/grub
The line to edit is the GRUB_DEFAULT=0. After setting this line to the desired setting (see below), save the file and update the GRUB 2 configuration file using the following command:
sudo update-grub
Setting a Main Menu entry as the default
By default GRUB 2 sets the most recent kernel as the default. This kernel choice appears as the first item on the main menu.
As in previous Grub 2 versions, the default boot option is set by a setting of the /etc/default/grub file. The first menuentry on the main menu is designated by the entry GRUB_DEFAULT=0
- Entries displayed on the main menu can be designated by number or title as with earlier versions of Grub 2.
- The first entry on the main menu is 0, the second entry is 1, etc.
- GRUB_DEFAULT="0", GRUB_DEFAULT="1", etc.
A submenu title (Previous linux entry) is also counted as an entry.
In the initial graphic, Memory test (memtest86+) would be entry 3.
- The title can also be used to specify the menuentry to be used.
- GRUB_DEFAULT="Ubuntu, with Linux 3.2.0-23-generic"
- The first entry on the main menu is 0, the second entry is 1, etc.
Setting a Submenu entry as the default
Designating an entry in the submenu requires a more complex identifier so that Grub 2 will search the submenu.
- A submenu entry is composed of three parts:
- A number or title
- If using numerals, the first menuentry is 0, the second is 1, etc.
In a default GRUB 2 configuration, the current kernel would be menuentry 0, its recovery mode menuentry would be 1. The first submenu, which is considered a menuentry as well, would be 2.
A > separator symbol with no spaces before or after
A second number determined by its order within its submenu (counting from 0 within the submenu section) or a menuentry title .
- A number or title
- The entire entry should be enclosed by only one set of quotes.
Submenu Designation Examples
- All of the following examples indicate the first menuentry in the first submenu. Titles are easier to use but numbers are also acceptable for either or both values.
- Examples: In the following examples, the main menu consists of the current kernel, a recovery mode option, and the submenu "Previous Linux versions" as the third entry. The desired default is the first entry in the first submenu.
GRUB_DEFAULT="Previous Linux versions>Ubuntu, with Linux 3.2.0-18-generic-pae"
GRUB_DEFAULT="Previous Linux versions>0"
GRUB_DEFAULT="2>0"
GRUB_DEFAULT="2>Ubuntu, with Linux 3.2.0-18-generic-pae"
Failsafe Kernel Booting
If GRUB2 cannot determine the kernel to boot due to an incorrect GRUB_DEFAULT setting in /etc/default/grub, GRUB2 will attempt to boot one additional entry. This is normally the first entry on the main menu; by default this is the newest installed kernel.
Submenu Troubleshooting
The "GRUB_DEFAULT" setting in the /etc/default/grub file never changes automatically except when the GRUB package version is updated by the system. If a kernel is added or removed, the DEFAULT setting does not adjust and can cause the system to boot a menuentry not expected by the user.
When a failure occurs and GRUB is unable to find the DEFAULT entry, it will attempt to boot the most recent kernel (the first menuentry on the main GRUB2 menu).
If the correct kernel is not booting:
Inspect the GRUB2 menu during boot or open /boot/grub/grub.cfg for inspection.
- Determine the location of the desired kernel on the main menu or submenu.
Edit the "GRUB_DEFAULT" setting in /etc/default/grub and save the file
- Update GRUB.
Note: The current version of GRUB in Precise Pangolin 12.04 is GRUB 1.99. Improvements to the submenu structure will be included in GRUB 2.0, but this version was not released in time to be incorporated into Ubuntu 12.04.