Rather than copying files directly to the ramdisk, we can make things easier by setting up a staging area. The staging area will give us room to work without worrying about the space constraints of the ramdisk. It will also provide a way to save our work and make it easier to enhance the rootdisk in later phases of the project.
The staging procedure will work like this:
Create a directory structure as defined in the FHS.
Copy in the files from phase 2's root disk.
Build the new package from source code.
Install files into the correct FHS directories.
Strip the binaries to save space.
Check library dependencies.
Copy to the whole directory structure to the ramdisk.
Compress the ramdisk and write it out to floppy.
bash#
mkdir ~/stagingbash#
cd ~/stagingbash#
mkdir bin boot dev etc home lib mnt opt proc root sbin tmp usr varbash#
mkdir var/log var/run
bash#
dd if=~/phase2-image.gz | gunzip -c > /dev/ram7bash#
mount /dev/ram7 /mntbash#
cp -dpR /mnt/* ~/stagingbash#
umount /dev/ram7bash#
rmdir ~/staging/lost+found
Download a recent version of coreutils from ftp://ftp.gnu.org/gnu/coreutils/
bash#
cd /usr/src/coreutils-5.2.1bash#
export CC="gcc -mcpu=i386"bash#
./configure --host=i386-pc-linux-gnubash#
makebash#
cd srcbash#
cp cat chgrp chmod chown cp date dd df ~/staging/binbash#
cp hostname ln ls mkdir mkfifo mknod ~/staging/binbash#
cp mv rm rmdir stty su sync uname ~/staging/bin
Check library requirements by using ldd on some of the new binaries.
bash#
ldd ~/staging/bin/catbash#
ldd ~/staging/bin/lsbash#
ldd ~/staging/bin/subash#
ls ~/staging/lib
Note the differences in the required libraries, as shown by the ldd command, and the libraries present in the staging area, as shown by the ls command, then copy any missing libraries to the staging area.
bash#
cp /lib/librt.so.1 ~/staging/libbash#
cp /lib/libpthread.so.0 ~/staging/libbash#
cp /lib/libcrypt.so.1 ~/staging/lib
bash#
strip ~/staging/bin/*bash#
strip --strip-unneeded ~/staging/lib/*
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=~/phase3-image bs=1k count=4096bash#
gzip -9 ~/phase3-image
The process for creating the compressed root disk image will change very little throughout the remaining chapters. Writing a small script to handle this function can be a great time saver.