move platform specific base-files into target/linux/<targetname>
[openwrt/openwrt.git] / target / linux / ar7-2.4 / base-files / sbin / mount_root
1 #!/bin/sh
2 size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
3 mount none /tmp -t tmpfs -o size=$size
4
5 if [ "$1" != "failsafe" ]; then
6 mtd unlock linux
7 mount | grep jffs2 >&-
8 if [ $? = 0 ] ; then
9 if [ $(cat /proc/mtd | wc -l) = 6 ]; then
10 mtd erase OpenWrt
11 else
12 mount -o remount,rw /dev/root /
13 fi
14 else
15 . /bin/firstboot
16 echo "switching to jffs2"
17 mount /dev/mtdblock/4 /jffs -t jffs2
18 pivot /jffs /rom || {
19 echo "jffs2 unusable; using ramdisk"
20 ramoverlay
21 }
22 fi
23 fi
24
25 mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
26 mkdir -p /dev/pts
27 mount none /dev/pts -t devpts
28 mount -t sysfs none /sys 2>&-