linux:grub:customizing_grub

Customizing grub

You might have got tired of seeing a box with black background for GRUB when Linux is booting. You could add a background image which looks good (better than the boring background colors).

The steps mentioned below were tested with grub-1.98 and should work on newer versions.

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 color)
  • Images should be non-indexed, RGB

In grub-1.98, the splash image to be displayed will be searched in the following order.

  • GRUB_BACKGROUND line in /etc/default/grub
  • First image found in /boot/grub/ ( more images found, it will be taken alphanumerically )
  • The image specified in /usr/share/desktop-base/grub_background.sh
  • The file listed in the WALLPAPER line in /etc/grub.d/05_debian_theme

So you can use any of the above in the order of priority to make GRUB display your own images. The following is an example content of /etc/default/grub file.

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX=""

GRUB_BACKGROUND="/files/wallpapers/grub.png"

Once changes has been done using any of the above methods, make sure you execute update-grub command as shown below.

# update-grub
Generating grub.cfg ...
Found background: /usr/share/images/desktop-base/moreblue-orbit-splash.png
Found background image: /usr/share/images/desktop-base/moreblue-orbit-splash.png
Found linux image: /boot/vmlinuz-2.6.32-5-amd64
Found initrd image: /boot/initrd.img-2.6.32-5-amd64
done

Now that you have your own image in GRUB, you can change the default colors. The following are the 3 main GRUB color setting that you can change:

  • menu_color_highlight ⇒ The color of the highlighted menu entry and its background within the menu box
  • menu_color_normal ⇒ The color of non-selected menu entry and its background within the menu box
  • color_normal ⇒ The color of text and background outside the menu box

The syntax for specifying the color is as follows:

menu_color_highlight=fg-color/bg-color

The following colors are supported by grub:

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

Now to change the colors, open “/etc/grub.d/05_debian_theme” and find the following line:

if [ -z "${2}" ] && [ -z "${3}" ]; then
echo " true"
fi

and, replace them with the following:

if [ -z "${2}" ] && [ -z "${3}" ]; then
# echo " true"
echo " set color_highlight=red/green"
echo " set color_normal=light-cyan/black"
fi

Don’t change the “black” present in color_normal. If changed, the image will not be transparent in the area where the menu is displayed.

After this change, execute “update-grub”, and reboot your system. You will notice the change in the font colors displayed.

When you are not sure of what colors to choose, and you would like to experiment, then you can do it from the grub command-line itself.

  1. When the grub menu appears, press any key to stop the countdown
  2. Press ‘C’ to get into GRUB command line, and experiment as you wish
    1. grub> set color_highlight=red/green
    2. grub> set color_normal=light-cyan/black
  3. Now press “ESC”, to see the effect of your changes. If not satisfied, follow the steps once again and try different combinations.
Enter your comment:
215 +6​ = 
 
  • linux/grub/customizing_grub.txt
  • Last modified: 2019/10/31 09:05
  • by 127.0.0.1