GRUB discussion -- virgin disks ?

William Case billlinux at rogers.com
Mon Oct 22 06:19:22 UTC 2007


Hi Jacques;

On Sun, 2007-10-21 at 22:05 -0400, Jacques B. wrote: 
> On 10/21/07, William Case <billlinux at rogers.com> wrote:
> > Hi Jacques et al;
[snip] 
> > If you are interested; a detailed bit by bit explanation:
> > "MBR"
> > http://www.ata-atapi.com/hiwmbr.htm
> >
> > "Part Table"
> > http://www.ata-atapi.com/hiwtab.htm
> >
> > Originally suggested by Mike Wright.
> >
> > I have an additional 10 - 20 pahttp://www.mbrwizard.com/ges cut and pasted as explanations; from
> > poweron to init.  I would be glad to share it in its raw form; or send
> > you what I've got after I have cleaned it up into something readable.
> 
> If you want to either send me the raw data, or better yet the URL
> where you got the data from so if I use it I can quote the source that
> would be great.
[snip] 
http://en.wikipedia.org/wiki/Power-on_reset

<hlhowell at pacbell.net>  From a personal response from a Fedora list
question about processes from power on to boot.  Les was the most
detailed source available.

<hlhowell at pacbell.net>  Another response from another question.

http://www.computer-dictionary-online.org/index.asp?q=bootstrap%20loader

Marko Vojinovic
Institute of Physics
University of Belgrade    A personal response quoting at length from a
text he had.  Best overall detailed description about booting.

http://linuxhelp.blogspot.com/2005/11/how-to-repair-corrupt-mbr-and-boot.html
http://www.pixelbeat.org/docs/disk/
http://www.mbrwizard.com/
http://en.wikipedia.org/wiki/Mbr Several good references at the bottom.
http://www.gnu.org/software/grub/manual/

I have lots more from individuals and text books I have here at home.

Give me a couple of days and I will meld it all together as a write up
(with citations).

N.B. While answering your post I realized that John Summerfield's answer
really just begs the question.

"grub and lilo (re)write the boot code when installed. Windows XP also 
has the ability to write its boot code after partitioning, and if 
suitably desperate I'd find out how again:-)"

Grub and lilo have to get the disk's basic configuration information
from somewhere before they (re-)write the MBR, unless Grub has some
magical little program that tests for virgin disks and then stores their
addresses. The data can't be in the Linux kernel or device
directory/file.  Linux doesn't exist yet.  

Is this kind of data stored in some kind of ROM along with the device
name/number that comes with the disk? If GRUB is going to write hd0,0 to
the MBR, and use hd0,0, it has to know in machine terms (binaries) what
hd0,0 means.  It has to know when it is installed that for certain there
is a hard disk, how to reach it, that it is the first in priority, and
that there is a partition on which to write /boot.  Certainly I can
change the info or add info, but it has to start somewhere.  Either the
initial data is loaded somewhere, somehow in the disk factory or is
added somewhere or somehow by a program.

I keep thinking.  When I last installed a new drive, I plugged
everything in and closed the box.  From my old but still installed disk
I ran 'parted' to partition my new disk and install the ext3
format/filesystem.  Parted knew about the existence of the disk, knew
there was no partitions yet, knew the size, etc.  If I had installed
Fedora from scratch on my new disk, anaconda would have found the disk
and fed me options through the anaconda gui, and then asked me where to
place GRUB.  

GRUB is a generic program.  GRUB does not know ahead of time how many
disks I have or where they are located.  My writing "hd0,0" into the
grub.conf file doesn't do it.  "hd0,0" has to be made to mean something
in binary.  GRUB has to read something about the disk to get started.
Even if no MBR yet exists or has no data, GRUB has to have an address to
issue an opcode that tells the cpu where and which disk to use.  Since
the kernel does not exist yet in memory, is the address and other basic
data in the BIOS?  If it is in BIOS, how does BIOS get it?  I know BIOS
can store the existence and location of devices in its flash memory.  If
that is the source of the initial disk data, is it read off of a disk
ROM? Is that where GRUB gets its initial data? Is there a protocol or
standard for that data so that they are the same for every disk?  And
every BIOS? If so what is that standard?  Where do I find it.

I know when I install a new disk, I have to tell my BIOS menu that it
now exists and that it is a Master or Slave etc.  BIOS returns to me in
its menu, the Manufacturer and Model number, size, sectors etc. of the
disk so that has to be in ROM somewhere, or read by BIOS code from
somewhere on the disk at startup.

I still believe answering that question is the key to understanding how
GRUB works.  There is something in my understanding of the total process
that is missing.  I can't find it and I am getting no more hints where
to look next.

-- 
Regards Bill




More information about the users mailing list