Making Your Boot-loader Stoned on Customization

Making Your Boot-loader Stoned on Customization

ยท

5 min read

What's that ?

If you have installed any GNU/Linux distro (except some, like Pop!_OS), you might have noticed something when your PC boots that looks like some variant of this image

grub2-in-ubuntu.jpg

This is the GRUB (GRand Unified Bootloader), an Open Source bootloader that allows users to boot into many types of operating systems including Windows.

Now what the heck is a bootloader ?

When your computer boots, the first thing that loads is the UEFI (Unified Extensible Firmware Interface) or BIOS (Basic Input/Output System) depending on the age of your computer. These are programs stored inside special memory blocks of the motherboard having no direct relation with any Operating System or Hard Drive, and allow you to control your hardware, check specs, manage bootloader order etc. UEFI/BIOS then execute your first priority Bootloader. Now bootloader is a special program that allows the user to boot into their operating system. It contains information about location of your boot files, kernel etc.

Windows has its own bootloader too. If you ever tried dual booting multiple versions of Windows, you might have noticed that upon startup, it asks which version of Windows you want to boot into. But Windows bootloader only supports booting into versions of Windows, and it won't help you booting another operating system like GNU/Linux.

So in order to boot into our favorite Linux distro and have dual booted Windows at the same time, we need a general purpose bootloader that supports all of these operating system, and thus GRUB comes to the rescue.

Okay, gotcha. Customization ?

GRUB supports themes out of the box. You just have to

  1. Download any GRUB theme you like. You can find many good ones here.
  2. Extract the downloaded theme.
  3. Copy the extracted folder to /boot/grub/themes
  4. Make a copy of GRUB's current config. Run sudo cp /boot/grub/grub.cfg ~/grub.cfg && sudo cp /etc/default/grub ~/grub
  5. Open /etc/default/grub as root
  6. Change GRUB_THEME to /boot/grub/themes/{the theme folder you just copied}/theme.txt. Save and exit.
  7. Run update-grub OR grub-mkconfig -o /boot/grub/grub.cfg as root. This will read /etc/default/grub and generate /boot/grub/grub.cfg, the GRUB's config file.
  8. Reboot and you will see a new screen upon boot.

Distro GRUB Theme This Theme: Distro GRUB Themes

Hmmm. But That's tedious ๐Ÿฅฑ

Bored of copy pasting files manually ? Scared of changing important files by hand ? GRUB Customizer comes to the rescure. It is a GUI program that takes away all the pain of manually changing files.

Installation

You can find grub-customizer package in your distro's package repository.

In Debian based distros (Ubuntu, Pop!_OS etc), if you can't find grub-customizer package, you might need to add external PPA.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

This will install latest grub-customizer.

Usage

Open grub-customizer as root. sudo grub-customizer

grub-custo.png

  • Save is equivalent of manually running sudo grub-update
  • Remove removes a menu entry (the options that show OSs' name) from GRUB
  • Similarly other buttons do obvious tasks like moving menu entry, editing menu entry etc.

Installing Themes

  1. Go to Appearance Settings
  2. Click on the โž• button
  3. Navigate to the theme file you downloaded and open it
  4. Finally, click save. It will update the GRUB config.

You can always change background, config etc manually, but recommended way is to use pre-tested themes via grub-customizer to make yourself stay in the safe zone.

Anything Else ?

There are many, actually. You can manually change screen resolution, background, fonts, menu entries etc. Discussing every feature is beyond the scope of this article, but I'd like to have a glace at two cool ones.

Feeling Hacky ?

Do you want your system to print out a bunch of log messages when it boots so that you feel like The Anonymous ? Say no more.

  1. Go to General Settings in grub-customizer
  2. In the Kernel Parameters input box, clear out quite splash
  3. Save.

Next time you open your system, you'll be greeted with log messages instead of the boring boot animation. ๐Ÿ˜Ž

boot logs

I'm a Typographer ๐Ÿซ 

Yeah, you can create custom fonts for GRUB too.

  1. Download any font you like in TTF format.
  2. Run sudo grub-mkfont -s {size of font you want eg: 16} {path of output file}.pf2 {path of input font}. Eg - sudo grub-mkfont -s 16 CascadiaMonoPL.pf2 CascadiaMonoPL.ttf assuming CascadiaMonoPL is in the same directory. This will generate the bitmap font file CascadiaMonoPL.pf2
  3. Copy the generated font to your current GRUB theme folder. sudo cp {output font}.pf2 /boot/grub/themes/{name of current theme}
  4. Open /boot/grub/themes/{name of current theme}/theme.txt as root and change all occurrences of Font to {output font}.pf2
  5. sudo update-grub

This will change all the text to your given font.

Troubleshooting

  • Just in case things don't go as expected, you can always copy grub.cfg and grub file to /boot/grub/grub.cfg and /etc/default/grub respectively and you'll be back to your previous config.
  • If you get /etc/default/grub not found or any error like that (most probably you're on Pop!_OS), this means your system doesn't have GRUB installed. You will need to manually install it and then start customizing.

My Current Setup

boi.png (open in new tab for better view)

At last....

Feel free to explore all the customization that GRUB offers. And if you want to test the themes on the go, there is a tool even for that. grub2-theme-preview uses virtual machine to emulate a boot and shows the preview of the theme you provide.

Thanks for reading ๐Ÿซก.

ย