+
+
laravel
centos
+
~
jenkins
ansible
!=
+
oauth
∞
+
+
rest
+
->
pip
http
+
+
erlang
+
+
phoenix
+
+
+
postgres
+
+
+
graphdb
meteor
+
+
+
spring
+
+
+
+
terraform
+
+
^
+
+
bash
+
===
Ο€
+
@
mvn
tls
r
?
βˆ‰
fiber
+
+
+
sublime
+
soap
+
ada
+
dask
+
∞
+
+
+
grafana
rs
+
marko
junit
eclipse
wasm
+
+
+
+
+
+
goland
rubymine
Back to Blog
Understanding the Boot Process and GRUB Configuration in AlmaLinux πŸš€
AlmaLinux System Administration GRUB

Understanding the Boot Process and GRUB Configuration in AlmaLinux πŸš€

Published Aug 19, 2025

Master the AlmaLinux boot process from BIOS/UEFI to login prompt. Learn GRUB configuration, boot parameters, kernel management, troubleshooting techniques, and recovery methods for complete control over your system startup.

22 min read
0 views
Table of Contents

The boot process is one of the most critical aspects of any Linux system, yet it often remains mysterious to many administrators. Understanding how AlmaLinux boots from power-on to login prompt empowers you to troubleshoot boot issues, optimize startup time, and customize your system’s initialization. This comprehensive guide demystifies the AlmaLinux boot process and provides practical knowledge for managing GRUB bootloader configuration.

The Complete Boot Sequence

πŸ”„ Overview of Boot Stages

The AlmaLinux boot process consists of several distinct stages, each playing a crucial role in bringing your system to life:

  1. Hardware Initialization (BIOS/UEFI)
  2. Bootloader Stage (GRUB2)
  3. Kernel Loading (vmlinuz)
  4. Initial RAM Disk (initramfs)
  5. systemd Initialization (PID 1)
  6. Target Units (multi-user/graphical)
  7. Login Prompt (getty/gdm)

πŸ“Š Detailed Boot Flow

Power On β†’ BIOS/UEFI β†’ MBR/GPT β†’ GRUB2 β†’ Kernel β†’ initramfs β†’ systemd β†’ Targets β†’ Services β†’ Login

Let’s examine each stage in detail:

Stage 1: Hardware Initialization

# View firmware type
[ -d /sys/firmware/efi ] && echo "UEFI" || echo "BIOS"

# Check boot mode
systemctl status | grep -i "firmware"

# View hardware initialization logs
sudo dmesg | head -50

Stage 2: Bootloader Loading

# Check GRUB installation
sudo grub2-install --version

# View boot partition
df -h /boot
lsblk | grep -E "boot|efi"

# Check MBR/GPT
sudo fdisk -l | grep -E "Disklabel|boot"

BIOS vs UEFI Boot Process

πŸ–₯️ Legacy BIOS Boot

The traditional BIOS boot process:

# BIOS boot sequence
1. POST (Power-On Self Test)
2. Read MBR (first 512 bytes)
3. Execute boot code
4. Load GRUB from /boot
5. Display boot menu

BIOS Configuration:

# Check for BIOS boot
ls -la /boot/grub2/
sudo file /boot/grub2/i386-pc/core.img

# View MBR content
sudo dd if=/dev/sda bs=512 count=1 | hexdump -C | head

πŸš€ Modern UEFI Boot

The UEFI boot process is more sophisticated:

# UEFI boot sequence
1. UEFI firmware initialization
2. Read ESP (EFI System Partition)
3. Execute EFI bootloader
4. Load GRUB EFI application
5. Display boot menu

UEFI Configuration:

# Check UEFI boot
ls -la /boot/efi/EFI/

# View EFI boot entries
sudo efibootmgr -v

# List EFI variables
ls /sys/firmware/efi/efivars/

# View current boot order
sudo efibootmgr | grep BootOrder

πŸ”§ Managing EFI Boot Entries

# Add new boot entry
sudo efibootmgr -c -d /dev/sda -p 1 -l \\EFI\\almalinux\\shimx64.efi -L "AlmaLinux"

# Change boot order
sudo efibootmgr -o 0001,0002,0003

# Remove boot entry
sudo efibootmgr -b 0004 -B

# Set next boot only
sudo efibootmgr -n 0001

Understanding GRUB2 Bootloader

🎯 GRUB2 Architecture

GRUB2 (GRand Unified Bootloader version 2) is the default bootloader for AlmaLinux:

# GRUB2 components
/boot/grub2/              # BIOS systems
/boot/efi/EFI/almalinux/  # UEFI systems
/etc/grub2.cfg            # Symlink to main config
/etc/default/grub         # User configuration
/etc/grub.d/              # Configuration scripts

πŸ“ Key GRUB2 Features

