...making Linux just a little more fun!

<-- prev | next -->

GRUB boot diskette for Knoppix

By Anonymous

GRUB cannot boot the Knoppix CD if booting from the CD-ROM is disabled. This is a feature that the GRUB developers should consider adding. See my previous article in the October 2004 Linux Gazette.

However, GRUB (current version 0.95) can generate a floppy to boot Knoppix after a full install to hard disk - something LILO may have problems with, due to its inability to find files, and due to the kernel and initial RAMdisk growing past diskette size.

Assume Knoppix is installed to hard disk but that its partition is not bootable, for whatever reason. You need a floppy to boot Knoppix, and here is how to make it with GRUB:

General case: disk visible to BIOS

You can use a simple GRUB diskette that boots to a GRUB command line. From this command line, you can issue commands to boot your Knoppix on the non-bootable partition.

This simple GRUB boot diskette can be prepared with the grub-floppy script. It is very quick to prepare, but does not carry a filesystem, so you cannot do much with it. You cannot write to it, and you will have to type quite a bit after booting to the GRUB prompt.

A more comfortable solution is given by the script grub-install, which requires a formatted diskette. A DOS-formatted diskette will do, and you will be able to modify it from DOS - quite an advantage. Mount the diskette, e.g., to /floppy, and issue the command:

grub-install --root-directory=/floppy fd0

The script will create /floppy/boot/grub and copy to it the image files required for booting. Some of them can be deleted, since you do not need support for half a dozen filesystems.

Now, the best part of it is that you can write to /floppy/boot/grub a text file by the name of menu.lst, which is the configuration file for GRUB. Here, you put all the instructions you want for booting your Knoppix, and that's it. (The endline sequence may be DOS-style or Linux-style.) It boots fairly quickly - or rather, it boots very quickly if you reduce the timeout to 1 sec and suppress the menu.

Abnormal case: disk not visible to BIOS

Let us now get around to a conjurer trick that looks a bit puzzling.

The hard disk where Knoppix is installed is not visible to the BIOS. Why not? Because the disk is explicitly set to 'none' in the BIOS, for some peculiar reason. Or because the old BIOS cannot see partitions past 8GB.

Wonder: Linux can boot, see the disk even though it is invisible to the BIOS, and plant its root on it.

The preparation of the GRUB diskettes for the trick goes actually the same way as before, but some additional fiddling is required.

Let us focus on the case where a DOS-formatted boot diskette has been prepared with grub-install.

First, you copy your Linux kernel (name it vmlinuz) to a hard disk visible to the BIOS, e.g., the first hard disk, first partition, which GRUB call (hd0,0).

Second, you must guess the proper Linux designation for the Knoppix partition, when Linux is running. Remember that Linux calls the SCSI disks /dev/sda, dev/sdb, etc., and the IDE disks /dev/hda, /dev/hdb, etc. The partitions are then appended to them as numbers, e.g., /dev/hda1, /dev/hda2, etc. It can get complex, depending on the devices you have in your PC. In any event, you must find the proper designation for the Knoppix partition, since it is invisible to the BIOS and GRUB. Assume for the sake of an example that the correct Linux designation is /dev/hdb1.

Now, write menu.lst to the floppy, directory /boot/grub, as follows:

# start of menu.lst
# GRUB boot for Knoppix 3.6/kernel 2.6.7
# Knoppix is installed to hdb1
# hdb1 is not bootable, indeed not seen by BIOS

# By default, boot the first entry
default 0

# Boot after 1 second, no menu
timeout 1

# first and unique entry
title knoppix36267
kernel (hd0,0)/vmlinuz root=/dev/hdb1

# Should an initial RAMdisk be required,
# the last line would be, for instance:
# kernel (hd0,0)/vmlinuz root=/dev/hdb1 initrd=/initrd/ird.gz
# end of menu.lst

We are not finished yet. GRUB has on the floppy an auto-generated file device.map, listing all devices known to it. In this abnormal case, it is a good idea to check the map file; it may need revision by hand. Indeed, it must include that device unknown to the BIOS but destined to carry the root. Note that the map file is simply a translation between GRUB device names and Linux device names.

That's it. Boot the GRUB diskette and it will pull vmlinuz from your first hard disk: vmlinuz will run and will recognize and use the partition /dev/hdb1 even though /dev/hdb is unknown to the BIOS.

Can anyone explain it? If the kernel can see partitions invisible to the BIOS, why can't GRUB? GRUB has in the boot sector a tiny program called stage1 that does nothing but trigger stage2. Since stage2 is more than 100K, shouldn't it be able to detect available devices the same way the kernel does?


Copyright © 2004, Anonymous. Released under the Open Publication license unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 108 of Linux Gazette, November 2004

<-- prev | next -->