How to change the grub2 fonts on Silverblue for better hidpi display?

Hello,
I am using a 4K monitor where the default grub fonts are barely visible. I have done grub2-mkfont and put the generated fonts into /boot/grub2. After adding GRUB_FONT=/boot/grub2/DejaVuSansMono.pf2, I did sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg. Everything seemed smooth but it doesn’t work at all. Anyone can give a hand?
Thanks a lot.

Hello @monacocoa,
Not sure about this, but it used to be a no no to use grub2-mkconfig on SB. I’m just checking into that right now. Believe me I would dearly love to tweak my Grub menu to have a “Fallout 3” theme, but I would currently have to make my own tree, so fork the SB project and do it myself. At least that is as far as I got into it when I checked (about F29 release time).

Hi @jakfrost ,
Glad to see you are also aware of the “aesthetics” from the booting LOL. Do you know why it’s not possible to customize grub2 on SB? The cfg is refreshed every booting time? Or grub2-mkconfig doesn’t generate correct cfg? Honestly I don’t have much experience with grub, but if you could provide some insight, I could also try to work on it.

Hello @monacocoa,

Well, I don’t have 4K, but I do have a pretty good monitor and card, and yes the boot menu … sucks? can I say that?
As far as I know, Silverblue being immutable has something to do with it, possibly the initramfs bit of the OS load, not sure, but I distinctly remember that being mentioned. This is a quote from the Silverblue documentation …

For Silverblue installs, ostree is responsible for deploying and updating the OS image (including everything below / that is not symlinked into /var ). It also updates grub.cfg entries to point to the current image.

And that would seem to be where we run into issues, as I found before. You really have to modify the way SB does the update so it leaves the menu style intact but does the menu entry update correctly. I forked the repo from https://github.com/cgwalters/fedora-silverblue-config and cloned my fork to play with. Basically, some python knowledge is necessary, and also a bit of understanding on how the commit tree is built up with your local layers, aside from figuring out how to get Grub to behave. Still, I think it would be very well received in the general Fedora Silverblue community.

Thanks a lot!
I’ll go to study the SB docs and see what’s behind. BTW, have you tried grub-customizer? Even if it doesn’t work, maybe the relevant error message could provide some hints.

The advice I got was don’t use it on Silverblue.
The SB updating is what writes the menu entries for Grub2. This likely is pretty much a preformatted approach I would think, so the modification would need to be in a file comp-sync.py (I think), which seems to be the file that downloads the ostree commit from the repo, copies it into a temporary location then diffs it against the current running tree to get the layering details. Flatpaks, /etc, and the home directory are not touched. So user settings and other configuration details remain as you set them. At least that is what I think is done.

In that sense, if we would like to change the grub.cfg, we could treat the generated new config as a package layer and compose a new bootable os image from that. Am I right?

It might be easier to fork the project and then mod the comp-sync.py file plus probably add some files to the base so when the base gets built it brings in all of our stuff. That way we are sort of inline with the release commit. Another thing is BIOS or EFI, I am on BIOS, and most are now EFI. Fedora is heading towards systemd-boot to handle the boot process which goes hand in hand along with the adoption of the Boot Loader Spec earlier adopted. BIOS is going away, to be replaced entirely by EFI eventually. The BLS will make what you are trying to do infinitely easier.

Hmm this seems a bit odd to me, I wasn’t aware of SB adding anything to change this… Out of curiosity, what happens if you switch to GRUB, hit the key to open the shell, then run lsfonts? Does it show the font you added?

Hi,
It shows Loaded fonts: without any item. FYI, since there is no grub2-mkfont at the host machine, I have generated the fonts in toolbox. It seems the generated font file is corrupted somehow…
I’ll try to regenerate the fonts. Thanks for your help and reminder!

Hmm, I don’t think that would affect it, but of course do note /boot inside the toolbox is different from /boot on the host.

Hi @refi64 @jakfrost,
Thank you both! I have finally found a workaround/solution. The problem is that the default grub_terminal is console which doesn’t respond to GRUB_FONT, probably it requires a different kernel argument to change the font. I set the grub_terminal to gfxterm which does slow down the response a lot especially when GFXMODE is set to very high resolution. But now it loads the font correctly. Also grub seems to only load fonts from the default directory /boot/efi/EFI/fedora/fonts for EFI bootloader even when I specify a differnt load path.

1 Like

Hi @jakfrost ,
I guess probably you can try a similar workaround. By settings the grub_terminal to gfxterm you can change the ‘GRUB_THEME’ to change the background. Here is the manual.