Random Quote Board

Linux Mint 21 and Grub

Gary Schafer, September 2022

Night before last, one of my data hard drives went bad. Since the last time, I've taken great pains to ensure my data is backed up. I've since installed a new hard drive and replaced the data. I also used the opportunity to upgrade my OS to Linux Mint 21.

After the install, I decided to try to customize Grub, the "grand unified bootloader". This is the program that allows me to dual-boot my computer between Linux Mint and Windows. There were certain defaults which I wanted to modify. Trying to figure that out was... a pain. I'm simply documenting how to change the certain attributes of Grub, and why others are much more difficult. The specific attributes I wanted to change were:

It turned out that the first two were relatively straightforward. The third was a learning curve.

Menu Timeout and Grub Background

Both the menu timeout and the background are controlled in the file /etc/default/grub. You can open this file with this command:

sudo xed /etc/default/grub

In the file, you'll find the line that begins with:

GRUB_TIMEOUT

My default setting was set to GRUB_TIMEOUT="10". I wanted to change this so that the timeout was essentially disabled. To do this, I changed the time from "10" to "-1". The line now read:

GRUB_TIMEOUT="-1"

To add a background, I used Gimp to create a 640x480 image, then saved it as a PNG file called "background.png". I saved it directly under my "home" directory. In the "grub" file, I added the following line:

GRUB_BACKGROUND="/home/gary/background.png"

The section of the "grub" file in which all of the commands started with "GRUB" appears as follows:

GRUB_DEFAULT="0"
GRUB_TIMEOUT_STYLE="hidden"
# Using a value of -1 for "TIMEOUT" means disable the timeout. The system will
# not automatically boot until manually selected.
GRUB_TIMEOUT="-1"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
GRUB_BACKGROUND="/home/gary/background.png"

Setting the Menu Names

This last part is trickier. There's one file, /boot/grub/grub.cfg, that appears to be the primary file used for the menu items. That file is not just a menu list; it's "bash" code. It even says right at the top comments,

# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub

It goes through both the /etc/grub.d folder as well as the /etc/default/grub file to actively create the actual menu that you see. There are a bunch of different files, all containing bash code, that work together to create the menu at runtime. This is why it becomes so difficult to change the menu names. You can't just change the text in one, particular file for whatever menu item you want to change. (Trust me. I've tried. It didn't work.) First, the menu item is probably written in multiple locations. Second, it will change anyway when you run sudo update-grub. I've not yet been able to figure out where specifically it's pulling the menu item names. It's not from any file I've found thus far. I don't know enough of "bash" programming to be able to figure out where this text comes from.

Some of the files within the /etc/grub.d folder, specifically the ones with the name "custom" in them, can be modified to change these names. This is what "grub customizer" does; it adds "bash" code to these files when you want to change the menu titles.

So, yeah, if you want to change the menu names, you'll need to either install "grub customizer", or figure out how to add the code yourself to those files.

If I figure out specifically how to change the files directly, I'll post it here at some point in the future.

Here's a Random Fact...