source: freewrt/target/linux/brcm-2.4/squashfs-overlay/files/sbin/mount_root@ 94ff7cb

freewrt_1_0 freewrt_2_0
Last change on this file since 94ff7cb was 94ff7cb, checked in by Waldemar Brodkorb <wbx@…>, 19 years ago

add mini-fo fixes from OpenWrt, mini-fo is now enabled in the squashfs-overlay kernel

git-svn-id: svn://www.freewrt.org/branches/freewrt_1_0@1105 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100755
File size: 2.0 KB
Line 
1#!/bin/sh
2is_dirty() {
3 grep Broadcom /proc/cpuinfo >&- || return 1
4 OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
5 return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
6}
7
8pivot() { # <new_root> <old_root>
9 mount -o move /proc $1/proc && \
10 pivot_root $1 $1$2 && {
11 mount -o move $2/dev /dev
12 mount -o move $2/tmp /tmp
13 return 0
14 }
15}
16
17dupe() { # <new_root> <old_root>
18 cd $1
19 echo -n "creating directories... "
20 {
21 cd $2
22 find . -xdev -type d
23 echo "./dev ./jffs ./mnt ./proc ./tmp"
24 # xdev skips mounted directories
25 cd $1
26 } | xargs mkdir -p
27 echo "done"
28
29 echo -n "setting up symlinks... "
30 for file in $(cd $2; find . -xdev -type f;); do
31 case "$file" in
32 ./rom/note) ;; #nothing
33 ./etc/resolv.conf|\
34 ./usr/lib/ipkg/info) cp -af $2/$file $file;;
35 *) ln -sf /rom/${file#./*} $file;;
36 esac
37 done
38 for file in $(cd $2; find . -xdev -type l;); do
39 cp -af $2/${file#./*} $file
40 done
41 echo "done"
42}
43
44mountdp() { # <device> <mount_point> <ignored> <fs>
45 dev=$1; mnt=$2; shift 2; opt=$*
46 mount $dev $mnt $opt
47 dupe $mnt $rom
48 pivot $mnt /rom
49}
50
51size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
52mount none /tmp -t tmpfs -o size=$size
53
54mtd unlock linux
55is_dirty
56[ $? != 0 ] && {
57 echo "switching to overlay filesystem"
58 datanr=$(awk -F : '/data/ { print $1 }' /proc/mtd |sed "s#mtd##")
59 mount /dev/mtdblock/$datanr /jffs -t jffs2
60 mount -t mini_fo -o base=/,sto=/jffs /jffs /mnt
61 pivot /mnt /rom
62} || {
63 echo "jffs2 unusable; using ramdisk"
64 mkdir -p /tmp/root
65 mountdp /tmp/root /mnt -o bind
66}
67
68mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
69mkdir -p /dev/pts
70mount none /dev/pts -t devpts
Note: See TracBrowser for help on using the repository browser.