66

I would like to reduce the size of the font of GRUB boot loader. Is it possible and so how?

neydroydrec
  • 3,837

5 Answers5

65

After some research based on the answers of @fpmurphy and @hesse, also based on a comprehensive thread at ubuntuforums and on Fedora Wiki, I found out how to reduce the font size of GRUB2.

  1. Choose a font, in this example I chose DejaVuSansMono.ttf
  2. Convert the font in a format GRUB understands:
    sudo grub2-mkfont -s 14 -o /boot/grub2/DejaVuSansMono.pf2 /usr/share/fonts/dejavu/DejaVuSansMono.ttf
  3. Edit the /etc/default/grub file adding a line:
    GRUB_FONT=/boot/grub2/DejaVuSansMono.pf2
  4. Update GRUB configuration with:
    • BIOS: sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    • EFI: sudo grub2-mkconfig -o /boot/efi/EFI/{distro}/grub.cfg # distro on RHEL8 is {'redhat'}
  5. reboot.

The resolution of GRUB display may also affect the size of the font, more on resolution etc. on the ubuntuforums link above.

neydroydrec
  • 3,837
  • 1
    On UEFI system one would use grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg – scrutari Mar 13 '19 at 15:32
  • 4
    On Linux Mint 20 the command is grub-mkfont. On my systems, the use of DejaVuSansMono leads to "broken" vertical lines in the box around the boot menu, probably because the vertical box drawing characters are 1 pixel too short. On Mint 20 the only pre-installed font that did it correctly was "FreeMono.ttf" sudo grub-mkfont -s 24 -o /boot/grub/FreeMono.pf2 /usr/share/fonts/truetype/freefont/FreeMono.ttf – dr fu manchu Jun 19 '21 at 03:27
  • @drfumanchu thanks, the same works for Ubuntu 20.04, (along with changing any grub2 references to grub). Also, /etc/default/grub advises to run update-grub, which calls grub-mkconfig, and (I'm hoping) does the right thing with regards to EFI. – mwfearnley Aug 03 '21 at 07:50
  • To make the font in Fedora 34, use sudo grub2-mkfont -s 20 -o /boot/grub2/DejaVuSansMono.pf2 /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf To update GRUB on Fedora 34 use sudo grub2-mkconfig -o /etc/grub2-efi.cfg – Nicholas Stommel Aug 19 '21 at 19:30
  • I am trying to use the breeze theme. It already contains fonts as small as 12, so no need to run grub-mkfont, but it just WON'T PICK THEM UP, even if I change ALL fonts to size 12 in theme.txt. It just picks some hardcoded value. – Szczepan Hołyszewski Sep 19 '22 at 06:47
  • This worked perfectly for me... until recently. It seems that a security fix to grub means that unsigned fonts are ignored. See https://bugzilla.redhat.com/show_bug.cgi?id=2144113 and https://lists.gnu.org/archive/html/grub-devel/2022-11/msg00155.html – David Robertson Dec 21 '22 at 01:41
  • sudo /usr/bin/grub-mkfont -s 16 -o /boot/grub/DejaVuSansMono.pf2 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf for Linux Mint 21. Note that Grub2 in general now is just referenced as grub. – cachius Apr 18 '23 at 06:54
  • As @DavidRobertson mentionned, on Ubuntu 22.04 LTS I had this issue where it stopped working after a grub update (current version on 22.04 is 2.06-2ubuntu7.1). The error message is error: prohibited by secure boot policy if we try the loadfont command. As in https://forums.debian.net/viewtopic.php?t=153356 somebody said there's a fixed version in debian 11.6, I tried leaving LTS and updating to 23.04 to get grub 2.06-2ubuntu16 but to no avail. Has anybody found a working solution? – Adrien Rey-Jarthon Apr 25 '23 at 11:50
  • ℹ️ For pixel perfect: Use --verbose to see the default size, then select a --size which is a multiple of that. – Alberto Salvia Novella Dec 22 '23 at 02:43
9

In Debian/Ubuntu you can change the default GRUB resolution, thereby resulting in larger fonts on the GRUB menu:

  1. Make a backup: sudo cp -a /etc/default/grub /etc/default/grub.bak
  2. Open the configuration: sudo $EDITOR /etc/default/grub
  3. Edit GRUB_GFXMODE entry to suit your resolution e.g. 800x600
  4. sudo update-grub
  5. Reboot; GRUB will display in the mode you set.
Matt F.
  • 119
arunk
  • 91
6

Yes, both the font and the font size can be customised. See the grub-mkfont utility. Bitmap (.pf2) and Truetype (.ttf) fonts are supported.

Just do an Internet search on grub-mkfont and you will quickly come across a number of examples of the necessary steps.

fpmurphy
  • 4,636
4

I whipped up a little script to automatically scale font size to monitor/screen width.

SCREEN_WIDTH=$(xdpyinfo | grep dimensions | cut -d ':' -f 2 | cut -d 'x' -f 1)
FONT_SIZE=$((${SCREEN_WIDTH} / 80))
sudo grub-mkfont -s ${FONT_SIZE} -o /boot/grub/DejaVuSansMono.pf2 /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
printf "\nGRUB_FONT=/boot/grub/DejaVuSansMono.pf2" | sudo tee -a /etc/default/grub
sudo grub-mkconfig -o /boot/grub/grub.cfg

A few caveats

  • This font is different from the default one
  • On old systems you might need grub2 instead of grub
  • Doesn't consider multi-monitor setups

Enjoy!

xjcl
  • 341
3

If you are looking for a simpler GUI alternative, you can use Grub Customiser to change the font size, colors and background of GRUB.