mount_root 650 B

12345678910111213141516171819202122232425262728
  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. if [ "$1" != "failsafe" ]; then
  5. mtd unlock linux
  6. mount | grep jffs2 >&-
  7. if [ $? = 0 ] ; then
  8. if [ $(cat /proc/mtd | wc -l) = 6 ]; then
  9. mtd erase OpenWrt
  10. else
  11. mount -o remount,rw /dev/root /
  12. fi
  13. else
  14. . /bin/firstboot
  15. echo "switching to jffs2"
  16. mount /dev/mtdblock/4 /jffs -t jffs2
  17. pivot /jffs /rom || {
  18. echo "jffs2 unusable; using ramdisk"
  19. ramoverlay
  20. }
  21. fi
  22. fi
  23. mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
  24. mkdir -p /dev/pts
  25. mount none /dev/pts -t devpts
  26. mount -t sysfs none /sys 2>&-