Re: GRUB Loading Stage2Read Error

From: Enrique Perez-Terron (enrio_at_online.no)
Date: 11/29/05


Date: Tue, 29 Nov 2005 19:47:40 +0100

On Tue, 29 Nov 2005 07:05:08 +0100, alan <misc@alanroter.com> wrote:

> I'm having trouble booting a new install of Fedora Core 4 running on a
> home-built system with an AMD Athlon 64-bit Processor 3000 with 1Gb RAM
> using an Abit NV8-V motherboard and two IDE drives plus DVD, etc. Its a
> pretty standard system.
>
> At boot time, the system reads from the master drive (/dev/hda) and
> gives an error "GRUB Loading stage2Read Error".

Seems alarming, because it looks like it fails during the load of stage2.
The problem I point at below with grub.conf should only affect what happens
after stage2 is loaded.

[...]

> The /boot partition contains the kernel and the /boot/grub directory
> with all of the grub files. The grub.conf file looks like this:
>
> # grub.conf generated by anaconda
> #
> # Note that you do not have to rerun grub after making changes to this
> file
> # NOTICE: You have a /boot partition. This means that
> # all kernel and initrd paths are relative to /boot/, eg.
> # root (hd0,0)
> # kernel /vmlinuz-version ro root=/dev/hda2
> # initrd /initrd-version.img
> #boot=/dev/hda1
> default=1

  ^^^^^^^^^^

Numbering starts at zero. With only one stanza below, there is no default one.

I don't know if this explains the error message you get, but I would try to
put "default=0" and see if it makes a difference.

> timeout=5
> splashimage=(hd0,0)/grub/splash.xpm.gz
> hiddenmenu
> title Fedora Core (2.6.11-1.1369_FC4)
> root (hd0,0)
> kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/ rhgb quiet
> initrd /initrd-2.6.11-1.1369_FC4.img
>
> Again, this all looks quite standard, but the system does not boot up
> and stops at the "GRUB Loading stage2Read Error".
>
> So reading this group and looking for anything related to grub errors
> on the net, I've tried a number of things, still with no success:
>
> 1) I'm booting off the FC4 rescue CD, mounting the hda partitions and
> chroot'ing /mnt/sysimage to get my hda partitions online.
>
> 2) In grub (GNU GRUB 0.95), I've done the following:
>
> sh-3.00# grub
> grub> find /grub/stage2
> find /grub/stage2
> (hd0,0)
> grub> root (hd0,0)
> root (hd0,0)
> Filesystem type is ext2fs, partition type 0x83
> grub> kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/hda2
> kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/hda2
> [Linux-bzImage, setup=0x1e00, size=0x1da85c1
> grub> initrd /initrd-2.6.11-1.1369_FC4.img
> initrd /initrd-2.6.11-1.1369_FC4.img
>
> Error 28: Selected item cannot fit into memory
> grub> boot
> boot
> sh-3.00#

It does not work to boot from grub when grub is running under a kernel.
The only purpose of running grub under Linux, is to issue "setup" commands.
(Which is what grub-install does for you.)

> which bounces me back to the shell prompt without a reboot. I've seen
> some info on the web dating back to RedHat 8.0 in 2002 that suggested
> there was a hardware incompatibility that was causing this. Could this
> still be the case?

The error message is of course silly, but the overall behavior is
perfectly expected.

> The sizes for the kernel and initrd files are 1,951,836 and 1,303,392,
> respectively, so it is not clear that this error message is accurate
> with 1Gb of RAM. I saw a note about limited RAM-disk space on one
> posting, but I don't believe I am using one nor did I understand the
> issue, but it is possible that the rescue CD is setting up a RAM-disk
> and that is memory limited?

No, what happens is that when running under Linux, the program allocates
about 100 000 bytes in order to *simulate* the boot environment. This is
of course not enough to load a kernel and an initrd.

> 3) I've also tried grub-install:
>
> sh-3.00# grub-install --recheck /dev/hda

Looks correct to me.

> Probing devices to guess BIOS drives. This may take a long time.
> Installation finished. No error reported.
> This is the contents of the device map /boot/grub/device.map;.
> check if this is correct or not. If any of the lines is incorrect,
> fix it and re-run the script 'grub-install'.
>
> (fd0) /dev/fd0
> (hd0) /dev/hda
> (hd1) /dev/hdb
>
> sh-3.00# vi /boot/grub/device.map
> [deleted fd0 and hdb lines, saved]

