Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

Customize GRUB (Debian)

Discussion in 'Installation' started by Jarret B, May 23, 2017.

  1. Jarret B

    Jarret B Member

    Joined:
    May 22, 2017
    Messages:
    76
    Likes Received:
    13
    Linux systems use some type of Boot Loader which is especially needed if the system is used to boot to more than one Operating System (OS). The GNU GRand Unified Bootloader (GRUB) is only one bootloader available for Linux. GRUB is the standard bootloader used for many Operating Systems. Customizing GRUB is a way to personalize your system to your tastes.

    To begin the installation you need to verify that you are running the GRUB Bootloader. Grub is shown in Figure 1. Remember that even if GRUB is installed it may not appear if there is only one OS installed on your system.

    Figure 01.jpg
    FIGURE 1

    Determine GRUB Installation and Version

    Before trying to customize GRUB you need to verify that your system is using GRUB as the bootloader.
    Open a terminal and type one of the following commands:
    • grub-install --version
    • grub-install -V
    • grub-probe -V
    • dpkg -l grub-pc

    Usually one of these commands will work and the last one almost always works as well as returning the version number of GRUB as shown in Figure 2.

    Figure 02.jpg
    FIGURE 2

    Once you know that GRUB is installed then you can start your customization of GRUB on Debian Linux. To perform the customization you will need to install ‘grub-customizer’.

    Install GRUB Customizer

    The GRUB Customizer is not found in the standard repository. To install the GRUB Customizer you will need to add a repository to your system. To add the repository and download the GRUB Customizer you will need to perform the following commands in a terminal:
    • sudo add-apt-repository ppa:danielrichter2007/grub-customizer
    • sudo apt-get update
    • sudo apt-get install grub-customizer -y
    You should now have the GRUB Customizer installed and be ready to perform a customization.

    Customizing GRUB

    Open GRUB-Customizer from your menu system or in a terminal enter the command ‘grub-customizer’ which will ask for authentication by entering the root password.

    Once the Customizer is open you should see a screen similar to Figure 3. On my system GRUB allows me to load Linux Mint 18.1 or Windows 10. There are a few other options available, but these are the Operating Systems which can be started.

    Figure 03.jpg
    FIGURE 3

    By selecting the ‘General Settings’ tab you should see a screen similar to Figure 4. Some settings may be different for your system, but they should be similar.

    Figure 04.jpg
    FIGURE 4

    If you click on the last tab, ‘Appearance Settings’, then you should see a screen similar to Figure 5. This is the screen where we will be making most of our changes for customization. You can change your default GRUB menu (Figure 1) into something more to your taste.

    Figure 05.jpg
    FIGURE 5

    The next step is to determine your screen resolution so you can add a background image to the GRUB menu.
    Try one or both of the following commands to check your screen resolution:



    • xdpyinfo | grep dimensions
    • xrandr | fgrep '*'

    Figure 6 shows the output of both commands on my system. Both commands show that my screen resolution is 1024x768. Knowing the screen resolution makes it simpler to continue.

    Figure 06.jpg
    FIGURE 6

    On the tab ‘Appearance Settings’ the custom resolution can be set to the resolution previously found for your system. If you set a resolution which is not supported then you can cause issues and may not even see the GRUB menu.
    The next step is to find a background image to use for the GRUB menu. Try to find an image that has the same resolution as the screen. With the image being the same size you are less likely to run into issues of the image being shrunk or enlarged which can alter the image.
    Find an image and save it.

    NOTE: The image must be saved on a hard drive which is not external. An external drive in this case includes USB drives and the like. GRUB does not have the ability to load drivers for USB devices so any image or font on a USB drive is not accessible to GRUB.

    In the GRUB Customizer select the bottom button on the left side for ‘background image’. Find the image you have saved and select it. You should see the large section on the right side of the pane as shown in the image. Your menu should appear on the image as well.
    To set the font color of your menu items select ‘Normal: Font’ and set the color as you like. Make sure the letters are easily visible and not lost in the background image. The next item is the ‘Normal: Background’. This option lets you set a background color for the font. In most cases the ‘transparent’ option may be best to use.
    The next option is the ‘Highlighted: Font’ which is the color of the menu line which is currently selected. Make sure the color is apparently different than the normal font color. The color should also be visible against the background image. For the next option you can also set the background color for the highlighted font. Again, this may be best to be left as transparent.
    The last option left not covered is the font style itself. The location where the font file is stored must be accessible by GRUB. Do not choose a font which is stored on removable media. The same is true for the background image as well.
    You can see what I have done in Figure 7 to customize my GRUB menu.

    Figure 07.jpg
    FIGURE 7

    Click on the ‘Save’ button in the top left of the GRUB Customizer window. The configuration should be saved and the current GRUB configuration overwritten. Once the changes have been saved you will need to restart your system and wait for your new customized GRUB to load. An example is shown in Figure 8.

    Figure 08.jpg
    FIGURE 8

    As you can see in the picture there are some anomalies present. The straight lines, which are used to draw a box, are not present in the font file selected. The lettering seems hard to read because of its size. The font size can be set when choosing a font. A different font should be used. I will try another font and enlarge the size. Do not enlarge the fonts too much or the GRUB menu can become corrupted.
    If you should have problems with the font you chose and wish to go back to the default then click on the red ‘x’ to the right of the font selection box. Once you remove the font you will need to save the settings and reboot to see the changes. Figure 9 shows the GRUB Boot Menu after I removed the font so the default would be used.

    Figure 09.jpg
    FIGURE 9

    With the GRUB Customizer you make the boring GRUB Boot Menu into something more exciting to see when your system loads. Play around with the Customizer and have some fun!
    If you want to know more about how GRUB works then read on.

    How GRUB Works

    When a computer boots it starts with the Basic Input/Output System (BIOS) which detects the Primary Hard Drive. The Primary Hard Drive is not the one set as Primary Master, but the one set as the boot drive. The BIOS then turns control over to the first sector, sometimes known as the Boot Record, where the Bootstrap Program is located. The Bootstrap Program, or Boot Loader, loads enough information to start the booting process for the OS. There are two types of Boot Loaders.
    The first type of Boot Loaders do not understand the various file systems (FAT32, NTFS, EXT4, etc.). For this reason it loads a kernel at a hard-coded sector which has information on the various file systems. The kernel can then access the various file systems and load the OS.

    NOTE: If a kernel resides at a hard-coded address and it is moved, then the Boot Loader cannot load it properly.

    The second type of Boot Loaders can understand the various file systems and can access any file it needs without being hard-coded. In this case we are talking about GRUB which can access various file systems. Remember that GRUB has issues with external USB drives, though. GRUB understands the file systems but not the USB Hardware.
    GRUB 2.0 has a specific process it follows once control is passed to it from the BIOS. These stages are as follows:

    • Stage 1 – The BIOS hands control over to the ‘boot.img’ file of GRUB located in the Boot Record. After a set amount of time has passed, control is then given to Stage 1.5.
    • Stage 1.5 – Control is passed to the ‘core.img’ which is located after the Boot Record but before the file structure begins on the Hard Drive (sector 63). The ‘core.img’ contains the necessary information to load the various file systems as well as some other configuration information. Part of the information is the path to the necessary files in Stage 2.
    • Stage 2 – By default the path to Stage 2 is at /boot/GRUB. This can be different and will be set in the configuration of Stage 1.5. In Stage 2 the menu information is loaded and displayed to the User. The User makes a selection and control is passed on to an OS kernel or another Boot Loader.
    Be aware that the underlying processes of booting a system can be complex. Changing one thing in a hard drive, such as the Boot Flag, can change everything in the Boot Process. Adding Hard Drives can also change the Boot Process since another drive may have the Boot Flag enabled. BIOS settings can also change the Boot Order and cause a different Boot Loader to be used. Be cautious with the Boot Process when you make changes.
    If you feel comfortable with the Grub Customizer then make some changes. If the screen resolution causes issues with the system or even the monitor, set the custom resolution back to 640x480. Have fun!
     
    #1 Jarret B, May 23, 2017
    Last edited: May 30, 2017

Share This Page