Writing an OS Kernel from Scratch | Windows Boot Manager vs GRUB: A Complete Analysis of Two Boot Loaders

From 360 to 362, we covered the BIOS/UEFI → MBR/GPT → GRUB boot chain. GRUB is the standard bootloader for Linux, but Windows uses a completely different system — BOOTMGR (Boot Manager) and BCD (Boot Configuration Data).

Have you ever wondered about these questions:

  • What exactly is inside Windows’ “System Reserved” partition?
  • Why does reinstalling Windows overwrite GRUB, but the reverse doesn’t happen?
  • What does the bcdedit command actually modify?
  • Why can Windows 10/11 boot from a VHD file without needing a virtual disk?
  • What’s the difference between GRUB 1 and GRUB 2? Why are some systems still using GRUB 1?

Today, we’ll deeply dissect these two boot loaders — Windows’ BOOTMGR + BCD, and the evolution history of GRUB’s Stage 1/Stage 2.


Windows Boot Loader: The Complete BOOTMGR Chain

Three Firmware Modes, Three Boot Chains

Windows’ boot chain is determined by the firmware type:

Bash
Legacy BIOS + MBR:
  POST → MBR(0x7C00) → BOOTMGR(C:BootBOOTMGR) → {BCD in C:}

UEFI + GPT (Most Common):
  POST → UEFI → NVRAM BootOrder → EFIMicrosoftBootootmgfw.efi
  → BCD(C:BootBCD) → winload.efi → ntoskrnl.exe

Legacy BIOS + GPT (Rare):
  POST → MBR(Protective) → BIOS Boot Partition (GRUB/BOOTMGR coexist)
  → BOOTMGR → BCD

We’ll focus on the most common UEFI + GPT chain.

What Is BOOTMGR

BOOTMGR is Windows’ Boot Manager, a 32-bit compressed executable (with NTFS compression enabled). Its responsibilities are:

  1. Read the BCD (Boot Configuration Data)
  2. Display the boot menu (if there are multiple boot entries)
  3. Load the Windows boot loader (winload.exe / winload.efi)

Bash
BOOTMGR File Location (UEFI mode):
C:EFIMicrosoftBootootmgfw.efi

BCD File Location:
C:BootBCD        (under ESP root's Boot directory in UEFI mode)

BOOTMGR Dependent System Files:
C:WindowsSystem32winload.efi   ← The actual Windows kernel loader
C:WindowsSystem32
toskrnl.exe  ← The Windows kernel itself

System Reserved Partition

When installing Windows on an MBR disk, Windows automatically creates a 100MB System Reserved partition (also called the “system partition”). This partition contains:

Bash
System Reserved Partition Contents:
├── Boot                          ← Boot folder
│   ├── BCD                        ← Boot Configuration Data
│   ├── BOOTMGR                    ← Windows Boot Manager
│   ├── fonts                     ← Boot fonts (Chinese, etc.)
│   └── Resources                ← Boot animation resources
└── System Volume Information     ← Locked metadata directory

Purpose: Even if Windows’ C: drive is damaged or reformatted, the BOOTMGR + BCD in the System Reserved partition remain intact, allowing the boot repair environment (WinRE) to start. This is also why Windows 10/11 installation defaults to checking “Create a system partition for Windows” — it’s not wasted space… [truncated]

Last modified: 2024年2月18日

Author

Comments

Write a Reply or Comment

Your email address will not be published.