LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How does the IPL know to load Stage1_5? (https://www.linuxquestions.org/questions/linux-general-1/how-does-the-ipl-know-to-load-stage1_5-a-779029/)

derrickr 12-31-2009 03:11 AM

How does the IPL know to load Stage1_5?
 
I’ve been searching high & low, but cannot find a definitive answer as to how GRUB Stage_1 (IPL of MBR) knows how to load Stage1_5.

I’ve read the GNU Grub manual and various other forums but since I don’t know C, I can’t reverse engineer or figure out the source code to determine whether Stage1_5 is loaded or not.

I understand that, as part of the OS install procedure, GRUB writes Stage_1 (as the IPL) into the MBR, and that this then calls either Stage1_5 or Stage_2, depending on whether Stage1_5 is installed.

I also believe that Stage1_5 is usually installed into the sectors following the MBR into the so-called DOS compatibility region (the next 62 sectors within the first cylinder before the first partition).

However, assuming Stage1_5 is installed, is there a routine within Stage_1 that checks to see if Stage1_5 is installed and if so jumps & runs to it?

Or, if Stage1_5 is not installed would the same routine then jump to & run Stage_2?

Or, does the GRUB installer intelligently install specific Stage_1 code dependent upon whether Stage1_5 was installed or not? i.e. If the GRUB installer was able to load Stage1_5 then the Stage_1 code it installs would have the routine to jump to & run Stage1_5. Or, if the GRUB installer did not install Stage1_5, it would install different Stage_1 code to jump to & run Stage_2

I appreciate this may be moot, what with GRUB 2 but I’d like to have a better understanding of this process.

TIA – Derrick

syg00 12-31-2009 04:11 AM

Quote:

Originally Posted by derrickr (Post 3809696)
Or, does the GRUB installer intelligently install specific Stage_1 code dependent upon whether Stage1_5 was installed or not? i.e. If the GRUB installer was able to load Stage1_5 then the Stage_1 code it installs would have the routine to jump to & run Stage1_5. Or, if the GRUB installer did not install Stage1_5, it would install different Stage_1 code to jump to & run Stage_2

This is my understanding. The stage1 code simply (always) jumps out - whether to stage 1.5 or 2 it neither knows nor cares. It is simply a sector number that the install procedure writes into the stage1 code as it's written into the MBR or (partition) boot sector.

ernie 12-31-2009 07:57 AM

The GRUB installer writes the jump instruction in the stage 1 code, directing the CPU where to pick up the next set of instructions. The installer keeps track of if stage 1_5 is installed, and writes the jump instruction to point to it if it is installed. If stage1_5 is mot installed, the installer sets the jump instruction to point to the first instruction in stage_2. If anything changes (e.g.: a GRUB update) that may relocate or eliminate stage 1_5, or relocate stage _2, the boot loader in the MBR is rewritten with a new jump instruction.

HTH,

derrickr 12-31-2009 08:11 AM

Understood.

I had a feeling that might be the case, but needed positive confirmation instead of my (hopefully) 'educated guesses'!

Thanks guys :)


All times are GMT -5. The time now is 05:52 PM.