- MBR
- the first 512 bytes of a disk
- After BIOS, it jumps to MBR
- also holding the partition table
- A partition can be marked bootable (active). It is used by boot loaders from old days to determine which partition to boot. Not used by grub.
- PBR (partition boot sector)
- the first 512 bytes of a partition
- boot loaders can also be installed to PBR, suppose the one installed to MBR knows PBR
- grub
grub-install
is a program to install grub to the disk- it detects the target automatically
- if the current system uses UEFI,
x86_64-efi
ori386-efi
- otherwise,
i386-pc
--target
to override
- if the current system uses UEFI,
- it defaults the boot dir to
/boot
- grub dir to
/boot/grub
--boot-directory
to override- it copies some binaries to
/boot/grub
- grub dir to
grub_install_make_image_wrap
generates and copies the core image- if UEFI
grub_install_register_efi
updates nvram to add the boot entry
- if BIOS
grub_util_bios_setup
installs the boot image to the boot sector- whether boot.img is installed in MBR or PBR, it loads another fixed sector which holds the first 512 bytes of core.img. It then jumps to it and loads the rest of core.img
- core.img has the ability to load modules and use filesystems
- if BIOS with GPT disk, grub requires a BIOS boot partition
- grub-install writes core image to the partition
- it is not ESP