# View GRUB version
grub2-install --version

# List GRUB modules
ls /usr/lib/grub/x86_64-efi/ | head -20

# Check GRUB installation
sudo grub2-probe /

# Test configuration
sudo grub2-script-check /etc/default/grub

GRUB Configuration Files

πŸ”§ Main Configuration Structure

# Primary configuration files
/etc/default/grub         # User-editable settings
/etc/grub.d/              # Script directory
/boot/grub2/grub.cfg      # Generated config (DO NOT EDIT)
/boot/grub2/grubenv       # Environment block

πŸ“‹ Essential /etc/default/grub Settings

# Edit main configuration
sudo nano /etc/default/grub

Example configuration:

# Boot timeout
GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE=menu

# Default boot entry
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

# Kernel parameters
GRUB_CMDLINE_LINUX="rd.lvm.lv=almalinux/root rd.lvm.lv=almalinux/swap rhgb quiet"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

# Display settings
GRUB_TERMINAL_OUTPUT="console"
GRUB_GFXMODE=1024x768
GRUB_GFXPAYLOAD_LINUX=keep

# Recovery options
GRUB_DISABLE_RECOVERY="false"
GRUB_DISABLE_SUBMENU=false

# OS Prober
GRUB_DISABLE_OS_PROBER=false

πŸ› οΈ Configuration Scripts in /etc/grub.d/

# List configuration scripts
ls -la /etc/grub.d/

# Script execution order
00_header     # GRUB settings
01_users      # User authentication
10_linux      # Linux kernels
20_linux_xen  # Xen kernels
30_os-prober  # Other operating systems
30_uefi-firmware # UEFI settings
40_custom     # Custom entries
41_custom     # Additional custom entries

Custom boot entry example:

# Create custom entry
sudo nano /etc/grub.d/40_custom

# Add custom entry
menuentry "AlmaLinux Recovery Mode" {
    set root=(hd0,1)
    linux /vmlinuz-5.14.0 root=/dev/sda2 ro single
    initrd /initramfs-5.14.0.img
}

# Make executable
sudo chmod +x /etc/grub.d/40_custom

πŸ”„ Regenerating GRUB Configuration

# For BIOS systems
sudo grub2-mkconfig -o /boot/grub2/grub.cfg

# For UEFI systems
sudo grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg

# Verify configuration
sudo grub2-script-check /boot/grub2/grub.cfg

Managing Boot Entries

πŸ“‹ Viewing Boot Entries

# List all boot entries
sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg

# View default entry
sudo grub2-editenv list

# Check saved entry
cat /boot/grub2/grubenv | grep saved_entry

🎯 Setting Default Boot Entry

# Set default by number
sudo grub2-set-default 0

# Set default by name
sudo grub2-set-default "AlmaLinux (5.14.0-162.el9.x86_64) 9.1"

# Set default for next boot only
sudo grub2-reboot "AlmaLinux (5.14.0-162.el9.x86_64) 9.1"

# Verify default
sudo grub2-editenv list

πŸ”§ Managing Kernel Entries

# List installed kernels
rpm -qa kernel

# View kernel entries
ls /boot/vmlinuz-*
ls /boot/initramfs-*

# Set specific kernel as default
sudo grubby --set-default /boot/vmlinuz-5.14.0-162.el9.x86_64

# View kernel info
sudo grubby --info=ALL

# Add kernel arguments
sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"

# Remove kernel arguments
sudo grubby --update-kernel=ALL --remove-args="rhgb quiet"

Kernel Parameters and Boot Options

πŸŽ›οΈ Common Kernel Parameters

# Essential parameters
root=         # Root filesystem
ro            # Mount root read-only initially
rd.lvm.lv=    # LVM logical volume
rd.md.uuid=   # RAID array UUID
rhgb          # Red Hat Graphical Boot
quiet         # Suppress verbose messages

πŸ”§ Debugging Parameters

# Add debugging parameters
debug                 # Enable debug messages
systemd.log_level=debug  # systemd debug
rd.debug             # initramfs debug
rd.shell             # Drop to shell in initramfs
rd.break             # Break at specific points
init=/bin/bash       # Boot to bash instead of systemd

Example debug configuration:

# Temporary debug boot
sudo grubby --update-kernel=DEFAULT --args="systemd.log_level=debug rd.debug"

# Remove after debugging
sudo grubby --update-kernel=DEFAULT --remove-args="systemd.log_level=debug rd.debug"

πŸš€ Performance Parameters

# Performance tuning
elevator=noop        # I/O scheduler
transparent_hugepage=never  # Disable THP
processor.max_cstate=1     # CPU power state
intel_idle.max_cstate=0    # Intel CPU idle
mitigations=off           # Disable CPU mitigations (UNSAFE)

Customizing GRUB Appearance

