2.3. Construction

In this section, we will be building the actual boot disk and root disk floppies. Lines preceded by bash# indicate a shell command and lines starting with grub> indicate a command typed within the grub shell.

2.3.1. Prepare the boot disk media

Insert a blank diskette labeled "boot disk".


It may be necessary to erase the "blank" diskette if it comes factory pre-formatted for another, non-Linux operating system. This can be done using the command dd if=/dev/zero of=/dev/fd0 bs=1k count=1440

bash# mke2fs -m0 /dev/fd0
bash# mount /dev/fd0 /mnt

2.3.2. Build the GRUB bootloader

Get the GRUB source code from ftp://alpha.gnu.org/gnu/grub/ and unpack it into the /usr/src directory.

Configure and build the GRUB source code for an i386 processor by using the following commands:

bash# cd /usr/src/grub-0.95
bash# export CC="gcc -mcpu=i386"
bash# ./configure --host=i386-pc-linux-gnu --without-curses
bash# make

2.3.3. Copy the bootloader files to diskette

Normally, after compiling source code, one would use the command make install to copy the finished files to their proper destinations in the filesystem. However, using make install does not work well with small media like the floppy disks we are using. The problem is that there are many files in a package besides the actual binaries that get the job done. For example, there are often man or info pages that provide documentation. These extra files can take up more space than we can spare on the diskette. We can work around this limitation by copying essential files manually rather than using make install.

For GRUB to boot we will need to copy the stage1 and stage2 bootloader files to the /boot/grub directory on the boot floppy.

bash# mkdir -p /mnt/boot/grub
bash# cp /usr/src/grub-0.95/stage1/stage1 /mnt/boot/grub
bash# cp /usr/src/grub-0.95/stage2/stage2 /mnt/boot/grub

2.3.4. Finish bootloader installation

Once the bootloader's files are copied to the boot disk we can enter the grub shell to finish the installation.

bash# /usr/src/grub-0.95/grub/grub
grub> root (fd0)
grub> setup (fd0)
grub> quit

2.3.5. Build the Linux kernel

The steps for building the kernel were tested using Linux kernel version 2.4.26 and should work any 2.4.x or 2.6.x kernel. The latest version of the kernel source code may be downloaded from http://www.kernel.org/ or one of its mirrors.


The instructions below are very brief and are intended for someone who has previous experience building custom kernels. A more detailed explanation of the kernel building process can be found in the Kernel Rebuild Guide by Kwan Lowe.

bash# cd /usr/src/linux
bash# make menuconfig

Be sure to configure support for the following:

bash# make dep
bash# make clean
bash# make bzImage

2.3.6. Copy the kernel to diskette

bash# cp /usr/src/linux/arch/i386/boot/bzImage /mnt/boot/vmlinuz

2.3.7. Unmount the boot disk

bash# cd /
bash# umount /mnt

2.3.8. Prepare the root disk media

Insert a blank diskette labeled "root disk".

bash# mke2fs -m0 /dev/fd0
bash# mount /dev/fd0 /mnt

2.3.9. Build BASH

Get the bash-3.0 source code package from ftp://ftp.gnu.org/gnu/bash/ and untar it into the /usr/src directory.

Build BASH for an i386 CPU with the following commands:

bash# cd /usr/src/bash-3.0
bash# export CC="gcc -mcpu=i386"
bash# ./configure --enable-static-link \
  --enable-minimal-config --host=i386-pc-linux-gnu
bash# make
bash# strip bash

2.3.10. Copy BASH to the root disk

bash# mkdir /mnt/bin
bash# cp bash /mnt/bin/bash
bash# ln -s bash /mnt/bin/sh

2.3.11. Create device files that BASH needs

bash# mkdir /mnt/dev
bash# mknod /mnt/dev/console c 5 1

2.3.12. Unmount the root disk

bash# cd /
bash# umount /mnt