LinuxCommandLibrary

update-grub

Updates GRUB boot menu configuration

SYNOPSIS

update-grub

DESCRIPTION

The update-grub command is a crucial utility in Linux distributions that use the GRand Unified Bootloader version 2 (GRUB 2). It's typically a shell script wrapper for the grub-mkconfig command, designed to simplify the process of generating the grub.cfg configuration file. This file, usually located at /boot/grub/grub.cfg, dictates the boot menu entries, kernel versions, and other bootloader settings.

When executed, update-grub scans your system for installed operating systems, including different Linux kernels and other OSes like Windows, often leveraging the os-prober utility for detection. It then compiles this information, along with settings from /etc/default/grub and scripts in /etc/grub.d/, into a new grub.cfg. This process ensures that the GRUB boot menu accurately reflects all available boot options, which is essential after installing new operating systems, updating kernels, or modifying disk partitions.

CAVEATS

Requires root privileges to execute, typically by using sudo.
Direct manual edits to /boot/grub/grub.cfg will be overwritten the next time update-grub is run.
Detection of other operating systems relies on the os-prober utility; if it's not installed or disabled, other OSes might not appear in the GRUB menu.
Incorrect or missing configuration files in /etc/default/grub or /etc/grub.d/ can lead to boot issues.

WRAPPER SCRIPT

update-grub is typically a shell script (e.g., /usr/sbin/update-grub on Debian/Ubuntu-based systems) that essentially executes grub-mkconfig -o /boot/grub/grub.cfg. It's provided for convenience to make GRUB configuration updates simpler for users, as it handles the correct output path and common options automatically.

CONFIGURATION SOURCES

The generated grub.cfg file is built from several sources:
1. User-defined settings in /etc/default/grub (e.g., default boot entry, timeout).
2. Executable scripts in /etc/grub.d/, which handle generating entries for Linux kernels, memtest, and other operating systems detected by os-prober.
3. Detected kernel images and their associated initramfs files in /boot/.

HISTORY

The update-grub command emerged with GRUB 2, which replaced the older GRUB Legacy. GRUB 2 introduced a more modular and script-driven configuration system, moving away from the static menu.lst file. To manage this complexity, grub-mkconfig was introduced to dynamically generate the boot configuration. update-grub was then created as a user-friendly wrapper script to simplify the common task of regenerating the configuration, abstracting away the specific grub-mkconfig command-line options and output paths.

SEE ALSO

grub-install(8), grub-mkconfig(8), os-prober(8), grub(8)

Copied to clipboard