本方法自己发现,大家都知道G13的rom小,最后整得可用空间只有150MB。使用了link2SD,可以安装大的软件了,可是最后还是发现内存急剧减少,没办法就又删除system/app中的程序,起码节省了系统程序会在data目录下创建的文件。

 

内存仍会减少,然后学着把一些自己认为必备的程序移到system/app下面,后面移得多了发现可用空间还是经常不足。

 

最后是自己发现的方法了。把移到了system/app下面的APK里面的class.dex和lib删掉,减小体积。之所以这么做是因为我们往往在移到system/app时都把lib释放到lib文件夹里面了,而安装时生成在data/dalvik-cache目录中的dex也改名odex移到了system/app中了,这些文件在系统恢复时也不会被删掉,那APK中的文件便不再有用了。试着删除之后果然体积减少很多,非常有效。推荐一下。然后精简了etc下WPDB.zip的文件删除了非中文,英文的地名,因为中文系统当然不可能用到了,就又减了3M多。

 

用G13就是得省的,现在我手机里可用空间保持在七八十MB了,基本大多数软件不会出现内存不足了

 

发现了一种新方法省内存
    首先是安装了link2SD和RE,针对link2SD做了内存卡分区,然后再RE中就多了一个分区可用啦,好了,把 /data/data目录中的任意一个占内存的文件夹移动到第二分区中,然后在移过去的文件夹上长按,选择【链接到此文件夹】,把链接创建回/data /data,好了,这个文件夹所占的内存释放了。不过还是建议只把非常用常开程序移动了。

    需要注意的是,对于有lib文件夹且lib文件夹中有so文件的程序不能把整个程序数据文件夹使用上面方法移动,这种lib文件夹必须存在才能保证link2SD的正常工作.因而只能把程序数据文件夹内的各个子文件夹分别链接到sdext2里面啦.

 

写了个脚本来移动数据文件的,可以节省很多内存,可以看看

#!/system/xbin/sh 
# folder not followed by /
dataappfolder=/data/app
datadatafolder=/data/data
sdext2datafolder=/data/sdext2/data2
dataapps=`ls $dataappfolder` 

isdataapp(){
    local key=$1
    if [ $key == "" ]
    then
        return 0
    fi
    
    local dataapp
    for dataapp in $dataapps
    do
        if [ -d $dataappfolder"/"$dataapp ]
        then
        continue
        fi
        
        if [ ! -L $dataappfolder"/"$dataapp ] 
        then
        continue
        fi
        
        #if [[ $dataapp == *$key*apk ]] not support,only support the following check method
        if [ ${dataapp/$key/} != $dataapp ]
        then
            return 1
        fi
    done
    
    return 0
} 

getfullpath(){
    local currentpath=`pwd`
    cd "$1"
    local fullpath=`pwd`
    cd $currentpath
    return 0
}

ergodic(){
    local folder=$1
    local file
    for file in ` ls $folder `
    do
        if [ -d $folder"/"$file ] && [ ! -L $folder"/"$file ]
            then
            ergodic $folder"/"$file
        else
            if [ -L $folder"/"$file ]
            then
                echo $folder"/"$file
            fi
        fi
    done
}
#ergodic .

rmfileorfolder(){
    local path=$1
    if [ -d $path ]
    then
        echo "rm -r $path <rmfileorfolder>"
        rm -r $path
    else
        echo "rm $path <rmfileorfolder>"
        rm $path
    fi
}

setprop(){
    local topath=$1
    local frompath=$1
    chmod -rwxXst topath
}

moveandlink(){
    local frompath=$1
    if [ ! -e $frompath ] || [ -L $frompath ]
    then
        echo "from file do not exist or is link. $frompath <moveandlink>"
        return
    fi

    local fromname=`basename $frompath`
    local fromdir=`dirname $frompath`

    local todir=$2
    if [ ! -d $todir ]
    then
        echo "to dir do not exist. $todir <moveandlink>"
        return
    fi
    
    if [ -e $todir"/"$fromname ] && [ -L $todir"/"$fromname ]
    then
        echo "dest file has exist, delete it. $todir"/"$fromname <moveandlink>"
        rm $todir"/"$fromname
    fi

    mv $frompath $todir
    ln -s $todir"/"$fromname $frompath
}

moveandlinkchildwithoutlib(){
    local fromdir=$1
    if [ ! -d $fromdir ]
    then
        echo "from dir do not exist. $fromdir <moveandlinkchildwithoutlib>"
        return
    fi

    local todir=$2
    if [ ! -d $todir ]
    then
        echo "to dir do not exist. $todir <moveandlinkchildwithoutlib>"
        return
    fi

    local fromdirname=`basename $fromdir`
    local finaltodir=$todir"/"$fromdirname

    if [ ! -e $finaltodir ]
    then
        mkdir $finaltodir
    fi

    local file
    for file in ` ls $fromdir `
    do
        if [ $file == "lib" ]
        then
            continue
        fi 
        
        if [ -L $fromdir"/"$file ]
        then
            continue
        fi
        
        moveandlink $fromdir"/"$file $finaltodir
    done
}

#moveandlink /home/dongzhiquan/a /home/dongzhiquan/b

haslibinfolder(){
    local folder="$1"
    local file
    for file in ` ls $folder `
    do
        if [ "$file" != "lib" ]
        then
            continue
        fi
        
        if [ ! -d $folder"/"$file ]
        then
            continue
        fi
        
        if [ "`ls $folder/$file`" = "" ]
        then
            continue
        fi
        return 1
    done
    
    return 0
}

link(){
    local basefolder=$1
    local destfolder=$2
    
    for file in ` ls $basefolder `
    do
        local childfile=$basefolder"/"$file
        
        if [ ! -d $childfile ]
        then
            echo "not folder. $childfile <link>"
            continue
        fi
        
        if [ -L $childfile ]
        then
            echo "been linked. $childfile <link>"
            continue
        fi 
        
        isdataapp $file
        local ret=$?
        if [ $ret -eq 0 ]
        then
            echo "not data app. $childfile <link>"
            continue
        fi
        
        haslibinfolder $childfile
        ret=$?
        if [ $ret -eq 0 ]
        then
            moveandlink $childfile $destfolder
            echo "linked. $childfile <link>"
        else
            moveandlinkchildwithoutlib $childfile $destfolder
            echo "child linked. $childfile <link>"
        fi
    done
}
link $datadatafolder $sdext2datafolder

 

换MT887后的自动mount脚本

 

 

moveandmount(){
    local frompath=$1
    if [ ! -d $frompath ]
    then
        echo "from file do not exist or is link. $frompath <moveandmount>"
        return
    fi

    umount $frompath

    local fromname=`basename $frompath`

    local todir=/home2/dongzhiquan/b
    if [ ! -d $todir ]
    then
        echo "to dir do not exist. $todir <moveandmount>"
        return
    fi

    if [ ! -e $todir"/"$fromname ]
    then
        echo "dest file not exist, make it. $todir"/"$fromname <moveandmount>"
        mkdir $todir"/"$fromname
        if [ $? -ne 0 ]
        then
            echo "mkdir failed. $todir"/"$fromname <moveandmount>"
            return
        fi
    fi

    mv -f $frompath/* $todir"/"$fromname/
    if [ $(ls -A $frompath/ | wc -w) -ne 0 ]
    then
        echo "move failed. $frompath/* $todir"/"$fromname/ <moveandmount>"
        return
    fi
    mount -o bind $todir"/"$fromname $frompath
    if [ $? -ne 0 ]
    then
        echo "mount failed. <moveandmount>"
        return
    fi
}

moveandmount /home2/dongzhiquan/a