GRUB 2 boot menu basics and how to add a custom splash image
GRUB 2 is the boot loader that is used by all current Linux Distributions. In this guide I will explain how to modify the GRUB boot loader menu on your server or desktop, how to add menu entries and add a custom splash screen image.
GRUB 2 overview.
One of the important features in GRUB 2 is flexibility; GRUB understands filesystems and kernel executable formats, so you can load an arbitrary operating system the way you like, without recording the physical position of your kernel on the disk. Thus you can load the kernel just by specifying its file name and the drive and partition where the kernel resides.
The configuration file of GRUB has a new name (‘grub.cfg’ rather than ‘menu.lst’ or ‘grub.conf’), new syntax and many new commands. Configuration cannot be transferred directly, although most GRUB Legacy users should not find the syntax too surprising. The file "grub.cfg" is automatically generated by the command:
Editing your GRUB menu.
Starting with the main file of GRUB "/boot/grub/grub.cfg". This file is automatically generated and is not meant to be edited directly.You can use any editor you want to display the file. Have a look at the image below.
The GRUB 2 user file to be edited can be found in two places.
/etc/default/grub to change boot menu options.
/etc/grub.d/ to edit the script files which create "grub.cfg".
To start editing boot menu options go ahead and type :
gksu gedit /etc/default/grub
The things you will be able to change are :
GRUB_DEFAULT=0 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=-1 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX=""
Explaining each one of them lets start with
GRUB_DEFAULT= The default menu entry. This may be a number, in which case it identifies the Nth entry in the generated menu counted from zero, or the title of a menu entry, or the special string "saved". Using the title may be useful if you want to set a menu entry as the default even though there may be a variable number of entries before it.
NOTE: IN THE ABOVE FILE SAMPLE THE NUMBER '0' INDICATES THE VERY FIRST ENTRY OF THE grub.cfg FILE.
GRUB_HIDDEN_TIMEOUT= Boot the default entry this many seconds after the menu is displayed, unless a key is pressed. The default is "5". Set to "0" to boot immediately without displaying the menu, or to "-1" to wait indefinitely.
GRUB_HIDDEN_TIMEOUT_QUIET= Will display a count down timer if set to false, If set to true will simply display a blank screen all before displaying the actual GRUB menu.
GRUB_TIMEOUT= This is the number of seconds GRUB will display the menu before booting the default option. Setting it to "0" will boot the default option instantly without displaying the menu. Whereas setting in to "-1" will hold up the menu till the user selects an option.
GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian This line simply retrieves the name in the menu entry.
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" Removing "quiet" out here will display a text output during the boot, whereas removing "splash" will display a black screen instead of the splash image.
You can go ahead and setup your own splash image by adding it to the /boot/grub/ directory
sudo cp splash1.jpg /boot/grub/
This was what you could do with the /etc/default/grub file. Now if you want to add your own boot menu entry this is where you will be able to do it. Type in the following as per the image.
Now, you will have to use the file 40_custom for writing your own menu entries.
gksu gedit 40_custom
You can go ahead and refer the entries generated by os_prober in /boot/grub/grub.cfg for your reference. The name of the file determines in which order the scripts are run so basically 30_os_prober will generate menu entry before 40_custom and then 41_custom. To make any file executable you will have to change the file permission. To change permission use
sudo chmod +x /etc/grub.d/40_custom
These were the basics. Now to apply all the settings and changes you will have to update GRUB.
Restart your system and checkout the changes by yourself.