Rescure - Debian LILO failure after upgraded to 3.1

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Jun 21 19:03:30 UTC 2005


On Tue, Jun 21, 2005 at 02:03:08PM -0400, John Vetterli wrote:
> I'm curious; how does grub do it?

When you install grub, it places a stage1 in the MBR or partition boot
sector you point it at, and adds a stage 1.5 loader into whatever part
of the fileystem has space reserved for boot loader code (as far as I
understand it, at least the file goes in /boot/grub/stagewhatever in
many cases) and the stage1 is modified to point at the right location to
read the stage1.5/stage2 code.  Once it has read that code (which is
never changed really, unless you rerun the grub installer command), it
has the ability to read the filesystem directly, and does everything
else by filename, such as reading the current /boot/grub/menu.lst and
/boot/kernel... and whatever.  Since it reads the config and kernels at
runtime using the filesystem, it doesn't have to update any map files
everytime a kernel or config changes.  It only has to map the location
of the stage1.5/stage2 code which is done at install time.  Upgrading
the grub package on your system doesn't touch /boot/grub/stage* unlike
lilo which does upgrade /boot/*.b causing the map file to invalid and
hence require lilo be run again to update the map of blocks for the boot
loader code.  If the lilo command copied the *.b files to /boot and then
mapped them, then it wouldn't break on upgrades, only when you change
the kernel files and other files it has a map pointing too.

So the key is to have filesystem reading code rather than a block map.
Of course this means lilo can run on any filesystem linux can give it
block numbers for (and which doesn't tailpack or other weird half block
usage schemes), while grub only works on filesystems it understands
natively, which fortunately is quite a few by now.

To make a nice grub boot disk you can do this:
cat /boot/grub/stage[12] > /dev/fd0
with a formatted floppy in the drive.  That will then boot to a grub
prompt where you can do things like:

root (hd0,0)                        # pick first partition of first
                                      hd found
kernel /boot/vmlinuz-2.6.8-2-686 root=/dev/hda1 single
                                    # Pick kernel file and set arguments
                                      for kernel to use, like single
				      user and root filesystem to use
initrd /boot/initrd.img-2.6.8-2-686 # set initrd file to use
boot                                # boot system with the current options

or

rootnoverify (hd0,0)
chainloader +1
boot

To boot from the boot sector of whatever is on the first partition of
the first hd without trying to even read the filesystem (in case of
unsupported ntfs versions, hpfs and other such things).

Lennart Sorensen
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list