2
0

mount_root 837 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. # Copyright (C) 2006 OpenWrt.org
  3. is_dirty() {
  4. grep Broadcom /proc/cpuinfo >&- || return 1
  5. OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
  6. return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
  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. if [ "$1" != "failsafe" ]; then
  11. mtd unlock linux
  12. mount | grep jffs2 >&-
  13. if [ $? = 0 ] ; then
  14. mount -o remount,rw /dev/root /
  15. else
  16. . /bin/firstboot
  17. is_dirty
  18. [ $? != 0 ] && {
  19. echo "switching to jffs2"
  20. mount /dev/mtdblock/4 /jffs -t jffs2
  21. pivot /jffs /rom
  22. } || {
  23. echo "jffs2 unusable; using ramdisk"
  24. ramoverlay
  25. }
  26. fi
  27. fi
  28. mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
  29. mkdir -p /dev/pts
  30. mount none /dev/pts -t devpts
  31. mount -t sysfs none /sys 2>&-