GRUB
GRUB illustration by Karol Kreński. | |
Original author(s) | Erich Boleyn |
---|---|
Developer(s) | GNU Project |
Initial release | 1995 |
Repository | git.savannah.gnu.org/git/grub.git |
Written in | C, assembler |
Operating system | Can load Linux, macOS, BSD, Windows, Solaris |
Platform | IA-32, x86-64, IA-64, ARM, PowerPC, s390x, MIPS and SPARC |
Type | Bootloader |
License | GPLv3 |
Documentation | www.gnu.org/software/grub/grub-documentation.html |
Website | www.gnu.org/software/grub/ |
GNU GRUB (short for GNU GRand Unified Bootloader) is the most common boot loader on modern GNU/Linux operating systems. It can be loaded from older computers with a BIOS that loads the bootloader off the first sector on a HDD or modern machines UEFI firmware that load boot loaders off a special EFI partition.
There have been three major versions released by the GNU Project. GRUB 2 is the modern versions most machines using GRUB use today.
Configuration[edit]
The GRUB2 bootloader is (typically) configured in either /boot/grub2/grub.cfg
OR /boot/efi/EFI/<distribution>/grub.cfg
. This is the file GRUB loads when it looks to see how it is configured. However, it is typically not the file end users should use to configure it.
End-user GRUB2 configuration is typically done with a configuration file with variables in /etc/default/grub
. There may or may not be a symbolic link to that file in /etc/sysconfig/grub
. That file should be a POSIX compliant list of variables such as:
GRUB_TIMEOUT=8
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="resume=/dev/mapper/ssd_swap rd.lvm.lv=live/root rd.luks.uuid=luks-b6acc605-ef7b-48e6-b881-1304cf078ac5 rd.md.uuid=5298a73d:89065962:cac4015a:b69353f7 rd.lvm.lv=live/ssd_swap rhgb idle=nomwait amdgpu.dc=1 log_buf_len=5M mitigations=off pcie_aspm=off quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=false
The GRUB2 configuration utility grub2-mkconfig
can be used to generate GRUB2 configuration files using the settings in the /etc/default/grub
configuration file together with a series of POSIX compliant shell scripts in /etc/grub.d/
. Special menu entries, GRUB2 themes and other custom GRUB2 configuration can be done by adding custom scripts that add custom settings in /etc/grub.d/
.
Most GNU/Linux distributions will call grub2-mkconfig
semi-regularly. Some will call it when GRUB2 packages are updated, some call it every time a new kernel is installed. Some modern GNU/Linux distributions keep a mostly static GRUB2 configuration file and add kernel-specific loader entries as files in /boot/loader/entries/
.
You should configure GRUB2 using the /etc/default/grub
configuration file and optionally scripts dropped into in /etc/grub.d/
and run grub2-mkconfig -o /boot/efi/EFI/<distribution>/grub.cfg
(some distributions like to rename grub2-mkconfig
to grub-mkconfig
for historical compatibility).
You can just go right ahead and make your custom changes to /boot/efi/EFI/<distribution>/grub.cfg
if you really want to, but you can't expect those changes to last; your distribution will update/re-generate it automatically sooner or later and your changes will be lost.
Adding Custom Fonts[edit]
GRUB2 may end up showing you really tiny text in the boot loader menu. That is specially true if you have something like a 13.3" 1080p screen on a laptop or notebook. You can change the font, and font size, but it requires some shell work.
The first thing you need to do if you want GRUB2 to show special fonts is to change the way it outputs information. Most distributions default to using what GRUB2 calls "native platform console" output. That's usually a simple text-mode. GRUB2 has another output mode available called gfxterm
that is described in the GRUB2 manual as "graphics-mode output". This is want you want, and you can use GRUB_TERMINAL_OUTPUT
to get it.
# GRUB_TERMINAL_OUTPUT="console"
GRUB_TERMINAL_OUTPUT="gfxterm"
You can make the gfxterm
use any PFF2 font format bitmap font by adding a GRUB_FONT=
(not what ends up in the grub.cfg
files) line to /etc/default/grub
.
You probably don't have any PFF2 font files. That's fine, there is a utility called grub2-mkfont
(or grub-mkfont
one some distributions). It can take any standard TrueType font and convert it to a .pf2 --output=
in a specific --size=
. You will font a lot of TrueType fonts in /usr/share/fonts/
. You will want to use one of the "monospace" fonts (find /usr/share/fonts/ -iname "*mono*"
).
grub2-mkfont
can be used to create a font like this (be root
or use sudo
):
grub2-mkfont --output=/boot/grub2/fonts/LiberationMono-Regular-36.pf2 \
--size=32 /usr/share/fonts/liberation-mono/LiberationMono-Regular.ttf
Notice that you can only have one size in pf2
font files; they are bitmap font files, not scalable fonts.
grub2-mkconfig
will make GRUB2 configuration files using pf2
fonts if you specify a font files with the GRUB_FONT
variable.
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_FONT=/boot/grub2/fonts/LiberationMono-Regular-36.pf2
Note: Make sure to place font files on the EFI partition (/boot/efi/EFI/<distribution>/fonts/ if you use EFI to load GRUB2. EFI partion (/boot/efi/ ) is typically not the same partition as the /boot/ partition.
|
Links[edit]
- GNU GRUB website: https://www.gnu.org/software/grub/index.html
- Documentation: https://www.gnu.org/software/grub/grub-documentation.html
- Arch Wiki: GRUB
- Debian Wiki: Grub2
Enable comment auto-refresher