GRUB Configuration

Jarret B

Active Member
Staff member
The GRand Unified Bootloader (GRUB) is used by systems to take control after the system BIOS is completed. GRUB may then show a menu to allow a user to choose from multiple Operating Systems (OS) or kernels of a specific OS.
With GRUB there are many configurable settings you can make on a system. The following items can be modified:

  • Wallpaper
  • Font color
Some people may use GRUB Customizer to make these changes but we will make the changes without using a special application.

NOTE: Another item I will cover in this article is to make GRUB search for newer Operating Systems on your system. If one is found then it will be added to the GRUB Menu.

GRUB Version

We need to make sure you have a usable version of GRUB to configure these settings.
In a Terminal you can type one of the following to find the GRUB version:

  • grub-install --version
  • grub-probe –version
The results of these commands are shown in Figure 1.

Figure 01.jpg

FIGURE 1

At the time of this the article being written the current version is 2.02-2ubuntu8.13. If your version is higher then you should be fine. If your GRUB version is an older one then you should update GRUB by:

Code:
sudo apt update
sudo apt upgrade
Changing the Wallpaper

I have seen many explanations on the Internet about why GRUB does not display images for wallpaper. Whether you are using a 32- or 64-bit system the reason is nearly always the same.
Before I get to the reason you need to verify the image resolution is equal to or less than your screen resolution. When GRUB loads it will try to find the best screen resolution supported by your system. Remember, GRUB is loaded after the BIOS and before the OS. No OS drivers are being utilized to set the screen resolution.
Let’s look at how to check the resolution of an image. Open a Terminal and type the command:

Code:
identify
If you get an error then you should install ‘imagemagick’:

For Ubuntu

Code:
sudo apt install imagemagick
For Red Hat systems:

Code:
sudo yum install ImageMagick
Once installed you can type ‘identify’ in a Terminal and make sure the command is found.
In the Terminal switch folders to the location of the image file you want to check and type:

Code:
identify imagename.ext
For example to find the resolution of a file named ‘Joker.png’ use the command:

Code:
identify Joker.png
The output should be something like that in Figure 2.

Figure 02.jpg

FIGURE 2

The first part of the output is the filename (Joker.png). The second portion is the image type (PNG). The third segment is the image resolution (1280x1024).
We can cover the other portions in a bit when we need them.
The image then has a resolution of 1280x1024 and should be equal to or less than my screen resolution ability of the system it will be shown on the GRUB Menu.
In most cases you can also open the image in an image viewer of some type and get the resolution information as well. We need to use the ‘identify’ program to determine if the image will work for GRUB or if no wallpaper will be displayed.
The seventh item in the list from the ‘identify’ command as shown in Figure 2 is ‘256c’. This is the reason why the wallpaper will not be displayed by GRUB. The colors in the PNG image file are set to 256 colors or indexed. A PNG image should not be limited to 256 colors, but a JPG image is usually limited to 256 colors. For GRUB it is preferable to use a PNG image to allow for more colors.
If you see in the output from the ‘identify’ program ‘8-bit’ then your image is only using 256 colors (28-bit).
If you have compiled GIMP yourself (versions before 2.10) or have version 2.10 then you can save a file at a higher precision. Any images you get from the Internet, especially those displayed on a web page, are usually 8-bit since this lowers the file size.
An 8-bit image has 256 colors while a 16-bit image has 65,536 colors. This can bee seen in Figure 3. The image must be 8-bit though to be displayed by GRUB.

Figure 03.jpg

FIGURE 3

What is an indexed picture? The picture has a limit of 256 colors. The colors used are listed in the palette. The palette is basically a listing of the colors being used by the picture. For the picture image every pixel is represented by a byte which has a value 0-255. The value of the specific pixel coincides with a value in the index to represent the pixel’s color. If we remove the index then each color value is used to represent each pixel. The values are 0-255 for each of the 3 colors Red, Green and Blue. Each pixel then is represented by 3 bytes. Even using a non-indexed PNG file may not increase the file size too much. After the file is created it is compressed to reduce space.
If you have an indexed image it will not work with GRUB as wallpaper. The image will need to be converted to Red-Green-Blue (RGB) format or sRGB without the ‘256c’ indexed palette. To convert the image you can load the image in GIMP, select ‘Image’, ‘Mode’ then ‘RGB’ as shown in Figure 4. Just be sure to ‘Export’ the image to a PNG file.

Figure 04.jpg

FIGURE 4

Once you have the image in a non-indexed form then you are ready to copy it to the proper location. The image file should be copied to /boot/grub/. If multiple image files are placed in the folder the first file will be used in the order of priority. The file extension is looked at first. The order for the extension is: jpg, JPG, jpeg, JPEG, png, PNG, tga, TGA. If two files have the same extension then the file which comes first alphabetically will be used. For example, ‘Joker.jpg’ will be used instead of ‘Tron.jpg’.

