tweaks for 2M devices
[openwrt.git] / package / base-files / files / sbin / mount_root
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3 . /etc/functions.sh
4
5 mount none /proc -t proc
6
7 size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)<l)?mt-l:s}' /proc/meminfo)
8 mount none /tmp -t tmpfs -o size=$size,nosuid,nodev,mode=1777
9
10 if grep devfs /proc/filesystems > /dev/null; then
11 mount none /dev -t devfs
12 M0=/dev/pty/m0
13 M1=/dev/pty/m1
14 HOTPLUG=/sbin/hotplug-call
15 else
16 mount -t sysfs none /sys
17 mount -t tmpfs tmpfs /dev -o size=512K
18 mknod /dev/console c 5 1
19 mkdir /dev/shm
20 /sbin/hotplug2 --no-persistent --coldplug --set-rules-file /etc/hotplug2-init.rules
21 M0=/dev/ptmx
22 M1=/dev/ptmx
23 HOTPLUG=
24 fi
25
26 mkdir -p /dev/pts /dev/shm
27 mount none /dev/pts -t devpts
28
29 # the shell really doesn't like having stdin/out closed
30 # that's why we use /dev/pty/m0 and m1 as replacement
31 # for /dev/console if there's no serial console available
32 dd if=/dev/console of=/dev/null bs=1 count=0 >/dev/null 2>/dev/null || \
33 exec <$M0 >$M1 2>&0
34
35 echo "$HOTPLUG" > /proc/sys/kernel/hotplug
36
37 jffs2_ready () {
38 mtdpart="$(find_mtd_part rootfs_data)"
39 magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
40 [ "$magic" != "deadc0de" ]
41 }
42
43 [ failsafe != "$1" ] && {
44 grep rootfs /proc/mtd >/dev/null 2>/dev/null && {
45 mtd unlock rootfs
46 grep rootfs_data /proc/mtd >/dev/null 2>/dev/null && {
47 . /bin/firstboot
48 jffs2_ready && {
49 echo "switching to jffs2"
50 mount "$(find_mtd_part rootfs_data)" /jffs -t jffs2 && \
51 fopivot /jffs /rom
52 } || {
53 echo "jffs2 not ready yet; using ramdisk"
54 ramoverlay
55 }
56 }
57 } || mount -o remount,rw /dev/root /
58 }
This page took 0.056852 seconds and 5 git commands to generate.