GRUB Legacy

You may write information about GRUB Legacy here.

GRUB Legacy is the old invocation of the GRand Unified Bootloader - no longer under active development. It is a fully-featured bootloader, and has a large user and support community out there.

GRUB 2, is thew new current stable release with many new features.

The maintenance of GRUB Legacy

If you write, or want to write code for GRUB Legacy, you may find the article "Hacking Grub for fun and profit" from Phrack Volume 0x0b, Issue 0x3f useful. Here's link: http://www.phrack.org/archives/63/p63-0x0a_Hacking_Grub.txt

Chainloading a bootable CD from Grub

This is possible by using memdisk from the Sys/Isolinux project and an image of a bootable floppy of the (orphaned) SBM smart boot manager project.

More information can be found here: http://www.lrz.de/~bernhard/grub-chain-cd.html

Creating a bootable floppy

The standard way to create a bootable floppy described in the Grub manual creates a floppy without a file system and no menu. For your convenience, I repeat the steps here:

Put stage1 and stage2 to some place, where you can access them later. Take a floppy and write stage1 immediately followed by stage2 on the first sectors of that floppy:

# dd if=stage1 of=/dev/fd0 bs=512 count=1
# dd if=stage2 of=/dev/fd0 bs=512 seek=1

If you want to have a formatted floppy, i.e. a bootable one with a file system, you can create one by preparing the following floppy (you can use the plain Grub Floppy without a file system and discard it later):

Download the current version of grub (legacy) from ftp://alpha.gnu.org/gnu/grub/grub-0.97-i386-pc.tar.gz (0.97 is the current version of Grub legacy on 3-Dec-2007, but that might change in the future).

Unpack grub-0.97-i386-pc.tar.gz and put ist contents on a formatted floppy (the type of the file system is at your choice, it can be e.g. ext2 or VFAT). This floppy should now contain a directory tree with with several files in /boot/grub/.

Now, you have to boot into a working Grub. One would be the plain Grub floppy mentioned above, two other possibilities which pop up in my mind are:

1. Download a CD-image from Kanotix, burn a CD

2. Caldera installation CD (ooh, now Caldera metamorphed to SCO and they are sueing against linux ..)

other systems also use Grub in their installation. In most cases, when booting from CD or from a Grub installed on a hard disk, you should hit ESC to leave Grub's menu and enter Grub's command line mode.

You also can boot the Grub floppy without file system created as described in the Grub manual or above puts you directly into Grub command line mode.

Now the important step: put in the floppy with grub in a file system (swap flopies if you booted from floppy, i.e. pull out the floppy without the file system and exchange it with the floppy with the FAT file system and grub files on it) and tell grub

root (fd0)
setup (fd0)

now Grub should setup the floppy with the file system correctly.

You can leave the floppy in the PC and reboot for a test or you can tell Grub to load the boot sector from the floppy and boot it interactively

chainload (fd0)+1
boot

GRUB for Linux

Linux Distros

Troubleshooting

Grub hangs at Stage1.5 or Stage2

After bios POST, you see:

Grub loading Stage1.5
Grub loading, please wait...

And then grub hangs up indefinetely. Also, you may see this message followed by a hang up.

Loading stage2 ....

This may happen due to corrupt files in /boot/grub directory. You can use a rescue CD to boot, and then chroot to the root partition with /boot mounted. Move all the files except menu.lst and grub.conf out of /boot/grub. Then run grub-install on the drive. This should repopulate the /boot/grub folder with the appropriate files.

The following example assumes you have your root partition on /dev/hda1, and /boot on /dev/hda2. And grub will be installed on the MBR of /dev/hda.

mount /dev/hda1 /mnt/sysimage
mount /dev/hda2 /mnt/sysimage/boot
chroot /mnt/sysimage
mv /boot/grub /boot/grub.old
mkdir /boot/grub
cp /boot/grub/menu.lst /boot/grub
cp /boot/grub/grub.conf /boot/grub
grub-install /dev/hda

Eltorito bootable CD drops into GRUB shell

If you followed the GrubBootableCDHowto, you may find your CD always booting into the grub shell. The right behaviour should be to drop into the menu if you specify one in menu.lst.

The problem might be from the way distributions changed their grub releases. Some like Fedora for instance, use grub.conf instead of menu.lst as the place to look for menu. Hence, you should put a grub.conf in the /boot/grub directory instead of menu.lst as described in the HOWTO.

Note: Symlinking grub.conf to menu.lst won't help, as GRUB doesn't understand symlinks on ISO9660 (CD filesystem).


Notes on robust booting

I wrote this quite awhile ago, hope it is still accurate. There seems to be some confusion around the the fact that some versions of the grub shell give an error like this:

grub> savedefault
Error 27: Unrecognized command

This shouldn't be taken literally, it could mean that it's just not recognized in this context. However other builds of grub do accept it here. Ether way, most recent versions will accept it in the menu file (usually /boot/grub/menu.lst). Though it seems savedefault is disabled in grubs built with the --enable-diskless option.

Note that you *Must* first initialize the /boot/grub/default file with the command:

grub-set-default 0

This is because grub has no code for updating the filesystem directories, it just changes a few bytes in a sector of an existing file.

One could add some lines to /etc/rc.local to run grub-set-default after about 10 minutes to set the next reboot to the current image. If something goes wrong you can remotely power cycle the server before then and it will go on to try the next fallback entry. We could pass an enviorment varable on the kerel command line and it would be visable in the start up scripts. eg, GRUB=2. You can also view the kenel argument list like so:

cat /proc/cmdline

Fallback doesn't require savedefault to work but it extends it's scope accross reboots.


CategoryObsolete

GrubWiki: GrubLegacy (last edited 2010-02-06 18:36:10 by FelixZielcke)