The short answer is it doesn't.
The long answer is Grub can find it out.
The major difference betwee a MS system boot loader (no name
) and the Linux boot loaders (Grub or Lilo) is the former has no target to boot
.
MS system MBR is like a blind person
searching a OS for booting. It does so by examining each of the 4 primary partitions in the bootable hard disk to see if any one has the boot flag switched on and proceed to boot it when the first one is found. In all partitioning programs of MS and Linux systems when a primary partition boot flag is switched on the other one will be automatically switched off and so there can never be more than one active primary partition.
Linux's Grub and Lilo do not use the boot flag at all. The partition to be booted in "always" declared up front. In Grub it is by
in Lilo it is by
As Grub counts from 0 and so hdb3, being the 3rd partition of the 2nd hard disk will be known as (hd1,2) in Grub. This "declare the boot partition first" feature is the key to why Linux can boot from either primary or logical partition while a "standard" MS system can only cope with the former.
Ulike Grub which refers to all bootable partitions by the same root statement Lilo uses
for non-Linux partitions or any partition that it has to boot by chainloading (A Lilo can chainload a fellow Linux too)
Grub is slightly more powerful than Lilo in that it can operate without an OS attached to and acts as a mini OS in its own right. Grub has a rich set of commands, available at any Grub prompt (when booted without a OS) or at a Grub shell (after booted to a Linux) that can interrogate the hard disks, display any of the text files (like /boot/grub/menu.lst or /etc/lilo.conf) and restore the boot loader.
In a Grub prompt if any of the partitions, say (hd2,10) has a boot loader inside it can be booted up by Grub manually by these lines
Code:
root (hd2,10)
chainloader +1
boot
Therefore Linux boot loader Grub can find out any bootable partition just by trial and error.
Think I may have given away a Howto to hack any PC.