Index: package/base-files/default/bin/firstboot =================================================================== --- package/base-files/default/bin/firstboot (revision 3537) +++ package/base-files/default/bin/firstboot (working copy) @@ -37,19 +37,30 @@ pivot_root $1 $1$2 && { mount -o move $2/dev /dev mount -o move $2/tmp /tmp + mount -o move $2/jffs /jffs 2>&- } } mountdp() { # - dev=$1; mnt=$2; shift 2; opt=$* + dev=$1; mnt=$2; shift 2; opt=$* mount $dev $mnt $opt dupe $mnt $rom pivot $mnt /rom } +fopivot() { # + root=$1 + { + mount -t mini_fo -o base=/,sto=$1 none /mnt 2>&- && root=/mnt + } || { + [ "$3" = "1" ] && mount -o bind $1 $1 && dupe $1 $rom + } + pivot $root $2 +} + ramoverlay() { mkdir -p /tmp/root - mountdp /tmp/root /mnt -o bind + fopivot /tmp/root /rom 1 } [ "${0##*/}" = "firstboot" ] && { @@ -61,8 +72,8 @@ [ "$1" = "switch2jffs" ] && { mtd erase OpenWrt - mount -o remount,ro none / # try to avoid fs changing while copying - mount -o bind / /mnt + mount -o remount,ro none / 2>&- # try to avoid fs changing while copying + mount -o bind /tmp/root /mnt mount /dev/mtdblock/4 /rom/jffs -t jffs2 echo -n "copying files ... " cp -a /mnt/* /rom/jffs @@ -70,7 +81,8 @@ echo "done" pivot /rom /mnt mount -o move /mnt /tmp/root - pivot /jffs /rom + fopivot /jffs /rom + umount /tmp/root 2>&- jffs2root --clean exit 0 } Index: package/base-files/default/sbin/mount_root =================================================================== --- package/base-files/default/sbin/mount_root (revision 3537) +++ package/base-files/default/sbin/mount_root (working copy) @@ -23,7 +23,7 @@ is_dirty [ $? != 0 ] && { mount /dev/mtdblock/4 /jffs - pivot /jffs /rom + fopivot /jffs /rom } || ramoverlay fi fi