grub
Configure the bootloader
SYNOPSIS
grub-install [options]
PARAMETERS
grub-install
Installs GRUB on a specified device.
grub-mkconfig
Generates GRUB configuration file (grub.cfg).
grub-mkrescue
Creates a bootable image (e.g., ISO).
--target=
Set the target platform for grub-install (e.g., i386-pc, x86_64-efi).
--boot-directory=
Set the boot directory for grub-install (where GRUB files are stored).
--recheck
Probe all devices when running grub-install.
-o
Output file (used with grub-mkconfig and grub-mkrescue).
--root-directory=
Use images under DIRECTORY rather than the root filesystem.
DESCRIPTION
The GRUB (GRand Unified Bootloader) is a boot loader package from the GNU project, most commonly used on Linux systems, but can also be used on other Unix-like operating systems. GRUB allows a user to have multiple operating systems on a single machine and choose which one to boot at startup.
The command `grub` itself isn't a direct user-executable command in the way `ls` or `cp` is. Instead, it refers to a family of tools and configuration files that work together to manage the boot process. These tools include `grub-install` (used to install GRUB to a boot device), `grub-mkconfig` (used to generate the GRUB configuration file), and `grub-mkrescue` (used to create bootable media). The heart of GRUB functionality lies in its ability to read configuration files, present a boot menu, load kernels, and transfer control to the operating system.
Key components include the GRUB configuration file (usually `/boot/grub/grub.cfg` or `/boot/efi/EFI/ubuntu/grub.cfg`), which defines boot entries and options, and the GRUB modules, which provide filesystem support, video drivers, and other essential functionality.
GRUB supports several filesystems, allowing it to load a kernel from various locations without relying on the operating system being already loaded.
CAVEATS
Incorrect configuration of GRUB can render a system unbootable. Always back up configuration files before making changes. Be careful when installing to disks that contain other operating systems.
CONFIGURATION FILES
The primary GRUB configuration file is typically located at `/boot/grub/grub.cfg`. Directly editing this file is discouraged; instead, use `grub-mkconfig` to generate it from template files in `/etc/grub.d/` and settings in `/etc/default/grub`.
BOOT PROCESS
When the computer starts, the BIOS loads the boot sector from the configured boot device. This boot sector contains the first stage of GRUB. GRUB then loads its core image, reads the configuration file, presents the boot menu (if configured), and loads the selected kernel and initrd (initial ramdisk) into memory. Finally, GRUB transfers control to the kernel, which then takes over the boot process.
RESCUE MODE
If the system fails to boot correctly, GRUB provides a rescue mode, accessible from the GRUB command line. This allows you to manually load a kernel, mount the root filesystem, and perform troubleshooting tasks.
HISTORY
GRUB's development started in the mid-1990s as a successor to LILO (Linux Loader). It was designed to address some of LILO's limitations, such as the 16-bit architecture which restricted number of bootable partitions and its inflexibility in handling more complex boot scenarios. The development was led by Erich Boleyn and then Gordon Matzigkeit. GRUB has become the standard bootloader for many Linux distributions due to its flexibility, filesystem support, and scripting capabilities. GRUB 2 is a major rewrite and enhancement of the original GRUB.
The initial purpose was to unify different GNU/Hurd kernels, but it became the main Linux bootloader.
SEE ALSO
efibootmgr(8), os-prober(8)