NOTE: Before placing an image in the folder you should remove all other images to make sure that the image you want to use is the only possible one that can be used.

Once you have copied the file into the proper folder then you need to update GRUB to have it find the image. To update GRUB you need to perform a ‘update-grub’ from a Terminal. You will notice that image is found and listed during the update. Make sure it is finding the proper image as shown in Figure 5 for the image ‘JokerRGB.png’.

Figure 05.jpg

FIGURE 5

When you reboot you should see the proper image displayed on GRUB menu screen.

NOTE: If you have issues with any images then it may be best to convert them to a PNG.

If the image is not found for any reason you could try to force the image by editing ‘/etc/default/grub’ as root. Towards the bottom add a line ‘GRUB_MENU_PICTURE=”/folder/name.png”’. Be sure the image file exists and after saving the changes you run the command ‘sudo update-grub’.
Other troubleshooting issues will be covered in the last section of this article called ‘Troubleshooting GRUB Issues’.

Font Color

Changing the font color is a simple task but you need a way to see it in action.
When the GRUB Menu appears press the ‘c’ button to enter to a command-line.
At the GRUB command-line you can enter the following commands to change the colors on the screen:

Code:
set menu_color=foreground/background
set color_highlight=foreground/background
set color_normal=foreground/background
These options are very specific in the way they are entered. Do not enter any spaces other than after the word ‘set’.
The color choices are as follows:

  • black
  • blue
  • brown cyan
  • dark-gray
  • green
  • light-cyan
  • light-blue
  • light-green
  • light-gray
  • light-magenta
  • light-red
  • magenta
  • red
  • white
  • yellow

Once an item is entered it will immediately change on the screen if the configuration affects what is viewed. To see how the menu changes with the new settings press the Escape key. The menu will reappear with the new settings. Press ‘c’ again to go back and make changes as needed. Once you have the settings you like type ‘set’. You will now be shown all of the current settings so make a note of them. Any changes you make will not be saved and be made permanent.

NOTE: If you use a background wallpaper image then the background color of ‘set color_normal’ should be black. When the background color is set to black then it is considered ‘transparent’. Any other color will cause the background image to not be shown.

Open the file ‘/etc/default/grub’ as root to edit it. Towards the bottom add the lines:

Code:
GRUB_COLOR_NORMAL=color1/color2
GRUB_COLOR_HIGHLIGHT=color3/color4
Save the file and perform the ‘sudo update-grub’ in a Terminal and the changes should take effect at the next boot.

NOTE: The options should be all upper-case and the color values should be all lower-case. Make sure they are typed correctly or GRUB will not recognize the option or the color value.

Troubleshooting GRUB Issues

There are two other areas that may need to be covered. One is a possible solution if an image does not show on the GRUB screen. The other item is when GRUB does not find all of the available Operating Systems (OS) on your computer.
If your system is not finding all of the Operating Systems you have installed then you will find it difficult to boot to other drives as you wish. To test GRUB to verify that it can see the other OS you can open a Terminal. In the Terminal type the command ‘sudo os-prober’. All of your installed Operating Systems should be listed. If not the problem is probably in the OS partition not being marked as bootable. The os-prober program does a fairly good job at finding all of the systems on your computer.
Start looking in ‘/etc/default/grub.d’ and look in each file for a line which is ‘GRUB_DISABLE_OS_PROBER=true’. Once you find it change the ‘true’ to ‘false’.
If it is not there then check the files in the folder ‘/etc/grub.d’. If one folder does not exist then the other should. If you do not find the line then you should add it to the end of ‘/etc/default/grub’. Make sure the boolean setting is set to ‘false’.
If your image is not loading in the GRUB menu then there is one option which will prevent it from occurring. Look in the same files as above for the setting ‘GRUB_TERMINAL=console’ and remove it or comment it out by placing a ‘#’ at the beginning of the line.
If you do find either or both of these mentioned lines you need to perform ‘sudo update-grub’ to make sure the changes are saved and GRUB has everything ready for the next boot.
I hope this helps you solve some of the GRUB issues which have been a problem for some users.
 


wizardfromoz

Super Moderator
Staff member
Gold Supporter
Nice article, Jarret.

Just a correction -

If the image is not found for any reason you could try to force the image by editing ‘/etc/default/grub’ as root. Towards the bottom add a line ‘GRUB_MENU_PICTURE=”/folder/name.png”’. Be sure the image file exists and after saving the changes you run the command ‘sudo update-grub’.
That should be

export GRUB_MENU_PICTURE=”/folder/name.png”

However a large number of Distributions outside of Debian do not support the export entry.

More commonly used and more successful is

GRUB_BACKGROUND=”/folder/name.png”

Cheers

Wizard
 

Staff online


Top