5.3. Construction

5.3.1. Install utilities from e2fsprogs

bash# cd /usr/src/e2fsprogs-1.29
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

5.3.2. Install utilities from util-linux

bash# cd /usr/src/util-linux-2.11u

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

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

5.3.3. Check library requirements

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

5.3.4. Strip binaries to save space

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

5.3.5. Create additional device files

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

5.3.6. Create mtab and fstab files

bash# cd ~/staging/etc
bash# ln -s /proc/mounts mtab

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

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

5.3.7. Write a script to mount the proc filesystem

bash# mkdir ~/staging/etc/init.d

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

#!/bin/sh
#
# proc_fs - mount the proc filesystem
#
PATH=/sbin:/bin ; export PATH

mount -t proc proc /proc
#
# end of proc_fs

5.3.8. 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 -o remount,rw /
  echo "Mounting local filesystems."
  mount -a
fi
#
# end of local_fs

Set execute permissions on the scripts.

bash# chmod +x proc_fs
bash# chmod +x local_fs

5.3.9. 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
bash# mount /dev/ram7 /mnt
bash# cp -dpR ~/staging/* /mnt
bash# umount /dev/ram7
bash# dd if=/dev/ram7 of=~/phase4-image bs=1k
bash# gzip -9 ~/phase4-image

5.3.10. Write the root disk image to floppy

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

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