5 mtdpart
="$(find_mtd_part $partname)"
7 rom
=$
(awk '/squashfs/ {print $2}' /proc
/mounts
)
8 jffs
=$
(awk '/jffs2/ {print $2}' /proc
/mounts
)
10 dupe
() { # <new_root> <old_root>
12 echo -n "creating directories... "
16 echo "./dev ./jffs ./mnt ./proc ./tmp"
17 # xdev skips mounted directories
22 echo -n "setting up symlinks... "
23 for file in $
(cd $2; find .
-xdev -type f
;); do
25 .
/rom
/note
) ;; #nothing
27 .
/usr
/lib
/opkg
/info
/*) cp -af $2/$file $file;;
28 *) ln -sf /rom
/${file#./*} $file;;
31 for file in $
(cd $2; find .
-xdev -type l
;); do
32 cp -af $2/${file#./*} $file
37 pivot
() { # <new_root> <old_root>
38 mount
-o move
/proc
$1/proc
&& \
39 pivot_root
$1 $1$2 && {
40 mount
-o move
$2/dev
/dev
41 mount
-o move
$2/tmp
/tmp
42 mount
-o move
$2/sys
/sys
2>&-
43 mount
-o move
$2/jffs
/jffs
2>&-
48 fopivot
() { # <rw_root> <ro_root> <dupe?>
51 mount
-t mini_fo
-o base
=/,sto
=$1 "mini_fo:$1" /mnt
2>&- && root
=/mnt
54 mount |
grep "on $1 type" 2>&- 1>&- || mount
-o bind $1 $1
63 fopivot
/tmp
/root
/rom
1
66 # invoked as an executable
67 [ "${0##*/}" = "firstboot" ] && {
69 [ -z "$mtdpart" ] && {
70 echo "MTD partition not found."
75 echo "You do not have a squashfs partition; aborting"
76 echo "(firstboot cannot be run on jffs2 based firmwares)"
80 [ "$1" = "switch2jffs" ] && {
81 mount
"$mtdpart" /rom
/jffs
-t jffs2 ||
exit
83 # try to avoid fs changing while copying
84 mount
-o remount
,ro none
/ 2>&-
86 # copy ramoverlay to jffs2
87 echo -n "copying files ... "
88 cp -a /tmp
/root
/* /rom
/jffs
2>&-
91 # switch back to squashfs (temporarily)
92 # and park the ramdisk ontop of /tmp/root
94 mount
-o move
/mnt
/tmp
/root
96 # /jffs is the overlay
97 # /rom is the readonly
100 # try to get rid of /tmp/root
101 # this will almost always fail
102 umount
/tmp
/root
2>&-
107 # script run manually
108 [ \
! -z "$jffs" ] && {
109 echo "firstboot has already been run"
110 echo "jffs2 partition is mounted, only resetting files"
111 grep mini_fo
/proc
/filesystems
>&-
117 mount
-o remount
$jffs / 2>&-
122 mtd erase
"$partname"
123 mount
"$mtdpart" /jffs
-t jffs2
This page took 0.057512 seconds and 5 git commands to generate.