OK, but should not make any difference.

> sh-3.00# grub-install /dev/hda
> Installation finished. No error reported.
> This is the contents of the device map /boot/grub/device.map;.
> check if this is correct or not. If any of the lines is incorrect,
> fix it and re-run the script 'grub-install'.
>
> (hd0) /dev/hda
> sh-3.00#
>
> 4) Finally, I've set the BIOS to boot off the hda drive first. I've
> checked and DMA is enabled. I haven't tried booting from a "grub boot
> floppy" but I think the Fedora rescue CD is allowing me to do something
> similar.
>
>
> After all of the above, I remove the rescue CD and reboot, and the
> machine stops at "GRUB Loading stage2Read Error".

The feeling I have is that something is going wrong during grub-install,
and I wonder if the fact that you are running grub-install under a chroot
environment could trigger a bug in grub.

Grub-install tries to find out if you have a separate /boot partition,
and what partition holds your root file system. For this it uses the "df"
command. "df" uses /etc/mntab, but when running under a chroot, "df" does
not have access to a valid /etc/mtab, and might get confused by that.

Do you have a floppy drive on your computer? No? Argh, when the world for
once goes forward and drops that unreliable beast, then you need it.

(If you can boot off a floppy, copy the files /usr/share/grub/*/stage[12]
to a floppy (obs obs obs don't copy them as files into a fat-formatted
msdos floppy, copy them to a raw floppy block device, eg.

   cd /usr/share/grub/*
   cat stage1 stage2 > /dev/fd0

then boot off the floppy. You get a grub prompt, which permits you to

   Grub> find /grub/stage2
   (hd0,0)/grub/stage2
   Grub> root (hd0,0)
   Grub> setup (hd0)

take out the floppy and any cdrom, and reboot.)

Not having a floppy, try to run grub without chroot.

Check if you have grub-install and grub in your path on the rescue cd

   sh-3.00# type grub
   grub is /sbin/grub
   sh-3.00# type grub-install
   grub is /sbin/grub-install

If you don't have it, add the sysimage directories to the path:

   sh-3.00# PATH="$PATH:/mnt/sysimage/sbin:/mnt/sysimage/bin"

Run grub-install with the --debug option, to see what it ends up
doing. You probably also need to use the --root-dir option since you
are running from a CD.

   sh-3.00# grub-install --debug --root-dir=/mnt/sysimage /dev/hda

You should see it assign values to "grubdir" and to "grub_prefix", and there
should be a call to "install_boot_block (hd0,0) (hd0)".

If this went well, you should now be able to boot your new system.

If not, a last attempt: from the rescue cd, run grub's setup command
directly:

   sh-3.00# grub
   grub> root (hd0,0)
   grub> setup --stage2=/grub/stage2 --prefix=/grub (hd0)
   grub> quit

Again, you should now be able to reboot.

-Enrique



Relevant Pages

  • Re: GRUB Problems with Dell Optiplex GX1
    ... inappropriate boot image when they turn it on... ... It will boot from a floppy, but installing it to ... FreeBSD folks tend not to use Grub, ...
    (freebsd-questions)
  • Re: GRUB Problems with Dell Optiplex GX1
    ... inappropriate boot image when they turn it on... ... It will boot from a floppy, but installing it to ... FreeBSD folks tend not to use Grub, ...
    (freebsd-questions)
  • Re: [SLE] Grub loading Stage2 read error
    ... grub-install to place the contents of menu.lst in the boot sector. ... Apparently, GRUB does *not* look beyond it's principal function, meaning it ... The syntax `' represents using the first partition of the first disk ...
    (SuSE)
  • Re: Naming harddisks (Linux)
    ... But I also see that for an USB drive it uses /dev/sdas the ... Does GRUB recognize SCSI drives? ... The first step in understanding the boot process is to ... The bootloader's job is to load the OSs kernel. ...
    (comp.os.linux.misc)
  • Re: CDRW/DVD how do i watch DVDs in Redhat 9
    ... I use a floppy to boot my linux system. ... OK then edit the syslinux.cfg file on the floppy. ... Grub, my mistake. ... Enabling DMA for these drives makes then faster for playback like ...
    (linux.redhat.misc)