GRUB (GRand Unified Bootloader) is an essential component of most Linux systems. It loads the Linux kernel into memory during the boot process and allows users to select between different operating systems or kernels if multiple ones are installed. On Arch Linux, keeping GRUB up-to-date is important to ensure proper system boot and access to newly installed kernels or operating systems. This comprehensive guide will cover multiple methods of updating GRUB on Arch Linux.
Understanding GRUB Components
Before updating GRUB, it‘s important to understand the key files and directories involved:
-
/boot/grub/grub.cfg – This is the main GRUB configuration file read during boot. It includes menu entries for installed kernels and operating systems. It should not be edited directly but is automatically generated based on other GRUB-related files.
-
/etc/default/grub – This file contains global GRUB configuration options such as the default menu entry, timeout duration before automatic booting, and display settings.
-
/etc/grub.d – This directory contains scripts that help generate the final grub.cfg configuration file when grub-mkconfig is run. Any custom user scripts should be added here.
-
grub-mkconfig – This command generates an updated grub.cfg based on /etc/default/grub and /etc/grub.d. It should be run after making most changes related to GRUB.
Updating GRUB Using grub-mkconfig
The simplest way to update GRUB on Arch Linux is by regenerating the grub.cfg configuration file using the grub-mkconfig command:
sudo grub-mkconfig -o /boot/grub/grub.cfg
This will read all relevant GRUB configuration files and scripts and write an updated grub.cfg with any new kernels or operating systems discovered.
Advantages of using grub-mkconfig include:
- Simple one line command.
- Automatically detects kernel updates.
- Additional grub.d scripts are incorporated.
The main limitation is lack of user-friendliness for more advanced configuration changes.
Updating GRUB with Grub Customizer
For a graphical interface to manage GRUB options, Grub Customizer can be installed:
sudo pacman -S grub-customizer
Grub Customizer allows changing backgrounds, menu colors, timeout durations, as well as easily adding/removing or editing menu entries and options.
Key advantages include:
- Friendly graphical interface.
- Menu entry management.
- Appearance customization.
Disadvantages include reliance on KDE Framework, lack of command line accessibility, and inability to detect new kernels automatically.
After making changes in Grub Customizer, grub-mkconfig must still be run for them to take effect:
sudo grub-mkconfig -o /boot/grub/grub.cfg
Updating GRUB Using update-grub Package
For Arch Linux systems, a package called "update-grub" is available to handle GRUB updates:
sudo pacman -S update-grub
Alternatively it can be installed using git:
git clone https://aur.archlinux.org/update-grub.git
cd update-grub
makepkg -sri
The update-grub script can then be run whenever changes are made related to GRUB:
sudo update-grub
This performs a number of helpful tasks:
- Updates grub.cfg with latest kernel changes.
- Adds new Linux and Windows installations automatically.
- Updates GRUB after software upgrades.
- Integrates with Arch systems well.
Limitations include lack of user-friendly configuration and inability to change GRUB themes/backgrounds.
Recovery Options If GRUB Breaks
If GRUB becomes corrupted or configuration mistakes prevent booting, recovery options include:
- Using live CD and reinstalling GRUB.
- Manually editing grub.cfg or other files.
- Using Arch fallback image to boot and fix configuration.
As long as the Linux partitions and kernels themselves are intact, GRUB can almost always be repaired from a recovery shell or live environment.
Conclusion
Keeping GRUB up to date is crucial for ensuring proper system boot and access to all installed operating systems on an Arch Linux computer. Using grub-mkconfig, Grub Customizer, and update-grub provides overlapping ways to update the bootloader. Learning to monitor GRUB and repair issues from live CDs or recovery environments can also prove invaluable for maintaining system access. With practice, updating GRUB can become a routine part of an Arch administrator‘s toolbelt.


