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
7 mount non /dev/pts -t devpts
9 # the root mount point can come from the kernel command line
10 # or it can be overridden in the preinit.arch file
11 [ -f /etc/preinit.arch ] && . /etc/preinit.arch
13 # if we have no root parameter, just go to running from ramfs
15 export NOMOUNT="No Root"
19 #if we have a failsafe boot selected, dont bother
20 #trying to find or wait for a root mount point
21 [ -z "$FAILSAFE" ] || {
22 exec /bin/busybox init
25 # Load the modules we have in initramfs, this should
26 # make the media accessible, but, it may take some time
28 load_modules /etc/modules /etc/modules.d/*
30 #wait 10 seconds for the disc to show up
31 #usb stick typically takes 4 to 6 seconds
33 #it's quite possible the disc never shows up
34 #if we netbooted this kernel
36 while [ $COUNTER -lt 10 ]; do
38 [ -e $rootfs ] && let COUNTER=10;
42 export FAILSAFE="NoDisc"
43 exec /bin/busybox init
46 # now we'll try mount it, again with a timeout
47 # This will fail if the inserted stick is formatted
48 # in a manner we dont understand
50 while [ $COUNTER -lt 10 ]; do
53 [ $? -eq "0" ] && let COUNTER=100;
57 export FAILSAFE="MountFail"
58 exec /bin/busybox init
61 #It mounted, lets look for a postinit file, again, give it time
62 #I've seen this take 6 seconds to actually complete
64 while [ $COUNTER -lt 10 ]; do
66 [ -e /mnt/etc/banner ] && let COUNTER=10;
69 [ -e /mnt/etc/banner ] || {
70 export FAILSAFE="No Openwrt FS"
71 exec /bin/busybox init
76 mount -o move /proc /mnt/proc
77 mount -o move /dev /mnt/dev
78 mount -o move /dev/pts /mnt/dev/pts
79 mount -o move /tmp /mnt/tmp
80 mount -o move /sys /mnt/sys
81 mount none /tmp -t tmpfs
82 exec switch_root -c /dev/console /mnt /sbin/init