A bootloader is a small program that acts as a bridge between the BIOS/UEFI firmware and the operating system kernel.
Think of it as: The "middle manager" that receives the system from hardware initialization and prepares it for the operating system.
Location:
BIOS/MBR systems: First 512 bytes of the disk (MBR)
UEFI/GPT systems: EFI System Partition (ESP) at /boot/efi
/boot/efi
The BIOS/UEFI doesn't know how to load an operating system directly. The bootloader:
✅ Provides a menu to choose between multiple operating systems
✅ Loads the Linux kernel into memory
✅ Loads the initial RAM disk (initrd/initramfs)
✅ Passes boot parameters to the kernel
✅ Handles boot-time configuration
Original version, now called "GRUB Legacy"
Rarely used today
Configuration: /boot/grub/menu.lst or /boot/grub/grub.conf
/boot/grub/menu.lst
/boot/grub/grub.conf
Modern replacement for GRUB
Used by: Ubuntu, Fedora, Debian, CentOS, RHEL, and most distributions
Much more powerful and flexible
Configuration: /boot/grub/grub.cfg (auto-generated, don't edit directly!)
/boot/grub/grub.cfg
One of the oldest bootloaders
Largely obsolete
Configuration: /etc/lilo.conf
/etc/lilo.conf
Simple UEFI-only bootloader
Used by: Some Arch Linux installations
Configuration: /boot/loader/
/boot/loader/
Lightweight bootloader
Often used for: USB drives, rescue disks
Multiple variants: ISOLINUX (CDs), PXELINUX (network boot)
1. BIOS/UEFI → Loads GRUB 2
2. GRUB 2 reads configuration (/boot/grub/grub.cfg)
3. Displays boot menu (if multiple options exist)
4. User selects OS or waits for timeout
5. GRUB 2 loads kernel image (vmlinuz-*)
6. GRUB 2 loads initramfs (initrd.img-* or initramfs-*)
7. Passes control to kernel with boot parameters
8. Kernel takes over
File/Directory
Purpose
Main GRUB 2 configuration (AUTO-GENERATED - don't edit!)
/etc/default/grub
User-editable GRUB settings
/etc/grub.d/
Scripts that generate grub.cfg
/boot/grub/ or /boot/grub2/
/boot/grub/
/boot/grub2/
GRUB installation directory
/boot/efi/EFI/
UEFI bootloader location
File
/boot/vmlinuz-*
Compressed Linux kernel image
/boot/initrd.img-*
Initial RAM disk (Debian/Ubuntu)
/boot/initramfs-*
Initial RAM filesystem (RHEL/CentOS/Fedora)
/boot/System.map-*
Kernel symbol table
/boot/config-*
Kernel configuration file
This is the file you SHOULD edit to customize GRUB.
# Default boot entry (0 = first, 1 = second, etc.)
GRUB_DEFAULT=0
# Wait time before auto-booting (seconds)
GRUB_TIMEOUT=5
# Show/hide GRUB menu (true/false)
GRUB_TIMEOUT_STYLE=menu
# Kernel boot parameters
GRUB_CMDLINE_LINUX="quiet splash"
# Additional kernel parameters for normal boot
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
# Resolution for GRUB menu
GRUB_GFXMODE=640x480
# Terminal output
GRUB_TERMINAL=console
# Disable submenu grouping
GRUB_DISABLE_SUBMENU=true
# Remember last boot choice
GRUB_SAVEDEFAULT=false
Scripts that build the final grub.cfg:
grub.cfg
Script
00_header
Basic GRUB settings
05_debian_theme
Appearance settings (Debian/Ubuntu)
10_linux
Detects Linux kernels
20_linux_xen
Xen hypervisor support
30_os-prober
Detects other operating systems
40_custom
User custom entries
41_custom
Another custom entry file
Scripts are executed in numerical order.
After editing /etc/default/grub, you MUST regenerate grub.cfg:
Debian/Ubuntu:
sudo update-grub # OR sudo grub-mkconfig -o /boot/grub/grub.cfg
sudo update-grub
# OR
sudo grub-mkconfig -o /boot/grub/grub.cfg
RHEL/CentOS/Fedora:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg # For UEFI systems: sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# For UEFI systems:
sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
If GRUB is corrupted or missing:
BIOS/MBR systems:
sudo grub-install /dev/sda # Where /dev/sda is your disk (not partition!)
sudo grub-install /dev/sda
# Where /dev/sda is your disk (not partition!)
UEFI systems:
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi
# Method 1
ls /boot/vmlinuz-*
# Method 2
dpkg --list | grep linux-image # Debian/Ubuntu
rpm -qa | grep kernel # RHEL/CentOS/Fedora
# List all boot entries with numbers
sudo grep menuentry /boot/grub/grub.cfg
# Set default (e.g., entry #2)
sudo grub-set-default 2
# OR edit /etc/default/grub
GRUB_DEFAULT=2
grub-install --version
grub2-install --version
When you see the GRUB menu at boot:
Key
Action
↑/↓ arrows
Navigate menu entries
Enter
Boot selected entry
e
Edit boot parameters (temporary)
c
Open GRUB command line
Esc
Return to menu (from edit mode)
Press 'e' at GRUB menu to temporarily edit boot parameters:
# Boot into single-user mode (rescue/recovery)
single
systemd.unit=rescue.target
# Boot into multi-user mode (no GUI)
systemd.unit=multi-user.target
3
# Boot into graphical mode s
# Boot into graphical mode
s
ystemd.unit=graphical.target
5
# Boot with different root partition
root=/dev/sda2
# Boot in verbose mode (remove quiet)
# Remove: quiet splash
# See all boot messages
# Disable graphics mode
nomodeset
# Boot with previous kernel (useful if new kernel fails)
# Select "Advanced options" → older kernel
To boot with edited parameters:
Press Ctrl + X or F10 after editing
Press 'c' at GRUB menu to access command line.
# List all partitions
ls
# View partition contents
ls (hd0,1)/
# Set root partition
set root=(hd0,1)
# Load kernel
linux /vmlinuz-5.4.0-42-generic root=/dev/sda1
# Load initrd
initrd /initrd.img-5.4.0-42-generic
# Boot
boot
# View environment variables
set
# Search for file
search --file /vmlinuz
# Display help
help
vmlinuz = Compressed Linux kernel
Location: /boot/vmlinuz-[version]
/boot/vmlinuz-[version]
Purpose: Core of the operating system
Size: Typically 5-10 MB
Example:
/boot/vmlinuz-5.15.0-56-generic
Two types:
initrd (Initial RAM Disk) - Older format
File: /boot/initrd.img-[version]
/boot/initrd.img-[version]
Block device in RAM
Used by: Older systems
initramfs (Initial RAM Filesystem) - Modern format
File: /boot/initramfs-[version]
/boot/initramfs-[version]
Compressed cpio archive
Used by: Modern systems (RHEL, Fedora, CentOS)
Purpose:
Contains essential drivers and modules
Provides temporary root filesystem
Needed before the real root filesystem can be mounted
Contains tools for mounting encrypted/LVM/RAID volumes
/boot/initrd.img-5.15.0-56-generic # Debian/Ubuntu
/boot/initrd.img-5.15.0-56-generic
# Debian/Ubuntu
/boot/initramfs-5.15.0-56.el8.x86_64 # RHEL/CentOS
/boot/initramfs-5.15.0-56.el8.x86_64
# RHEL/CentOS
Parameter
quiet
Suppress most boot messages
splash
Show graphical splash screen
ro
Mount root filesystem as read-only initially
root=/dev/sda1
Specify root partition
init=/bin/bash
Boot directly to bash shell (emergency)
Boot into single-user mode
Boot to multi-user mode (no GUI)
Boot to graphical mode
Disable kernel mode setting (graphics issues)
acpi=off
Disable ACPI (power management issues)
mem=4G
Limit RAM usage to 4GB
maxcpus=2
Limit to 2 CPU cores
Symptoms:
GRUB loading...
error: no such partition
grub rescue>
Solution:
Boot from live USB/CD
Mount your root partition:
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
Chroot into system:
sudo chroot /mnt
Reinstall GRUB:
grub-install /dev/sda
update-grub
Exit and reboot:
exit
sudo umount /mnt/dev /mnt/proc /mnt/sys /mnt
sudo reboot
Solution: Boot with previous kernel from GRUB menu
Select "Advanced options"
Choose older kernel version
Once booted, remove problematic kernel:
sudo apt remove linux-image-[bad-version] # Debian/Ubuntu
sudo apt remove linux-image-[bad-version]
sudo dnf remove kernel-[bad-version] # Fedora
sudo dnf remove kernel-[bad-version]
# Fedora
Solution: Boot into single-user mode
Press 'e' at GRUB menu
Find line starting with linux or linux16
linux
linux16
Add single or init=/bin/bash at end
Press Ctrl+X to boot
Reset password:
passwd root
Reboot
GRUB 2 can boot multiple operating systems:
# Install os-prober
sudo apt install os-prober # Debian/Ubuntu
sudo apt install os-prober
sudo dnf install os-prober # Fedora
sudo dnf install os-prober
# Detect other operating systems
sudo os-prober
# Update GRUB to include detected OS
Edit /etc/grub.d/40_custom:
/etc/grub.d/40_custom
menuentry "My Custom Linux" {
linux /vmlinuz-5.15.0-56-generic root=/dev/sda1 ro quiet
initrd /initrd.img-5.15.0-56-generic
}
Then update GRUB:
# Generate password hash
grub-mkpasswd-pbkdf2
# Enter password when prompted
# Add to 40_custom:
set superusers="admin"
password_pbkdf2 [REDACTED:PASSWORD] [hash-from-above]
Update GRUB:
Now users need password to edit boot entries or access GRUB command line.
What does GRUB stand for?
GRand Unified Bootloader
What is the primary purpose of a bootloader?
To load the Linux kernel and initrd/initramfs into memory and pass control to the kernel
Where is the main GRUB 2 configuration file located?
/boot/grub/grub.cfg (or /boot/grub2/grub.cfg on some systems)
/boot/grub2/grub.cfg
Should you directly edit /boot/grub/grub.cfg? Why or why not?
No, it's auto-generated and changes will be overwritten. Edit /etc/default/grub instead and regenerate the config.
What file should you edit to customize GRUB settings?
What command regenerates the GRUB configuration on Debian/Ubuntu systems?
udo update-grub or sudo grub-mkconfig -o /boot/grub/grub.cfg
udo update-grub
What command regenerates the GRUB configuration on RHEL/CentOS/Fedora systems?
What command installs GRUB to the MBR of /dev/sda?
What directory contains scripts that generate the GRUB configuration?
What does the kernel image file typically start with?
vmlinuz- (e.g., /boot/vmlinuz-5.15.0-56-generic)
vmlinuz-
What are the two types of initial RAM disk files used in Linux?
initrd (initrd.img-) and initramfs (initramfs-)
Where are kernel and initrd/initramfs files typically stored?
/boot/ directory
/boot/
What key do you press at the GRUB menu to temporarily edit boot parameters?
e (edit)
What key do you press to boot after editing GRUB parameters?
Ctrl + X or F10
What key opens the GRUB command line interface?
What parameter in /etc/default/grub sets the default boot entry?
GRUB_DEFAULT=0 (where 0 is the first entry, 1 is second, etc.)
What parameter in /etc/default/grub sets the boot menu timeout?
GRUB_TIMEOUT=5 (in seconds)
What boot parameter boots the system into single-user/rescue mode?
single or systemd.unit=rescue.target
What does the kernel parameter "quiet" do?
Suppresses most boot messages, showing only critical errors
What does the kernel parameter "splash" do?
Displays a graphical splash screen during boot instead of text messages
What boot parameter can you add to see all boot messages?
Remove "quiet" from the kernel command line, or remove both "quiet splash"
What is the purpose of initrd/initramfs?
Provides a temporary root filesystem with essential drivers and tools needed to mount the real root filesystem
What command lists all available kernels on Debian/Ubuntu?
dpkg --list | grep linux-image or ls /boot/vmlinuz-*
dpkg --list | grep linux-image
What command lists all available kernels on RHEL/CentOS/Fedora?
rpm -qa | grep kernel or ls /boot/vmlinuz-*
rpm -qa | grep kernel
In BIOS/MBR systems, where is GRUB installed?
In the Master Boot Record (MBR) - first 512 bytes of the disk
In UEFI/GPT systems, where are GRUB files stored?
In the EFI System Partition (ESP), typically at /boot/efi/EFI/[distro]/
/boot/efi/EFI/[distro]/
What is the GRUB command to list all partitions?
ls (from GRUB command line)
What is the GRUB notation for the first hard drive, first partition?
(hd0,1) or (hd0,msdos1) for MBR, (hd0,gpt1) for GPT
(hd0,1)
(hd0,msdos1)
(hd0,gpt1)
What command detects other operating systems for multi-boot?
After running os-prober, what must you do to add detected OS to GRUB menu?
Run sudo update-grub or sudo grub2-mkconfig
sudo grub2-mkconfig
What file can you edit to add custom GRUB menu entries?
/etc/grub.d/40_custom or /etc/grub.d/41_custom
/etc/grub.d/41_custom
What boot parameter specifies which partition to use as root?
root=/dev/sda1 (or appropriate partition)
What boot parameter boots directly to a bash shell (emergency access)?
What boot parameter disables graphics mode (useful for display issues)?
What is the typical sequence of the boot process?
BIOS/UEFI → Bootloader (GRUB) → Kernel → initrd/initramfs → Init System (systemd)
If GRUB shows "grub rescue>" prompt, what has likely happened?
GRUB cannot find its configuration files or the boot partition, usually due to partition changes or corruption
What does GRUB_CMDLINE_LINUX in /etc/default/grub do?
Specifies kernel boot parameters that apply to all Linux boot entries (normal and recovery)
What does GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub do?
Specifies kernel boot parameters for normal boot only (not recovery mode)
How do you boot into multi-user mode without GUI?
Add systemd.unit=multi-user.target or 3 to kernel parameters
How do you boot into graphical mode?
Add systemd.unit=graphical.target or 5 to kernel parameters
systemd.unit=graphical.target
What command shows the GRUB version?
grub-install --version or grub2-install --version
What is the difference between GRUB and GRUB 2?
GRUB 2 is the modern, more powerful replacement for GRUB Legacy, with better features, flexibility, and support for UEFI
What does the bootloader do after loading the kernel and initrd?
It passes boot parameters to the kernel and transfers control to it
What parameter makes GRUB remember the last booted entry?
GRUB_SAVEDEFAULT=true (also requires GRUB_DEFAULT=saved)
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved
What is the purpose of /boot/System.map?
Contains kernel symbol table for debugging (maps memory addresses to function names)
What is the typical size of the EFI System Partition?
100-550 MB, formatted as FAT32
What command generates a GRUB password hash?
What happens if you forget to run update-grub after editing /etc/default/grub?
Your changes won't take effect because grub.cfg hasn't been regenerated
What is the role of the /etc/grub.d/10_linux script?
It detects and adds Linux kernels installed in /boot to the GRUB menu
What is the role of the /etc/grub.d/30_os-prober script?
It detects other operating systems on the system and adds them to the GRUB menu
Last changeda month ago