Skip to main content

GRUB - Grand Unified Boot Loader

GRUB's responsibility in the boot process

GRUB2 Installation

There may come a time where you need to install or reinstall GRUB2 on a system. Depending on whether your system is booting via BIOS or UEFI, you'll need to use a slightly different method;

  1. BIOS
    The below command can be used to install GRUB2 on a BIOS system (using MBR disks format)
    grub2-install [options] /dev/sdX
    OptionFunction
    --modules modulenames

    Reload specified kernel modules

    --install-modules modulenamessInstall only the specified modules and dependencies.



  2. UEFI


GRUBGRUB2 Configuration Options

There are 2 directories to note when talking about GRUB;GRUB2;

/etc/grub - This directory stores configuration scripts that define boot entries for GRUB2.

/boot/grub - This directory stores the actual GRUB2 configuration files used during boot.

There are also 2 commands to note for GRUB configuration:

grubby

  • Function: grubby is a command-line tool that allows you to directly manipulate individual GRUB2 menu entries on your system. It provides functionalities for:

    • Setting the default boot entry
    • Adding, removing, or modifying existing entries
    • Changing boot order
    • Viewing information about current entries
  • Focus: grubby operates on individual boot entries within the existing GRUB2 configuration.


     

grub2-mkconfig

  • Function: grub2-mkconfig (or sometimes shortened to update-grub on some systems) is a utility used to regenerate the GRUB2 configuration file (grub.cfg) located in /boot/grub. It reads configuration scripts from the /etc/grub.d directory.
  • Focus: grub2-mkconfig focuses on rebuilding the entire GRUB2 configuration file based on the defined scripts. This ensures the grub.cfg file reflects any changes made to the configuration scripts in /etc/grub.d.