Changeset 3389

Show
Ignore:
Timestamp:
08/02/07 16:27:19 (1 year ago)
Author:
tg
Message:

an apparently working mini-fo based solution

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freewrt/target/linux/brcm-2.4/ramovl/files/sbin/mount_root

    r3388 r3389  
    11#!/bin/sh 
    2  
    3 pivot() { # <new_root> <old_root> 
    4         mount -o move /proc $1/proc && \ 
    5         pivot_root $1 $1$2 && { 
    6                 mount -o move $2/dev /dev 
    7                 mount -o bind $2/etc /etc 
    8                 mount -o move $2/tmp /tmp 
    9                 return 0 
    10         } 
    11 } 
    12  
    13 dupe() { # <new_root> <old_root> 
    14         cd $1 
    15         echo -n "creating directories... " 
    16         { 
    17                 cd $2 
    18                 find . -xdev -type d 
    19                 echo "./dev ./jffs ./mnt ./proc ./tmp" 
    20                 # xdev skips mounted directories 
    21                 cd $1 
    22         } | xargs mkdir -p 
    23         echo "done" 
    24  
    25         echo -n "setting up symlinks... " 
    26         for file in $(cd $2; find . -xdev -type f); do 
    27                 case "$file" in 
    28                 ./etc*|./rom/note) ;; #nothing 
    29                 ./usr/lib/ipkg/info) cp -af $2/$file $file;; 
    30                 *) ln -sf /rom/${file#./*} $file;; 
    31                 esac 
    32         done 
    33         for file in $(cd $2; find . -xdev -type l); do 
    34                 cp -af $2/${file#./*} $file 
    35         done 
    36         echo "done" 
    37 } 
    38  
    39 mountdp() { # <device> <mount_point> <ignored> <fs> 
    40         dev=$1; mnt=$2; shift 2; opt=$* 
    41         mount $dev $mnt $opt 
    42         dupe $mnt $rom 
    43         pivot $mnt /rom 
    44 } 
    452 
    463size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo) 
    474mount none /tmp -t tmpfs -o size=$size 
    485 
    49 mkdir -p /tmp/root 
    50 mountdp /tmp/root /mnt -o bind 
     6echo "switching to overlay filesystem" 
     7mount -t tmpfs none /jffs 
     8mount -t mini_fo -o base=/,sto=/jffs / /mnt 
     9mount -o move /proc /mnt/proc 
     10pivot_root /mnt /mnt/rom 
     11mount -o move /rom/dev /dev 
     12mount -o move /rom/tmp /tmp 
    5113 
    5214mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777