#!/bin/sh # Builds (most of) a directory that can be used as # a stand-alone root filesystem. See make_image # for the next step. # This script is highly customized to my purposes, # Use it as a guide. It can (and should) be run as # a non-privileged (development) user. # Larry Doolittle September 2000 BASE=$PWD APP=$HOME/mebt/fpga mkdir -p root cd root rm -rf * # start with a clean slate HERE=$PWD mkdir bin sbin lib usr dev var tmp proc mnt mkdir usr/bin usr/lib mnt/floppy mkdir -p home/mortal/.ssh # The /etc directory gets created with a cp -a (below). # Miscellaneous system binaries, not covered by busybox. cp /sbin/ifconfig sbin/ cp /sbin/route sbin/ cp /usr/bin/strace bin/ cp /usr/local/bin/socket bin/ # Application-specific binaries cp $APP/cs/fserver usr/bin/ cp $APP/xsload usr/bin/ # Stripping normally saves a huge amount of space. strip sbin/* usr/bin/* # Am I really working around a bug in GNU strip 2.9.1? for f in bin/*; do strip $f; done # BusyBox (http://busybox.lineo.com/) is cool, you # should use it if space is an issue. I recommend # configuring it to include at _least_ init, ls, more, # df, echo, grep, head, tail, insmod, rmmod, ln, # kill, mkdir, mknod, mount, ps, rm. # The busybox install script fills up directories with symlinks, # so install it _after_ the generic strip command above. # The busybox makefile strips for us. # BUSYBOX_DIR=$HOME/net/byld-1.0beta3/packages/BYLD/BusyBox/busybox-0.46 BUSYBOX_DIR=$HOME/rffe/busybox-fpga ( cd $BUSYBOX_DIR || exit; make PREFIX=$HERE install) # System configuration files. I don't supply these. # I hope this list is a good reminder of what you need # to bring networking up nicely, but you really have to # understand what they are and create versions for yourself. # /etc/init.d/rcS is the default system initialization script # for busybox's init. # # $ ls -R etc # group hosts inittab pam.conf resolv.conf # host.conf init.d nsswitch.conf passwd ssh # # etc/init.d: # rcS # # etc/ssh: # ssh_host_key ssh_host_key.pub sshd_config cp -a $BASE/etc etc # This is a weird one cp $HOME/.ssh/csg.identity.pub home/mortal/.ssh/authorized_keys # Libraries. Kind of a pain. BYLD seems to use its # scripts to identify needed libraries, but I'll # bet it wouldn't find libnss_*, that glibc2 pulls # in as needed based on /etc/nsswitch.conf . # # Maybe I should do this too, proceeding something like: # EXES=`find . -perm +111 -type f` # EXES=`file $EXES | grep "dynamically linked" | awk -F: '{print $1}'` # NSSVER=2.0.7 # NSSLIBS=$(awk '/[a-z]/&&!/#/{for(i=2;i<=NF;i++)f[$i]=1}\ # END{for(i in f)print "/usr/lib/libnss_"i"-'$NSSVER'.so"}\ # ' etc/nsswitch.conf) # LIBS=`ldd $EXES $NSSLIBS | awk '(NF==4 && $2=="=>"){f[$3]=1}\ # END{for(i in f)print i}'` # cp $LIBS $NSSLIBS lib/ cp /lib/ld-2.0.7.so lib/ cp /lib/libc-2.0.7.so lib/ cp /lib/libm-2.0.7.so lib/ cp /lib/libnsl-2.0.7.so lib/ cp /lib/libnss_dns-2.0.7.so lib/ cp /lib/libnss_files-2.0.7.so lib/ cp /lib/libnss_compat-2.0.7.so lib/ cp /lib/libresolv-2.0.7.so lib/ cp /usr/lib/libstdc++.so.2.8.0 lib/ # Stripping libraries tends to save even more space than for the executables. strip lib/* # Kernel modules MODULE_DIR=$HOME/rffe/linux-2.0.36/modules mkdir lib/modules cp $MODULE_DIR/8390.o lib/modules cp $MODULE_DIR/ne.o lib/modules echo "Root filesystem finished." echo "Space taken:" du echo "Suggested next step: make_image (have to be root for that one)"