Reputation: 2075
I'm not very clear in some terms regarding a PC's boot.
Terms: Boot block, boot sector, MBR, boot loader vs boot straper, bios vs cmos and their functions.
And how does these relate to the current bootloaders like grub.
I understand boot order and the high level software stuff after booting, but i really am curious about what goes on inside those chips when someone presses the power on button.
Wikipedia seems a bit cryptic so i thought maybe stackoverflow can give me some lucid answers or at least point me to a location where i can find simple explanations.
Help is much appreciated.
Upvotes: 3
Views: 644
Reputation: 1069
Ok.
First thing you need to understand is how a CPU works. There is something called an instruction pointer (IP) register which points to the address that contains the next instruction for the CPU to execute. Every time you start a new program, that program is loaded into memory and then you set CPU's IP to the start address of the program. But what do you do when your CPU is switched off. How do you make the CPU run the "boot" program.
For this there is something called "boot vector", that is the address to which CPU will jump as soon as it is powered on.
But then, who will load the program at the boot vector. Naturally the program can't be pre-loaded in RAM. Because RAM requires power (volatile). So they have something called a "boot flash" which is EEPROM and thus non-volatile. This flash contains a program called "BIOS" whose responsibility is to wake the system from death.The idea is that it has to have minimum and necessary functionality. This boot flash is burned and fixed on the system in such a way that the starting instruction of this program is exactly at the "boot vector" of the CPU.
Now the next task that you require your BIOS to do is to load the operating system. But you might have multiple OS installed on your hard disks. So you first want to load a program which can further load the operating systems. This program is called boot loader (grub is an example of that)
So how do you do that. There is something called as a "boot sector" on each disk. Which is generally the first sector of the disk. It is generally of the size of 512MB or so. Good enough to store a small program. You tell the BIOS which disk (primary, secondary, CD, USB, network)to use for further booting. Most commonly and by default it uses the primary hard disk. So boot loader goes and fetches that program and jumps to it. Boot loader knows how to boot the OS from that point. For example in grub you specify your kernel name etc.
Master Boot Record is another term, which is more of a Windows world terminology. Window's boot loader assumes some kind of a "record" about the nature of OS's installed on the boot sector. It calls that record as MBR.
Hope this is good for you for now.
Upvotes: 9