Configuring GRUB2
You can run one of two commands at the shell prompt (as root) to see which version of GRUB your particular Linux system is using:
•grub-install –v
•grub2-install -v
GRUB2 uses a completely different set of configuration files as compared to the GRUB Legacy bootloader. Here are the configuration files used by GRUB2:
•/boot/grub/grub.cfg file
•/etc/grub.d directory
•/etc/default/grub file
On some distributions, the grub.cfg file is located in /boot/grub instead of /boot/grub2
However, unlike the menu.lst file, grub.cfg is automatically updated every time you make a configuration change and then run one of the following commands:
•update-grub
•grub2-mkconfig -o /boot/grub2/grub.cfg
You have to run update-grub or grub2-mkconfig after making any configuration changes to the GRUB2 bootloader. They will not take effect until this has been done.
Even though grub.cfg is somewhat analogous to menu.lst, it doesn’t actually contain the GRUB2 menu information. Instead, it is stored in several configuration files within the /etc/grub.d directory. All the files within /etc/grub.d are executable script files. If you make changes to one of these files and then run the update-grub or grub2-mkconfig command, the grub.cfg file is automatically updated with the new GRUB settings. So, in summary, the /etc/default/grub file contains the GRUB menu configuration settings, but the script files in /etc/grub.d are the ones you actually edit to make any changes.
Grub2
hd0,1
If you were to view the contents of the grub.cfg file, you would see that it’s divided up into many sections. Each section begins with the text ###BEGIN.
Each of the sections references a particular script in the /etc/grub.d directory from which it was generated by the update-grub or the grub2-mkconfig command. When you look at the files within /etc/grub.d, you’ll see that they typically begin with a numeral, as shown here:
openSUSE:/etc/grub.d # ls
00_header 20_linux_xen 20_ppc_terminfo 40_custom 90_persistent10_linux 20_memtest86+ 30_os-prober 41_custom README
This naming convention is important because the placement of the menu items within the grub.cfg file is determined by the numeric order of the script file names within /etc/grub.d. The lowest-numbered files are executed first by the update-grub or grub2-mkconfig command. So in this example, 00_header would be run first, 10_linux would be run second, and so on. Any script files using nonnumeric files names will not be run until after all the numerically named files are run first. This then influences the order in which the information from these script files appears within /boot/grub2/grub.cfg.
00_header:
This file configures various parameters for the GRUB2 boot menu, such as the initial appearance, the graphics mode, the default selection, timeout values, and so on.
10_linux:
This file identifies each of the Linux kernels that have been installed on the system. If you have multiple kernels installed, the 10_linux script will search within your boot folder and locate any installed Linux kernels. For each one it finds, it will create a separate GRUB menu entry.
30_os-prober:
This script searches for any other operating systems that may be installed on your system. If you just have Linux installed, this script will locate your Linux kernel and create a menu entry for it. However, if you have Linux and Windows installed on the same system, 30_os-prober will identify Linux as well as the Windows operating system that has been installed and automatically create a GRUB menu entry for each.
40_custom:
This file is designed for you to use to customize the behavior of the GRUB menu. Basically, it’s a template for adding custom menu entries that will be inserted into the grub.cfg file.
Finally, we need to look at the /etc/default/grub configuration file. This file contains information that used to be contained in the upper section of the original GRUB Legacy menu.lst file, as shown here:
openSUSE:/etc/grub.d # cat /etc/default/grub
GRUB_DISTRIBUTOR="openSUSE 13.1"
GRUB_DEFAULT=saved
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=8
You can go ahead and edit this file and make whatever changes you need to and have those changes incorporated into grub.cfg when you run the update-grub or grub2-mkconfig command. Within this file are several different parameters you can use to change the way GRUB behaves and looks:
•GRUB_DEFAULT:
This parameter sets the default menu entry. For example, if you were to configure grub_default=0, the first menu entry becomes the default menu entry. If you have a timer set and no selection is made by the user, the first menu entry will be automatically selected. You can specify either an entry number or an entry title.
•GRUB_SAVED DEFAULT:
If you set this parameter to true, GRUB will automatically select the last selected operating system from the menu as the default operating system to be used on the next boot. As you can see, this parameter could potentially conflict with the grub_default parameter. Therefore, you can use either one, but not both.
•GRUB_HIDDEN_TIMEOUT:
The grub_hidden_timeout parameter can be used to cause the boot process to pause and display a blank screen (or a splash image if you configure it to do so) for a specified number of seconds. After the end of the timeout period, the system will boot. The grub_hidden_timeout parameter determines how long (in seconds) the blank screen will be displayed. While the screen is blank, the user can press the shift key to display the menu. If you don’t want them to have that option, set this parameter to a value of zero. If you set this to a null value, the menu will be displayed for the number of seconds configured by the grub_timeout parameter.
•GRUB_HIDDEN_TIMEOUT_QUIET:
This parameter works in conjunction with the grub_hidden_timeout parameter. If it is set to true, no countdown is displayed. If it is set to false, a counter will be displayed on the blank screen for the duration of the value specified for grub_hidden_timeout.
•GRUB_TIMEOUT:
This parameter specifies how long (in seconds) the user has to make a menu selection from the GRUB menu before the default operating system is booted. If you set this to a value of −1, the timer is disabled and GRUB will wait until the user makes a selection.
•GRUB_CMDLINE_LINUX:
This parameter is used to pass options to the kernel. With the GRUB Legacy bootloader, this was done by adding options to the end of the kernel line. You can do the same thing in GRUB2 using the grub_command line_Linux parameter.
•GRUB_GFX MODE:
This parameter sets the resolution of the graphical menu displayed by GRUB2. You can also append a color depth, if needed. For example, if you wanted the grub menu to use a screen resolution of 1440×900 and to use 24-bit color depth, you would set this parameter to a value of 1440×900×24. You can actually specify multiple resolutions with this parameter. List your preferred screen resolution first, then a comma, then the second one, and then a comma, and so on. GRUB2 will try to use the first resolution first. If the resolution is supported by the video display, it will be used and the others will be ignored. If it is not supported, GRUB will move on to the second resolution, and it will keep working its way down the list until it finds one that it can use. If this parameter is commented out, or if the resolution specified isn’t supported, GRUB2 will use the default graphic mode setting specified in the /etc/grub.d/00_header file.
•GRUB_INIT_TUNE:
You can use this parameter to play a single beep just prior to the GRUB2 menu being displayed. The syntax is to put an equal sign and then a quotation mark and then three numbers. The first number is the tempo to be used. The second number is the pitch of the tune. The third number is the duration of the tune. End the parameter with a closing quotation mark.
•GRUB_BACKGROUND:
This parameter sets the background image used by the GRUB2 menu.
•GRUB_DISABLE_OSPROBER:
Setting this parameter to a value of true will then disable the osprober check. This functionality looks for partitions on the hard drive that have other operating systems, such as Windows or other Linux distributions.
No comments:
Post a Comment