[nSLUG] kernel setup stack overlaps lilo

Peter Cordes peter at cordes.ca
Sun Mar 14 23:36:33 AST 2004


On Sat, Mar 13, 2004 at 07:48:26AM -0400, Donald Teed wrote:
> On Sat, 13 Mar 2004 bdavidso at supercity.ns.ca wrote:
> > I really need to read the
> > documentation on it and overcome my inertia and start using it.

 The docs don't do a very good job of explaining what you need to know to
understand how things work.  They tell you how to do things, but not why you
need to do them or what's actually going on, IIRC.  My mental model of GRUB
is:

There's a 512 byte "stage 1" program in the master boot record, that the
BIOS boots directly.
 There's a ~8kB "stage 1.5" piece of code that groks ext2/3, and it is at the
beginning of my ext3 partition.  Apparently partitions and/or filesystems
leave some space at the beginning for bootable code, which is why you can
use lilo with boot=/dev/hda3, for example.  Apparently it's big enough to
hold code that groks a filesystem.  There's a different stage 1.5 for every
filesystem, e.g. reiserfs.  There are copies of them in /boot/grub.  The
stage1 somehow knows where to find the stage1.5, and loads it. 
 The stage 1.5 code can get files by name from filesystems, and it loads the
stage2 bootloader.  I don't know how it knows where to look for the stage2,
but there are options in grub-install for defaulting to looking on the boot
drive, which it finds out from the BIOS at boot time, so you can move your HD.
 The ~100kB stage2 is the full thing.  It reads the config file, carries out
the commands in it, and displays a menu of boot options.  Depending on the
menu option you choose, or the commands you type, it will load the
appropriate files into memory and call it.  It can also chainload other
partitions (for dos/windows, or if you have LILO installed on a partition).

 The grub-install shell script installs the stage1 and stage1.5 into the
right places, and copies the stage2 (and other stuff) into /boot/grub.  You
have to edit menu.lst yourself.  Here's a simple one:

timeout 4

default 0
fallback 1

# I don't use root (hd0,0) or anything because it defaults to the drive you
# booted from.  With RAID1, I can boot from either drive (last I checked :)

title Linux
kernel /boot/vmlinuz hdb=scsi hdd=scsi root=/dev/md0 acpi=force
title Linux (2.4.21-ck3)
kernel /boot/vmlinuz-2.4.21-ck3-llama hdb=scsi hdd=scsi root=/dev/md0

title memtest86+
kernel /boot/memtest86+.bin
title Boot floppy
root (fd0)
chainloader +1

 You can specify a path like (hd0,2)/src/linux/arch/i386/boot/bzImage
if you have /usr mounted on hda3 (note that GRUB numbers from 0).

 If you have GRUB compiled with ethernet support, the command language
includes DHCP and ifconfig commands, and you can use tftp paths.  Debian's
GRUB package doesn't have net support, though.

> But on the other hand, if this is your first time building the kernel,
> then a grub run would be needed.

 Not if GRUB was already installed.  When you install a new kernel, you edit
/boot/grub/menu.lst.  GRUB's bootloader reads the config file at runtime.
/sbin/lilo embeds the data from lilo.conf, and the on-disk locations of all
the files (kernel images and initrds) into the bootloader.  (Actually, it
puts stuff into /boot/map and gives the bootloader the disk location of that
file.)

-- 
#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter at cor , des.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC



More information about the nSLUG mailing list