GRUB (GRUB)
GRUB is the program that starts Linux on most computers. After the motherboard hands off control, GRUB finds the Linux kernel on the disk and launches it. It can show a menu so you can pick an older kernel, start recovery mode, or boot a different operating system. When Linux will not start, GRUB is often where you begin fixing it.
GRUB 2 (the current version; GRUB Legacy is long retired) is a GNU project bootloader that understands filesystems (ext4, XFS, Btrfs, LVM, some RAID), so it can read the kernel straight from /boot.
Configuration flow on Ubuntu:
- Edit
/etc/default/grub(timeout, default entry,GRUB_CMDLINE_LINUX_DEFAULT) - Scripts in
/etc/grub.d/(such as10_linux,30_os-prober,40_custom) generate entries update-grub(a wrapper forgrub-mkconfig -o /boot/grub/grub.cfg) writes the final config
At boot:
- Hold Shift (BIOS) or tap Esc (UEFI) to show a hidden menu
eedits an entry for one boot;Ctrl+Xboots itcopens the GRUB command line- “Advanced options” lists older kernels and recovery mode
Useful one-time kernel parameters: systemd.unit=rescue.target, systemd.unit=emergency.target, nomodeset (skip graphics drivers), removing quiet splash to see boot messages.
The grub> prompt means GRUB loaded but found no config. grub rescue> means it could not even find its own modules, usually a missing or moved partition.
Source: ArchWiki: GRUB
Configuring and repairing GRUB
# Current defaults
$ grep -E "^GRUB_(DEFAULT|TIMEOUT|CMDLINE)" /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
# Apply changes
$ sudo update-grub
# Boot by hand from the grub> prompt
grub> ls
grub> set root=(hd0,gpt2)
grub> linux /boot/vmlinuz root=/dev/sda2 ro
grub> initrd /boot/initrd.img
grub> boot Knowing GRUB turns “the server will not boot” from a reinstall into a ten-minute fix. Typical jobs: booting the previous kernel after a bad update, adding a kernel parameter to get past a graphics hang, recovering a forgotten password through recovery mode, and reinstalling GRUB after a dual-boot accident. Set a visible timeout on lab and server machines so you can reach the menu without fighting the keyboard timing.