2 # Copyright (C) 2006 OpenWrt.org
4 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
5 mount none /proc -t proc
6 mount none /dev -t devfs
8 # the root mount point can come from the kernel command line
9 # or it can be overridden in the preinit.arch file
10 [ -f /etc/preinit.arch ] && . /etc/preinit.arch
12 # if we have no root parameter, just go to running from ramfs
14 export NOMOUNT="No Root"
18 #if we have a failsafe boot selected, dont bother
19 #trying to find or wait for a root mount point
20 [ -z "$FAILSAFE" ] || {
21 exec /bin/busybox init
24 # Load the modules we have in initramfs, this should
25 # make the media accessible, but, it may take some time
27 load_modules /etc/modules /etc/modules.d/*
29 #wait 10 seconds for the disc to show up
30 #usb stick typically takes 4 to 6 seconds
32 #it's quite possible the disc never shows up
33 #if we netbooted this kernel
35 while [ $COUNTER -lt 10 ]; do
37 [ -e $rootfs ] && let COUNTER=10;
41 export FAILSAFE="NoDisc"
42 exec /bin/busybox init
45 # now we'll try mount it, again with a timeout
46 # This will fail if the inserted stick is formatted
47 # in a manner we dont understand
49 while [ $COUNTER -lt 10 ]; do
52 [ $? -eq "0" ] && let COUNTER=100;
56 export FAILSAFE="MountFail"
57 exec /bin/busybox init
60 #It mounted, lets look for a postinit file, again, give it time
61 #I've seen this take 6 seconds to actually complete
63 while [ $COUNTER -lt 10 ]; do
65 [ -e /mnt/etc/banner ] && let COUNTER=10;
68 [ -e /mnt/etc/banner ] || {
69 export FAILSAFE="No Openwrt FS"
70 exec /bin/busybox init
75 mount -o move /proc /mnt/proc
76 mount -o move /dev /mnt/dev
77 mount -o move /tmp /mnt/tmp
78 mount -o move /sys /mnt/sys
79 mount none /tmp -t tmpfs
80 exec switch_root -c /dev/console /mnt /sbin/init