Master the fundamental concepts of the boot process: theory through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksChainloading means one bootloader loads another without installing its own stage-1 in the MBR. GRUB can hand off to Windows bootmgr, another GRUB on another disk, or a raw sector image. For example, chainloader +1 reads the next sector from the selected partition and jumps to 0x7C00 like the BIOS would.
cLoading…
ntldr or BCD path on Windows volumesGRUB uses insmod part_msdos or part_gpt to find the target, then sets root to that partition before chainloader.
MBR entries at offset 0x1BE hold the starting LBA of each partition; GRUB's root command selects which boot sector gets chainloaded. GPT systems may still use BIOS compatibility images with a protective MBR pointing at the EFI partition. Windows bootmgr expects certain fields in the BPB region to remain intact; overwriting them breaks chainloading even if your own sector is valid.
You will document how GRUB chainloads another bootloader and which partition bytes are executed. This exercise requires explaining register setup, the +1 sector read, and why dual-boot setups rely on this instead of overwriting the Windows MBR code.
chainloader +1 loads the first sector of another partition to 0x7C00 and jumps to it. To choose that partition, a chainloader reads the MBR partition table: four 16-byte entries at offset 0x1BE, followed by the signature 55 AA. Decode it.
Each entry:
| Bytes | Field |
|---|---|
| 0 | boot flag; bit 7 (0x80) marks the active partition |
| 4 | partition type (0x0B/0x0C FAT32, 0x07 NTFS, 0x83 Linux, 0xEE GPT protective, 0x00 empty) |
| 8-11 | first LBA, 32-bit little-endian |
| 12-15 | size in sectors, 32-bit little-endian |
Four lines of 16 hex bytes (the entries), then the two signature bytes.
One line per entry:
P2: EMPTY.P1: TYPE=0x0B BOOT=yes LBA=63 SECTORS=104769 END=104831, where END = LBA + size - 1, left out when the size is 0.Then the signature. If it is not exactly 55 AA, print INVALID SIGNATURE (need 55 AA, got 55 AB) - not chainloadable and stop. Otherwise print SIGNATURE OK (55 AA), then either CHAINLOAD: partition 3 at LBA 2048 -> loaded to 0x7C00 for the first entry with bit 7 set, or NO BOOTABLE PARTITION.