🎨 Theme Configuration

# Install GRUB themes
sudo dnf install grub2-themes

# Set theme
sudo nano /etc/default/grub
# Add: GRUB_THEME="/boot/grub2/themes/AlmaLinux/theme.txt"

# Create custom theme directory
sudo mkdir -p /boot/grub2/themes/custom

# Theme configuration file
sudo nano /boot/grub2/themes/custom/theme.txt

Theme configuration example:

# Global properties
title-text: "AlmaLinux Boot Menu"
title-font: "DejaVu Sans Bold 16"
title-color: "#ffffff"
desktop-image: "background.png"
desktop-color: "#000000"
terminal-font: "Fixed Regular 12"

# Boot menu
+ boot_menu {
  left = 15%
  width = 70%
  top = 20%
  height = 60%
  item_font = "DejaVu Sans Regular 12"
  item_color = "#cccccc"
  selected_item_color = "#ffffff"
  item_height = 24
  item_padding = 8
  item_spacing = 4
}

πŸ–ΌοΈ Background Images

# Copy background image
sudo cp wallpaper.png /boot/grub2/themes/custom/

# Convert image format
convert input.jpg -resize 1920x1080 background.png

# Set in configuration
GRUB_BACKGROUND="/boot/grub2/themes/custom/background.png"

Boot Process Troubleshooting

πŸ” Common Boot Issues

# Boot fails with kernel panic
# Solution: Boot older kernel from GRUB menu

# Boot stuck at "Starting Show Plymouth Boot Screen"
# Solution: Remove 'rhgb quiet' parameters

# Cannot find root device
# Solution: Check rd.lvm.lv or root= parameters

# SELinux preventing boot
# Solution: Add 'enforcing=0' to kernel parameters

πŸ› οΈ Diagnostic Tools

# View boot messages
sudo journalctl -b

# Check previous boot
sudo journalctl -b -1

# View kernel messages
sudo dmesg | less

# Check systemd boot process
systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain

# Generate boot chart
sudo systemd-analyze plot > boot.svg

πŸ“Š Boot Time Analysis

# Overall boot time
systemd-analyze

# Service startup times
systemd-analyze blame | head -20

# Critical path
systemd-analyze critical-chain

# Check specific service
systemd-analyze critical-chain NetworkManager.service

Emergency and Rescue Modes

🚨 Emergency Mode

# Boot to emergency mode
# Add to kernel parameters: systemd.unit=emergency.target

# Or press 'e' in GRUB and add:
emergency

# In emergency mode
mount -o remount,rw /
mount -a
systemctl default

πŸ›Ÿ Rescue Mode

# Boot to rescue mode
# Add to kernel parameters: systemd.unit=rescue.target

# Or press 'e' in GRUB and add:
rescue

# In rescue mode
systemctl start network.service
systemctl default

πŸ”§ Single User Mode

# Traditional single user mode
# Add to kernel parameters:
single

# Or
init=/bin/bash

# After booting
mount -o remount,rw /
passwd root
sync
reboot -f

Kernel Management

πŸ“¦ Installing New Kernels

# Install latest kernel
sudo dnf install kernel

# Install specific kernel version
sudo dnf install kernel-5.14.0-162.el9

# Install kernel development packages
sudo dnf install kernel-devel kernel-headers

# List available kernels
dnf list available kernel

πŸ—‘οΈ Removing Old Kernels

# List installed kernels
rpm -qa kernel

# Remove specific kernel
sudo dnf remove kernel-5.14.0-70.el9

# Keep only 2 latest kernels
sudo dnf install dnf-utils
sudo package-cleanup --oldkernels --count=2

# Configure automatic cleanup
sudo nano /etc/dnf/dnf.conf
# Add: installonly_limit=3

πŸ”„ Kernel Module Management

# List loaded modules
lsmod

# Load module
sudo modprobe module_name

# Remove module
sudo modprobe -r module_name

# Blacklist module
echo "blacklist module_name" | sudo tee /etc/modprobe.d/blacklist.conf

# View module info
modinfo module_name

# Rebuild initramfs after changes
sudo dracut -f

Advanced GRUB Features

πŸ” Password Protection

# Generate password hash
grub2-mkpasswd-pbkdf2

# Add to /etc/grub.d/01_users
cat << 'EOF' | sudo tee /etc/grub.d/01_users
#!/bin/sh
set -e
cat << EOT
set superusers="admin"
password_pbkdf2 admin grub.pbkdf2.sha512.10000.HASH_HERE
EOT
EOF

# Make executable
sudo chmod +x /etc/grub.d/01_users

# Regenerate configuration
sudo grub2-mkconfig -o /boot/grub2/grub.cfg

πŸ”„ Chain Loading

