Page List

Wednesday, June 12, 2024

CBT Nugget: Linux Server Administration - 5. Boot Modules and Files

5. Boot Modules and Files in GRUB and GRUB2

Both GRUB (Legacy GRUB) and GRUB2 use a variety of files and modules to manage the boot process. Understanding these components helps in configuring, customizing, and troubleshooting the bootloader.

GRUB (Legacy GRUB)

1. Bootloader Files:

  • Stage 1: This small initial boot code is typically installed in the Master Boot Record (MBR) or the boot sector of a partition. Its primary job is to load Stage 1.5 or Stage 2.
    • Location: Usually in the MBR.
  • Stage 1.5: This stage is located in the space between the MBR and the first partition. It contains filesystem drivers that enable Stage 2 to be loaded from various filesystems.
    • Location: In the sectors immediately following the MBR.
  • Stage 2: This stage is responsible for presenting the boot menu and loading the operating system kernel.
    • Location: /boot/grub/ directory (e.g., /boot/grub/stage2).

2. Configuration Files:

  • menu.lst or grub.conf: The main configuration file containing boot menu entries and settings.
    • Location: /boot/grub/menu.lst or /boot/grub/grub.conf.

3. Kernel and Initrd Files:

  • Kernel: The Linux kernel to be booted.
    • Location: /boot/vmlinuz
  • Initrd: The initial RAM disk, used to preload necessary drivers before the actual root filesystem is mounted.
    • Location: /boot/initrd.img or /boot/initrd.

GRUB2

1. Bootloader Files:

  • Core Image (core.img): This is the main part of GRUB2 that is loaded by the initial boot code. It includes basic modules and can load additional modules from the filesystem.
    • Location: Installed in the MBR or EFI partition, usually generated during the grub-install process.
  • Modules: GRUB2 is highly modular, with many modules to support different filesystems, devices, and functionalities.
    • Location: /boot/grub/i386-pc/ or architecture-specific directories like /boot/grub/x86_64-efi/.

2. Configuration Files:

  • grub.cfg: The main configuration file, which is automatically generated by scripts and contains all the boot menu entries and settings.
    • Location: /boot/grub/grub.cfg.
  • /etc/default/grub: Contains user-defined settings that affect the generation of grub.cfg.
  • /etc/grub.d/: A directory containing scripts used to generate grub.cfg.
    • Scripts such as 10_linux, 20_linux_xen, 30_os-prober, etc., are found here.

3. Kernel and Initrd Files:

  • Kernel: The Linux kernel to be booted.
    • Location: /boot/vmlinuz-*
  • Initrd: The initial RAM disk, used to preload necessary drivers before the actual root filesystem is mounted.
    • Location: /boot/initrd.img-*

Key Modules in GRUB2

GRUB2's modular design includes many modules, each providing specific functionalities. Some of the key modules include:

  • fs (Filesystem) Modules:
    • ext2, ext4, xfs, btrfs, etc.: Support for various filesystems.
  • crypto (Cryptography) Modules:
    • cryptodisk, luks, pbkdf2: Support for encrypted disks.
  • terminal Modules:
    • console, serial, gfxterm: Support for different terminal types.
  • disk Modules:
    • ahci, usb, scsi: Support for different disk types.
  • network Modules:
    • tftp, http, net: Support for network booting and protocols.

Example Configurations

GRUB2 Configuration Example (/etc/default/grub):

plaintext
GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX=""

Generating grub.cfg:

sh
sudo update-grub

Summary

Understanding the boot modules and file locations for GRUB and GRUB2 is crucial for configuring and managing the boot process. GRUB2's modular architecture and modern design provide greater flexibility and functionality compared to Legacy GRUB. The core components include bootloader stages, configuration files, and kernel/initrd files, with GRUB2 also incorporating a range of modules to support various filesystems, devices, and features.

פוסט מוצג

CBT Nugget: Linux Server Administration - 13.Identifying Red Hat and CentOS Network Configuration Files

13.Identifying Red Hat and CentOS Network Configuration Files In Red Hat Enterprise Linux (RHEL) and CentOS, network configuration is manag...