All about booting
This post gives an overview of the booting process. It is not about how to setup booting linux. I’ll indicate what I do for that in a future post.
IBM prefers to use the term IPL, which is short for Initial Program Load. And that well describes what booting is. It is the procedure for loading some software into memory for execution. There’s an obvious problem. You need to have a running program to do anything, such as loading a program. So special provisions have to be made for booting.
Typically, the computer manufacturer provides a way of loading some small amount of code. In the IBM 360 series of mainframes, the hardware had a special provision for loading 24 bytes. The general idea is that you start by loading a small amount using what the manufacturer made available. Then you use that small amount that was loaded to in turn load some more software. After a few steps of this type, hopefully you can have the whole operating system loaded and running.
People sometimes talk about “pulling yourself up by the bootstraps.” We all know that isn’t actually possible. But it seems a good, if imperfect, analogy to the way that the operating system is loaded. And that’s where the term “booting” came from. People initially called it “bootstrapping” and this was eventually shortened to “booting.”
With most modern computers, the system comes with ROM (read only memory) containing some programs. In a typical PC, this is referred to as the BIOS. When you first power on the computer, code in that ROM does POST (Power On System Testing) and then loads the operating system if one is found.
We normally divide a disk drive into sections. Those are called “partition” or, with some systems they are called “slices”. An operating system is installed on one of the partitions. For a multi-boot system, several operating systems can be installed on separate partitions.
There is typically some space reserved near the beginning of a partition or slice for boot code. In some computers, the code written to that space is called the boot block. In a typical PC, that reserved space is just a single disk sector (usually 512 bytes), sometimes called the PBR or Partition Boot Record.
Once that initial code has been loaded, the ROM passes control to that code. That initial boot code must complete loading the operating system, often in several stages. Reading a disk drive is a bit complex. So the boot code normally uses subroutines that are in the ROM for handling that reading. This is why there can be limitations in system booting. The full capabilities of reading the disk are not available until the operating system has been loaded and is running. Until that time, whatever limitations are present in ROM disk subroutines will affect how booting is done.
In a typical PC, the ROM boot code loads the MBR (main boot record, the first sector of the disk) into memory and passes control to that. It is up to code in the MBR to examine the partition table, decide which partition to boot, load the PBR (partition boot record) into memory and pass control to that. Then the code in the PBR loads the operating system loader (usually part of grub for linux), and allows that operating system loader to complete the loading and starting of the operating system.