nuke jffs2root --move from init scripts
[openwrt/staging/mkresin.git] / openwrt / package / base-files / brcm-2.6 / sbin / mount_root
1 #!/bin/sh
2 is_dirty() {
3 grep Broadcom /proc/cpuinfo >&- || return 1
4 OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
5 return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
6 }
7
8 size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
9 mount none /tmp -t tmpfs -o size=$size
10
11 if [ "$1" != "failsafe" ]; then
12 mtd unlock linux
13 mount | grep jffs2 >&-
14 if [ $? = 0 ] ; then
15 mount -o remount,rw /dev/root /
16 else
17 . /bin/firstboot
18 is_dirty
19 [ $? != 0 ] && {
20 echo "switching to jffs2"
21 mount /dev/mtdblock/4 /jffs -t jffs2
22 pivot /jffs /rom
23 } || {
24 echo "jffs2 unusable; using ramdisk"
25 ramoverlay
26 }
27 fi
28 fi
29
30 mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
31 mkdir -p /dev/pts
32 mount none /dev/pts -t devpts
33 mount -t sysfs none /sys 2>&-