LinuxCommandLibrary

grub

Configure the bootloader

SYNOPSIS

grub [OPTION...] [file]

PARAMETERS

--help
    Display usage information and exit

--version
    Print GRUB version details and exit

--no-config
    Skip loading any configuration files

--no-curses
    Disable curses-based user interface

--no-disk-cache
    Prevent using on-disk module cache

--batch[=file]
    Run non-interactively from script file

--device-map[=file]
    Use specified device.map file (legacy)

DESCRIPTION

The grub command launches the GRand Unified Bootloader (GRUB) command-line interface, a powerful tool for booting operating systems. Primarily used in rescue scenarios, testing, or manual boot configuration, it allows direct execution of GRUB commands without relying on menu files.

Users can set root devices with root, load kernels via linux or kernel, specify initramfs with initrd, and initiate boot with boot. It supports multiboot for various OSes, including Linux, Windows, and BSD, with features like chainloading and filesystem probing.

GRUB excels in flexibility, handling complex partitions (GPT, LVM, RAID) and providing tab-completion, command history, and embedded scripting. Invoke it from live media or by interrupting the boot process (Shift key). Modern distros symlink grub to GRUB 2, differing from legacy GRUB 0.97 in syntax and modules.

Ideal for recovery when /boot/grub/grub.cfg fails, but requires familiarity to avoid boot loops or misconfigurations.

CAVEATS

Legacy GRUB syntax differs from GRUB 2; verify version with grub --version. Requires root privileges or boot environment. Errors in commands can prevent booting; test in VM first.
GRUB 2 distros may use grub2 binary instead.

KEY INTERACTIVE COMMANDS

root (hd0,0) - Set root filesystem
linux /vmlinuz root=/dev/sda1 - Load kernel
initrd /initrd.img - Load initramfs
boot - Start booting
ls - List devices/files

MODULES AND FILESYSTEMS

Supports ext2/3/4, btrfs, xfs, ntfs, fat via modules like insmod ext2, insmod linux. Probe with ls (hd0,msdos1)/.

HISTORY

Developed in 1995 by Erich Boleyn as a replacement for LILO. GRUB Legacy (0.97) released 2002. GRUB 2 development began 2001 by Yoshinori Okuji and team, with stable 1.97 in 2009, now at 2.12+. Enhanced for UEFI, GPT, and scripting.

SEE ALSO

Copied to clipboard