# Chain load another OS
menuentry "Windows 10" {
    insmod part_gpt
    insmod fat
    insmod chain
    set root='hd0,gpt1'
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

πŸ“‘ Network Boot

# Configure PXE boot entry
menuentry "Network Boot" {
    insmod net
    insmod efinet
    insmod tftp
    set net_default_server=192.168.1.100
    linux (tftp)/vmlinuz
    initrd (tftp)/initrd.img
}

Performance Optimization

⚑ Fast Boot Configuration

# Reduce timeout
GRUB_TIMEOUT=1

# Remove unnecessary modules
GRUB_TERMINAL=console

# Disable OS prober
GRUB_DISABLE_OS_PROBER=true

# Skip GRUB menu if only one OS
GRUB_TIMEOUT_STYLE=hidden

# Disable recovery entries
GRUB_DISABLE_RECOVERY=true

πŸš€ Parallel Service Startup

# Check current default target
systemctl get-default

# Optimize service dependencies
systemd-analyze dot | dot -Tsvg > dependencies.svg

# Disable unnecessary services
sudo systemctl disable bluetooth
sudo systemctl disable cups

# Mask services not needed
sudo systemctl mask ModemManager

πŸ“Š Boot Profiling

# Enable boot profiling
sudo systemctl enable systemd-boot-chart

# Generate detailed boot chart
sudo /usr/lib/systemd/systemd-boot-chart -o boot-chart.svg

# Analyze I/O during boot
sudo bootchart -f

Security Hardening

πŸ”’ Secure Boot Configuration

# Check Secure Boot status
mokutil --sb-state

# Import Machine Owner Key
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der

# Verify signed kernels
sudo pesign -S -i /boot/vmlinuz-$(uname -r)

πŸ›‘οΈ Kernel Security Parameters

# Security-focused parameters
GRUB_CMDLINE_LINUX="audit=1 selinux=1 enforcing=1"

# Disable interactive boot
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX systemd.confirm_spawn=false"

# Hide kernel pointers
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX kptr_restrict=2"

# Restrict kernel logs
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX dmesg_restrict=1"

πŸ” Encrypted Boot

# Check for encrypted partitions
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,UUID

# Add LUKS support to GRUB
GRUB_ENABLE_CRYPTODISK=y

# Configure encrypted root
GRUB_CMDLINE_LINUX="rd.luks.uuid=<UUID>"

Best Practices

βœ… Configuration Management

  1. Always backup before changes:
sudo cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.backup
sudo cp /etc/default/grub /etc/default/grub.backup
  1. Test configuration:
sudo grub2-script-check /etc/default/grub
  1. Document changes:
# Add comments in /etc/default/grub
# Changed by: admin
# Date: 2025-08-19
# Reason: Performance optimization

πŸ“‹ Maintenance Checklist

  • Keep at least 2 working kernels
  • Test new kernels before removing old ones
  • Regular backup of /boot partition
  • Monitor /boot partition space
  • Review boot logs periodically
  • Update GRUB after kernel updates
  • Test recovery procedures
  • Document custom configurations

πŸ” Monitoring and Alerting

# Monitor boot partition space
df -h /boot

# Check for boot errors
journalctl -b -p err

# Monitor boot time
systemd-analyze

# Set up alerting for boot issues
cat << 'EOF' > /usr/local/bin/boot-monitor.sh
#!/bin/bash
BOOT_TIME=$(systemd-analyze | awk '{print $4}' | sed 's/s//')
if (( $(echo "$BOOT_TIME > 60" | bc -l) )); then
    echo "Warning: Boot time exceeded 60 seconds: ${BOOT_TIME}s"
    # Send alert (email, notification, etc.)
fi
EOF

chmod +x /usr/local/bin/boot-monitor.sh

Conclusion

Understanding the AlmaLinux boot process and GRUB configuration provides you with powerful tools for system management, troubleshooting, and optimization. From the initial firmware handoff to the final service startup, each stage offers opportunities for customization and improvement.

Key takeaways:

  • 🎯 The boot process follows a predictable sequence that can be debugged systematically
  • πŸ”§ GRUB2 offers extensive customization options for various use cases
  • πŸš€ Performance optimization can significantly reduce boot times
  • πŸ”’ Security hardening at boot level provides defense in depth
  • πŸ›Ÿ Emergency and rescue modes are essential recovery tools

Regular maintenance of your boot configuration, keeping multiple working kernels, and understanding recovery procedures ensure your AlmaLinux systems remain reliable and performant. Whether you’re managing a single workstation or a fleet of servers, mastering the boot process is an essential skill for any Linux administrator.

Remember to always test changes in a non-production environment first, maintain proper backups, and document your configurations for future reference. With this knowledge, you’re well-equipped to handle any boot-related challenges and optimize your AlmaLinux systems for your specific needs.