3 # mkrootfs.sh - creates a root file system
6 # TODO: need to add checks here to verify that busybox, uClibc and bzImage
10 # command-line settable variables
12 UCLIBC_DIR
=..
/..
/uClibc
18 # don't-touch variables
22 while getopts 'b:u:s:t:Cm' opt
25 b
) BUSYBOX_DIR
=$OPTARG ;;
26 u
) UCLIBC_DIR
=$OPTARG ;;
27 t
) TARGET_DIR
=$OPTARG ;;
30 m
) MKFS
='mkfs.minix' ;;
32 echo "usage: `basename $0` [-bu]"
33 echo " -b DIR path to busybox direcory (default ..)"
34 echo " -u DIR path to uClibc direcory (default ../../uClibc)"
35 echo " -t DIR path to target direcory (default ./loop)"
36 echo " -s SIZE size of root filesystem in Kbytes (default 4000)"
37 echo " -C don't perform cleanup (umount target dir, gzip rootfs, etc.)"
38 echo " (this allows you to 'chroot loop/ /bin/sh' to test it)"
39 echo " -m use minix filesystem (default is ext2)"
48 # clean up from any previous work
50 [ $?
-eq 0 ] && umount
$TARGET_DIR
51 [ -d $TARGET_DIR ] && rm -rf $TARGET_DIR/
52 [ -f rootfs
] && rm -f rootfs
53 [ -f rootfs.gz
] && rm -f rootfs.gz
56 # prepare root file system and mount as loopback
57 dd if=/dev
/zero of
=rootfs bs
=1k count
=$FSSIZE
60 mount
-o loop
,exec rootfs
$TARGET_DIR # must be root
64 mkdir
-p $TARGET_DIR/lib
67 cp -a libc.so
* $BASE_DIR/$TARGET_DIR/lib
68 cp -a uClibc
*.so
$BASE_DIR/$TARGET_DIR/lib
69 cp -a ld.so-
1/d-link
/ld-linux-uclibc.so
* $BASE_DIR/$TARGET_DIR/lib
70 cp -a ld.so-
1/libdl
/libdl.so
* $BASE_DIR/$TARGET_DIR/lib
71 cp -a crypt
/libcrypt.so
* $BASE_DIR/$TARGET_DIR/lib
75 # install busybox and components
78 make CC
=$BASE_DIR/$UCLIBC_DIR/extra
/gcc-uClibc
/i386-uclibc-gcc
79 make CONFIG_PREFIX
=$BASE_DIR/$TARGET_DIR install
85 .
/mkdevs.sh
$TARGET_DIR/dev
90 ln -s /proc
/mounts
$TARGET_DIR/etc
/mtab
93 # other miscellaneous setup
94 mkdir
$TARGET_DIR/initrd
95 mkdir
$TARGET_DIR/proc
98 # Done. Maybe do cleanup.