Add a background image and change text colour
for the Grub 2 menu in Ubuntu (Debian) based systems.
NOTE: This is not a Grub Repair Solution. If your Grub Menu is not working, then you need a Grub Repair Tutorial.
Guide Overview
Please read the entire tutorial, before proceeding. Different instructions apply to different versions of Grub 2.
This tutorial is based on the Ubuntu Community Help Wiki and tested on a Xubuntu 20.04 system. It should work for all Debian based installations.
If you are an experienced user, running a Red Hat or other system, please advise of any changes that may be needed to apply this to those other installations.
The purpose of this guide is to teach you how to add a background image to your Grub Menu. In addition, it also shows how to modify the colour of the Grub menu text, to compensate for varying shades and colours in your background image.
Are you bored with Grub’s default drab menu? Do you wish you could spice it up a little bit?
Tools Needed
-
A working Grub 2 Menu in an Ubuntu (Debian) based system.
-
A suitable image to use as a background.
Instructions
-
Step 1 - Determine what picture you wish to use as your background.
GRUB 2 can use PNG, JPG/JPEG and TGA images for the background. The image must meet the following specifications:
- JPG/JPEG images must be 8-bit (256 colour). Else you will get errors saying "Too many Huffman tables". Since most of the time you will not want to limit yourself to 256 colours you will probably find PNG much preferable.
- Images should be non-indexed, RGB.
- The GIMP image editor is one application which can edit images to conform to the GRUB 2 standards. Use the Image > Mode menu options to set the properties to RGB and ensure the mode is not set to Indexed. For novice users, it can be found in desktop menu under “Graphics.”
- If you have used the “GRUB_GFXMODE=” option in your “/etc/default/grub” settings, then you must use an image of equal or less resolution. For example, if you have set your Grub menu to 800x600, by adding the line “GRUB_GFXMODE=800x600” then you can use any compatible image that is up to 800x600. Once again, GIMP can re-scale the image for you if it is too large. Use the Image > Scale Image menu option to change the resolution.
NOTE: Ubuntu users can download a sample of suitable pictures. Open a terminal window by pressing the ctl+alt+t keys together. Type the following command and hit enter:
sudo apt install grub2-splashimages
The images are found in the “/usr/share/images/grub” folder. The images in the grub2-splashimages package are primarily 640x480 images, and should work on any default install.
Once you have a compatible image, open a terminal window and enter the following command:
grub-install -V
This will display the version of Grub that you are using.
For versions of Grub 1.99 and later, go to Step 2.
For versions of Grub prior to 1.99, go to Step 3.
-
Step 2 - For versions of Grub 1.99 and later.
There are two options for adding a background image if you have version of Grub 1.99 or later.
-
The preferable method is to edit your “etc/default/grub” file.
In a terminal, enter the following:
sudo nano /etc/default/grub
This will open the grub file in the Nano text editor. Scroll down to the line #GRUB_GFXMODE=640x480
(If you have already set the resolution by adding the “GRUB_GFXMODE=” then you should find that easily enough.)
Under the “GRUB_GFXMODE=” entry, add the following line:
GRUB_BACKGROUND="/full/path/to/backgroundimage.xxx”
You must specify the full path to the file, for example:
“/home/username/Pictures/Wallpaper/image.type".
NOTE: Even though it is enclosed in “quotation“ marks, you can not have any spaces or special characters in the path. Using either “~/Pictures/Wallpaper/imagename.png", or “/home/username/Pictures/My Wallpaper/imagename.png" will not work!
DO NOT forget to add a carriage return by hitting the enter key at the end of the line!
Exit and save out of Nano then enter the command:
sudo update-grub
At this point you can restart your system, and the Grub background image will appear behind your menu.
If your menu is washed out by the background image, then you must go to step 4, and change your menu text colours. For example, my background image has a blue sky, which is too close to the default light gray used by Grub. So I changed it to darker colours, to make it more visible.
-
The alternate (second) method of adding a background image if you have version of Grub 1.99 or later.
You can simply copy the image file to the /boot/grub directory. You need root privileges to do so.
Open a terminal and enter the following commands:
sudo cp image.type /boot/grub/
sudo update-grub
Although this seems a simpler solution, it can become complicated at a later time. The first method is preferable.
For example, you could be using a file named “grubbgimage.png” located in your ~/Pictures directory.
You can change your background at any time, by overwriting that file name with another picture.
More adventurist users can then create a script file, to change the background image after each boot.
-
Step 3 - For versions of Grub 1.98 and earlier.
NOTE: This is based on the Ubuntu Community Help Wiki and untested by me. If you have Grub 1.98 or earlier, please advise if this is correct, or what changes you had to make.
The following guidance for setting the background image is for GRUB 2 version 1.98-1ubuntu13 found on Ubuntu 10.04, Lucid Lynx.
The GRUB 2 splash image, if it exists, is selected in the following order:
-
The image specified in /usr/share/desktop-base/grub_background.sh. This script does not exist in a default Ubuntu installation.
-
The file listed in the WALLPAPER line in /etc/grub.d/05_debian_theme.
-
The default file listed in the WALLPAPER line is /usr/share/images/desktop-base/moreblue-orbit-grub.png. This image is present only if the desktop-base package is installed.
-
The image will be used if GRUB 2 locates it in either the /usr/share/images/desktop-base or the /grub folder (normally a sub folder of /boot)
The use a different splash image:
sudo nano /etc/grub.d/05_debian_theme
Find and edit the “WALLPAPER=” line. Include the new path and filename of the image you wish to use. For example:
WALLPAPER=/home/username/Pictures/image.type
Exit and save from Nano, then enter the following:
sudo update-grub
At this point you can restart your system, and the Grub background image should appear behind your menu.
If your menu is washed out by the background image, then you must go to step 4, and change your menu text colours. For example, my background image has a blue sky, which is too close to the default light gray used by Grub. So I changed it to darker colours, to make it more visible.
NOTE: If no background image appears, or the wrong image is displayed, refer to:
Troubleshooting Splash Images in the Ubuntu Community Help Wiki.
-
Step 4 – Changing Text Colours in the Grub Menu.
If your menu is washed out by the background image, you can change your menu text colours.
For example, my background image has a blue sky, which is too close to the default light gray used by Grub. So I changed it to darker colours, to make it more visible.
For each font colour entry, two inputs are required, separated by a /. The first entry is the text colour, while the second entry is the background colour (if an image is not present.)
NOTE: Many systems default to English spelling. Please note that Grub uses American spelling. If you type the word as “colour” then you will get an error. You must use the American spelling “color”.
For example: menu_color_highlight=black/white
GRUB 2 accepts the following colours for the menu fonts and background:
black blue brown cyan dark-gray green light-cyan
light-blue light-green light-gray light-magenta light-red
magenta red white yellow
About "Black"
GRUB 2 treats "black" differently when it is the second entry in a setting. Black is considered a value for "transparent" for example:
" color_normal=white/black " will produce white text on a transparent background.
By assigning the transparency value to black in the background, your image will not be blocked by the black bars that appear behind the text in the menu. You will only see the text, its’ self.
The colours may be changed to other values by writing them directly into the 05_debian_theme file.
When an image is present GRUB 2 uses only color_normal and color_highlight settings.
The color of selected menu entries is set by menu_color_highlight setting.
The color of non-selected menu entries is set by menu_color_normal setting.
To change default colour values when using a splash image enter the following in a terminal:
sudo nano /etc/grub.d/05_debian_theme
Find the following lines:
if [ -z "${2}" ] && [ -z "${3}" ]; then
echo " true"
fi
Change the entry to the following, replacing 'color1' and 'color2' to the desired colors. Leave /black as is!
if [ -z "${2}" ] && [ -z "${3}" ]; then
# echo " true"
echo " set color_highlight=color1/color2"
echo " set color_normal=color1/black"
fi
NOTE: The 05_debian_theme file uses tabs. Use tabs in Nano to indent rather than spaces. Also, remember to add a carriage return to the end of each line.
Exit and save from Nano then enter the command:
sudo update-grub
Reboot your system to see the changes in the Grub menu.
NOTE: If your colours do not change, or for more detailed instructions refer to
Grub2/Displays in the Ubuntu Community Help Wiki.
Cheers!
Naught