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