2021/02/20

GRUB 2 configuration

I've recently found time and need to improve my GRUB 2 setup and I hope sharing that could help somebody, although it is not something you won't find in other HOWTOs. 

I'm quite conservative and not spending in boot screen much time so all I use is text mode

First of all, the location of onfig files. All the configuration settings are in /etc/default/grub. The settings are used as variables when you generate a new GRUB configuration. The settings there are used whe you generate a new GRUB configuration /boot/grub/grub.cfg with grub-mkconfig command and are all you usually need to change.

If you need to put some custom logic to the generation for the config file, you can achieve that by adding a script into /etc/grub.d directory.

disabling framebuffer

Wher you try to avoid problems with a proprietary driver or just like text mode:

GRUB_TERMINAL_OUTPUT=console


Some information about current framebuffer setup can be found by:
hwinfo | grep -i framebuffer

menu timeout

Setting menu-style timeout, with 5sec countdown:
GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE=menu

menu font


GRUB allows to set a custom font. You can create a new GRUB font by converting an existing font with grub-mkfont utility. AFAIK at least TTF and PCF font formats are supported.  

Example of using converted Terminus font in bold weight and 16pt size: GRUB_FONT=/usr/share/grub/terminus16b.pf2

Note that this font is a bitmap one so I had to just chose the proper size and coverte it, when converting TTF fonts you need also provide the desired size.

menu colors

The palette for text-mode colors is quite limited, valid color names are: black, blue, brown, cyan, dark-gray, green, light-cyan, light-blue, light-green, light-gray, light-magenta, light-red, magenta, red, white, yellow.

There are two config options, for setting normal and highlight colors, in format foreground/background: GRUB_COLOR_NORMAL=white/blue GRUB_COLOR_HIGHLIGHT=yellow/light-blue

As it seems these settings are ignored, I created  file /etc/grub.d/99_set_colors with following content to fix that. It's rather simplistic as it does now allow any spaced or quotes around the color values but it does the job:

#!/bin/sh


color_normal=`grep "^GRUB_COLOR_NORMAL" /etc/default/grub | cut -d "=" -f2`

color_highlight=`grep "^GRUB_COLOR_HIGHLIGHT" /etc/default/grub | cut -d "=" -f2`


cat <<EOF

set color_normal=${color_normal}

set color_highlight=${color_highlight}

set menu_color_normal=${color_normal}

set menu_color_highlight=${color_highlight}

EOF

recalling previously selected menu entry


GRUB can save the menu entry you selected last time and use it as default for the next boot:

GRUB_DEFAULT=saved

GRUB_SAVEDEFAULT=true

play tune


If you do not like the waiting for the moment when the GRUB menu is shows up, you can set a tune that will be played just the moment before it appears.


Example with the greeting from the film Close Encounters of The Third Kind: GRUB_INIT_TUNE="480 900 2 1000 2 800 2 400 2 600 3"


You canl find other well-known tunes on internet, e.g. in Linuxmint forum .



No comments:

Post a Comment