next up previous contents
Next: Creating a CD-ROM Up: Making Linux Installation Disks Previous: Building a Kernel   Contents

Subsections

Making a Bootable Diskette

We will use GRUB and the initial RAM disk, even though they may not be the optimum solution in all cases. Our choices were motivated as follows:

Compiling GRUB

The current version of GRUB does not compile without patching the source, at least not with the gcc-3.3 that came with Suse Linux 8.2.

First configure as follows:

./configure --disable-xfs --disable-reiserfs --disable-jfs \
            --disable-vstafs --disable-minix --disable-ffs
This will get some of the bloat out.

Next edit the file stage2/fsys_reiserfs (I know this file isn't even linked in) and remove the word `long' from line 115, it should read:

   __u32 j_mount_id;
This seems to be a real bug in the source code, but now we can simply make at last.

Getting 0.93 to compile is even more troublesome. The linker keeps complaining about missing memcpy Apart from the reiserfs bug, you have to edit the file stage2/Makefile. Find the line with STAGE2_CFLAGS and change it to:

STAGE2_CFLAGS = -Os -minline-all-stringops
But apply this fix only if your C compiler complains, earlier versions probably don't. If you apply the fix, do make clean first. Hopefully these bugs will be fixed very soon.

Creating the RAM Disk Image

Create a directory mnt below $MYBOOT. This directory is used as a temporary mount point, independent of mount points present in your Linux distribution.

Then run the following commands (put them in a shell script):

cd $MYBOOT
dd if=/dev/zero of=initrd.img bs=1k count=2000
mke2fs -F -N 300 initrd.img
mount -o loop initrd.img mnt
cp -a rootfs/* mnt
umount initrd.img
gzip -9 initrd.img

Now the contents of the root file system are contained in the compressed image file initrd.img.gz. This can be mounted as an initial RAM disk.

Creating the Boot Diskettes

The combined size of the kernel and the initial RAM disk are larger than a single diskette, so we have to make two diskettes. A third diskette will be needed to store the modules.tar.gz file.

The first diskette is the trickiest to make. It will contain the boot loader and the kernel. First put a fresh diskette into the drive and type the following commands:

fdformat /dev/fd0u1440
mke2fs /dev/fd0
mount /dev/fd0 mnt
mkdir mnt/boot
mkdir mnt/boot/grub
cp linux-2.4.21/arch/i386/boot/bzImage mnt/boot/kernel
cp grub-0.92/stage1/stage1 mnt/boot/grub
cp grub-0.92/stage2/stage2 mnt/boot/grub
Create the file mnt/boot/grub/menu.lst using an editor. It should contain the following lines.
title Linux Installation Disk
root (fd0)
kernel (fd0)/boot/kernel
pause Please insert the second diskette
initrd (fd0)/initrd.img.gz

Next unmount the diskette and start GRUB.

umount mnt
grub-0.92/grub/grub

Inside GRUB type the following commands:

root (fd0)
setup (fd0)
quit
After this, the diskette is bootable and contains the kernel. If you want to update the kernel, you only have to mount the diskette again and copy a new kernel file to it. You can also edit the menu.lst file on the diskette without the need for rerunning GRUB.

The second diskette will contain the RAM disk. Put a fresh diskette into the drive and type the following commands:

fdformat /dev/fd0u1440
mke2fs /dev/fd0
mount /dev/fd0 mnt
cp initrd.img.gz mnt
umount mnt

The third diskette will contain the modules. Put a fresh diskette into the drive and type the following commands:

fdformat /dev/fd0u1440
mke2fs /dev/fd0
mount /dev/fd0 mnt
cp modules.tar.gz mnt
umount mnt

Using the diskettes

Insert the first diskette into the floppy drive in order to boot. The GRUB menu presents you with a single item, the Linux Installation Disk. Press Enter and the boot loader will load your kernel. Insert the second diskette into the drive when the boot loader prompts you for it. Next the RAM disk will be loaded. After this, the kernel starts to decompress and print boot messages.

Next comes a screen that tells you that here could be your installation script. This does not do anything useful for now.

Press ALT-F2, ALT-F3 or ALT-F4 to switch to another virtual terminal. Press ALT-F1 to switch back to your `installer'. The other virtual terminals have shell prompts and if you are familiar with Linux, you should be familiar with these.

In the shell window you can mount CD-ROMs, diskettes and hard disk partitions. You have both fdisk and cfdisk to partition a hard disk. You have the vi editor to edit files. You can create and repair ext2 file systems. If you manage to get your Ethernet card working, there is even a possibility to mount an NFS file system or to obtain files from the Web using wget.

What about the third diskette? You can mount it with:

mount /dev/fd0 /mnt

Next you can use tar to list the contents of the modules.tar.gz file and to extract files from it. As the insmod command is also available, you can get your Ethernet card or SCSI host adapter to work, at least in theory.


next up previous contents
Next: Creating a CD-ROM Up: Making Linux Installation Disks Previous: Building a Kernel   Contents
Lennart Benschop 2003-07-16