WIPIVERSE All articles

Chain loading

Chain loading is a method used in computer booting where a boot manager or boot loader (the primary loader) loads and executes a second boot loader (the secondary loader) instead of loading an operating system kernel directly. The secondary loader then proceeds to load the operating system kernel or presents its own menu for further selection.

Mechanism

In a typical chain loading scenario:

  1. The system firmware (BIOS or UEFI) executes the code in the Master Boot Record (MBR) or the EFI System Partition (ESP).
  2. This primary boot loader (e.g., GRUB, Windows Boot Manager, rEFInd) identifies a partition or file containing a secondary boot loader.
  3. The primary loader loads the secondary loader into memory and transfers execution control to it.
  4. The secondary loader (e.g., the Volume Boot Record (VBR) of a specific partition, or a bootloader like NTLDR/BOOTMGR for Windows, or a boot sector for Linux) initializes and loads its associated operating system.

Common Use Cases

  • Multi-boot Systems: Chain loading is the standard mechanism for booting multiple operating systems from different partitions or disks. For example, a Linux bootloader (GRUB) chain loads the Windows Boot Manager to start Windows, or the Windows Boot Manager chain loads GRUB to start Linux.
  • Partition Boot Sectors: On BIOS/MBR systems, the generic MBR code often chain loads the Volume Boot Record (VBR) of the active partition.
  • Bootable Media: Boot managers on USB drives or optical media often chain load the boot sector of an ISO image or a specific partition on a hard drive.

Technical Context

  • BIOS/MBR: Chain loading typically involves loading the first sector (VBR) of a target partition into memory at address 0x7C00 and jumping to it.
  • UEFI: Chain loading involves loading an EFI executable (.efi file) from the ESP or another filesystem driver-supported location using the LoadImage and StartImage boot services.

Advantages

  • Modularity: Each operating system maintains its own boot logic; the primary boot loader does not need to understand the specific kernel loading requirements of every OS.
  • Compatibility: Allows boot loaders designed for specific operating systems (which may have proprietary or complex initialization requirements) to function correctly without modification by a third-party boot manager.
Browse

More topics to explore

    Browse all articles