2 # Copyright (C) 2006 OpenWrt.org
11 # if we have no root parameter, just go to running from ramfs
13 export NOMOUNT="No Root"
17 #if we have a failsafe boot selected, dont bother
18 #trying to find or wait for a root mount point
19 [ -z "$FAILSAFE" ] || {
20 exec /bin/busybox init
23 # Load the modules we have in initramfs, this should
24 # make the media accessible, but, it may take some time
26 load_modules /etc/modules /etc/modules.d/*
28 #wait 10 seconds for the disc to show up
29 #usb stick typically takes 4 to 6 seconds
31 #it's quite possible the disc never shows up
32 #if we netbooted this kernel
34 while [ $COUNTER -lt 10 ]; do
36 [ -e $rootfs ] && let COUNTER=10;
40 export FAILSAFE="NoDisc"
41 exec /bin/busybox init
44 # now we'll try mount it, again with a timeout
45 # This will fail if the inserted stick is formatted
46 # in a manner we dont understand
48 while [ $COUNTER -lt 10 ]; do
51 [ $? -eq "0" ] && let COUNTER=100;
55 export FAILSAFE="MountFail"
56 exec /bin/busybox init
59 #It mounted, lets look for a postinit file, again, give it time
60 #I've seen this take 6 seconds to actually complete
62 while [ $COUNTER -lt 10 ]; do
64 [ -e /mnt/etc/banner ] && let COUNTER=10;
67 [ -e /mnt/etc/banner ] || {
68 export FAILSAFE="No Openwrt FS"
69 exec /bin/busybox init
74 mount -o move /proc /mnt/proc
75 mount -o move /dev /mnt/dev
76 mount -o move /dev/pts /mnt/dev/pts
77 mount -o move /tmp /mnt/tmp
78 mount -o move /sys /mnt/sys
79 mount none /tmp -t tmpfs
81 exec switch_root -c /dev/console /mnt /sbin/init