3. Construction

3.1. Install utilities from e2fsprogs

Download the e2fsprogs source code package from http://sourceforge.net/projects/e2fsprogs/

bash# cd /usr/src/e2fsprogs-1.35
bash# export CC="gcc -mcpu=i386"
bash# ./configure --host=i386-pc-linux-gnu
bash# make
bash# cd e2fsck
bash# cp e2fsck.shared ~/staging/sbin/e2fsck
bash# ln -s e2fsck ~/staging/sbin/fsck.ext2
bash# cd ../misc
bash# cp fsck mke2fs ~/staging/sbin
bash# ln -s mke2fs ~/staging/sbin/mkfs.ext2

3.2. Install utilities from util-linux

Get the latest util-linux source from ftp://ftp.win.tue.nl/pub/linux-local/utils/util-linux/

bash# cd /usr/src/util-linux-2.12h

Use a text editor to make the following changes to MCONFIG:

  • Change "CPU=$(shell uname -m)" to "CPU=i386"

  • Change "HAVE_SHADOW=yes" to "HAVE_SHADOW=no"

bash# ./configure
bash# make
bash# cp disk-utils/mkfs ~/staging/sbin
bash# cp fdisk/fdisk ~/staging/sbin
bash# cp login-utils/agetty ~/staging/sbin
bash# ln -s agetty ~/staging/sbin/getty
bash# cp login-utils/login ~/staging/bin
bash# cp misc-utils/kill ~/staging/bin
bash# cp mount/mount ~/staging/bin
bash# cp mount/umount ~/staging/bin
bash# cp mount/swapon ~/staging/sbin
bash# cp sys-utils/dmesg ~/staging/bin

3.3. Check library requirements

bash# ldd ~/staging/bin/* | more
bash# ldd ~/staging/sbin/* | more
bash# ls ~/staging/lib

All of the dependencies revealed by the ldd command are for libraries already present in the staging area so there is no need to copy anything new.

3.4. Strip binaries to save space

bash# strip ~/staging/bin/*
bash# strip ~/staging/sbin/*

3.5. Create additional device files

bash# mknod ~/staging/dev/ram0 b 1 0
bash# mknod ~/staging/dev/fd0 b 2 0
bash# mknod ~/staging/dev/null c 1 3

3.6. Create the fstab and mtab files

bash# cd ~/staging/etc

Use an editor like vi, emacs or pico to create the following file and save it as ~/staging/etc/fstab.

proc        /proc   proc   defaults   0   0
/dev/ram0   /       ext2   defaults   1   1

Create an empty mtab file.

bash# echo -n >mtab

3.7. Write a script to check and mount local filesystems

Use an editor to create the following shell script and save it as ~/staging/etc/init.d/local_fs:

#!/bin/sh
#
# local_fs - check and mount local filesystems
#
PATH=/sbin:/bin ; export PATH

fsck -ATCp
if [ $? -gt 1 ]; then
  echo "Filesystem errors still exist!  Manual intervention required."
  /bin/sh
else
  echo "Remounting / as read-write."
  mount -n -o remount,rw /
  echo -n >/etc/mtab
  mount -f -o remount,rw /
  echo "Mounting local filesystems."
  mount -a -t nonfs,nosmbfs
fi
#
# end of local_fs

Set execute permissions on the script.

bash# chmod +x local_fs

3.8. Create a compressed root disk image

bash# cd /
bash# dd if=/dev/zero of=/dev/ram7 bs=1k count=4096
bash# mke2fs -m0 /dev/ram7 4096
bash# mount /dev/ram7 /mnt
bash# cp -dpR ~/staging/* /mnt
bash# umount /dev/ram7
bash# dd if=/dev/ram7 of=~/phase4-image bs=1k count=4096
bash# gzip -9 ~/phase4-image

3.9. Write the root disk image to floppy

Insert the diskette labeled "root disk" into drive fd0.

bash# dd if=~/phase4-image.gz of=/dev/fd0 bs=1k