#!/bin/ash export PATH="/bin:/sbin:/usr/bin:/usr/sbin" KERNVER="`uname -r`" FILES=`echo /* | sed 's@/mnt @ @'` if [ -n "$AUFS" ]; then if [ -z "$INIT_TMPFS" ]; then mount -t tmpfs none /mnt cd /mnt cp -a $FILES . mkdir mnt export INIT_TMPFS=1 exec switch_root . /init fi fi mount -t proc none /proc ROOTFLAG="ro" INIT="/sbin/init" for p in `cat /proc/cmdline`; do v=`echo $p | sed 's/[^=]*=//'` case $p in root=*) ROOT=$v ;; rootfstype=*) ROOTPARM="-t $v" ;; rootflags=*) ROOTFLAG=$v ;; nfsroot=*) NFSROOT=`echo $v | sed 's/,.*//'` NFSOPTS=`echo $v | sed 's/[^,]*,*//'` NFSPARM='-t nfs' if [ -n "$NFSOPTS" ]; then NFSPARM="$NFSPARM -o $NFSOPTS" unset NFSOPTS fi ;; init=*) INIT=$v ;; [0-6S]) RUNLEVEL=$p ;; esac done unset p v ROOTPARM="$ROOTPARM -o $ROOTFLAG" unset ROOTFLAG if [ -n "$RUNLEVEL" ]; then INIT="$INIT $RUNLEVEL" fi hwclock --hctosys mount -t sysfs none /sys tmp=/tmp/dev2mod echo 'dev2mod(){ while read dev; do case $dev in' > $tmp sort -r /lib/modules/$KERNVER/modules.alias \ | sed -n 's/^alias *\([^ ]*\) *\(.*\)/\1)modprobe \2;;/p' >> $tmp echo 'esac; done; }' >> $tmp . $tmp rm $tmp unset tmp cat /sys/bus/*/devices/*/modalias | dev2mod modprobe pcmcia cat /sys/bus/*/devices/*/modalias | dev2mod umount /sys modprobe af_packet modprobe unix modprobe ext3 modprobe xfs if [ -z "$NIC_DEV" ]; then NIC_DEV=eth0 fi if [ -n "$NFSROOT" ]; then ifconfig lo 127.0.0.1 if ifconfig $NIC_DEV; then ifconfig $NIC_DEV up sleep 3 udhcpc --retries=2 -i $NIC_DEV mount -t nfs $NFSPARM $NFSROOT /mnt fi elif [ -n "$ROOT" ]; then mount $ROOTPARM $ROOT /mnt fi if [ -n "$INIT_DEBUG" ]; then set exec /bin/sh fi umount /proc if [ -n "$AUFS" ]; then case $AUFS in /*) mnt="/mnt$AUFS" ;; *) mnt="/mnt" ;; esac mkdir /.rw /.root mount -t aufs -o br:/.rw:${mnt}=ro none /.root unset mnt cd /.root if [ -n "$INIT_TMPFS" ]; then test -d initrd || mkdir initrd pivot_root . initrd initrd/bin/busybox rm -rf `echo $FILES /.root | sed 's@/@initrd/@g'` exec $INIT else cp -a /bin/busybox . rm -rf $FILES ./busybox mount --move . / exec ./busybox chroot . /bin/sh -c "rm ./busybox; exec $INIT" fi fi exec switch_root /mnt $INIT