The disk space can be used in a boot loader is very restricted because a MBR (see section The structure of Master Boot Record) is only 512 bytes but it also contains a partition table (see section The format of partition table) and a BPB. So the question is how to make a boot loader code enough small to be fit in a MBR.
However, GRUB is a very large program, so we break GRUB into 2 (or 3) distinct components, stage1 and stage2 (and optionally stage1.5). See section The memory map of various components, for more information.
We embed stage1 in a MBR or in the boot sector of a partition , and place stage2 in a filesystem. The optional stage1.5 can be installed in a filesystem, in the boot loader area in a FFS, and in the sectors right after a MBR, because stage1.5 is enough small and the sectors right after a MBR is normally an unused region. The size of this region is the number of sectors per head minus 1.
Thus, all the stage1 must do is just load a stage2 or stage1.5. But even if stage1 needs not to support the user interface or the filesystem interface, it is impossible to make stage1 less than 400 bytes, because GRUB should support both the CHS mode and the LBA mode (see section INT 13H disk I/O interrupts).
The solution used by GRUB is that stage1 loads only the first sector of a stage2 (or a stage1.5) and stage2 itself loads the rest. The flow of stage1 is:
The flow of stage2 (and stage1.5) is:
Note that stage2 (or stage1.5) does not probe the geometry or the accessing mode of the loading drive, since stage1 has already probed them.
Go to the first, previous, next, last section, table of contents.