Download the e2fsprogs source code package from http://sourceforge.net/projects/e2fsprogs/
bash#
cd /usr/src/e2fsprogs-1.35bash#
export CC="gcc -mcpu=i386"bash#
./configure --host=i386-pc-linux-gnubash#
makebash#
cd e2fsckbash#
cp e2fsck.shared ~/staging/sbin/e2fsckbash#
ln -s e2fsck ~/staging/sbin/fsck.ext2bash#
cd ../miscbash#
cp fsck mke2fs ~/staging/sbinbash#
ln -s mke2fs ~/staging/sbin/mkfs.ext2
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#
./configurebash#
makebash#
cp disk-utils/mkfs ~/staging/sbinbash#
cp fdisk/fdisk ~/staging/sbinbash#
cp login-utils/agetty ~/staging/sbinbash#
ln -s agetty ~/staging/sbin/gettybash#
cp login-utils/login ~/staging/binbash#
cp misc-utils/kill ~/staging/binbash#
cp mount/mount ~/staging/binbash#
cp mount/umount ~/staging/binbash#
cp mount/swapon ~/staging/sbinbash#
cp sys-utils/dmesg ~/staging/bin
bash#
ldd ~/staging/bin/* | morebash#
ldd ~/staging/sbin/* | morebash#
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.
bash#
mknod ~/staging/dev/ram0 b 1 0bash#
mknod ~/staging/dev/fd0 b 2 0bash#
mknod ~/staging/dev/null c 1 3
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
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
bash#
cd /bash#
dd if=/dev/zero of=/dev/ram7 bs=1k count=4096bash#
mke2fs -m0 /dev/ram7 4096bash#
mount /dev/ram7 /mntbash#
cp -dpR ~/staging/* /mntbash#
umount /dev/ram7bash#
dd if=/dev/ram7 of=~/phase4-image bs=1k count=4096bash#
gzip -9 ~/phase4-image