Monday, May 16, 2011

Free some space on phone's memory without DATA2EXT

Although there is a2sd, that keeps the apks on the sd-ext some files are stored on phone's nand on /data partition and if we install alot of apk's then you remain out of free space. WE DO ALL THIS WITH PHONE ON, NOT IN RECOVERY
1st let's see how much free space i'm having:


df -h | grep data

/dev/block/mtdblock5 147.6M 76.7M 70.9M 52% /data  

As you can see i have left about 70 mB free. Lets see what folders eat my space:



#
du -sk /data/data/* | sort -rn | head
18641 /data/data/com.navngo.igo.javaclient
14911 /data/data/com.opera.browser
6756 /data/data/com.google.android.gm
5194 /data/data/com.android.providers.contacts
3661 /data/data/com.htc.launcher
3083 /data/data/com.htc.googlereader
1276 /data/data/com.swype.android.inputmethod
1172 /data/data/com.android.settings
1144 /data/data/com.htc.android.mail
1084 /data/data/and.blogger

Ok so it seems that iGO and Opera is eating 32 megs together. I'll leave data/data/com.google.android.gm alone since it's gmail and I want to be more responsive by keeping its files to nand(i only have a class 4 card). Lets get to work. 1st we need to make a folder on sd-ext where to keep the files. 

#
mkdir /system/sd/.moreapps  


I made the folder .moreapps. Now let's move stuff and symlink them.
First we move them:


mv /data/data/com.navngo.igo.javaclient /system/sd/.moreapps/com.navngo.igo.javaclient



Then we symlink them:


#
ln -s /system/sd/.moreapps/com.navngo.igo.javaclient /data/data/com.navngo.igo.javaclient



Now we repeat the operation for opera:
Move:


#
mv /data/data/com.opera.browser /system/sd/.moreapps/com.opera.browser  


Symlink:


ln -s /system/sd/.moreapps/com.opera.browser /data/data/com.opera.browser  

Now let's check again my free space. 


#
df -h | grep data

/dev/block/mtdblock5 147.6M 51.8M 95.9M 35% /data 

Well it seems to me I gained 35 mB without uninstalling apps, without moving ALL of them to SD and experience some lags. 

Now let's check if we made the symlinking right


#
ls -al --color=none /data/data/com.opera.browser

lrwxrwxrwx 1 0 0 38 Feb 22 05:46 /data/data/com.opera.browser -> /system/sd/.moreapps/com.opera.browser  



Yap all seems right. Opera and iGO are working at same speed, i freed up some space. Everyone's happy.
The advantage of this method is that you can choose what to move to sd-ext you don't have to have all to sd-ext. 
Now make sure you don't name your folder in /system/sd "data" since a2sd script will move back on nand all its contents. 
This method is recommend for GPS software, Browsers, Games, some apps you got from market. It's best to  leave system apps there to avoid FCs or slowdowns. If anything goes wrong with your app after this you can always move them back.
1st you delete the symlink (rm /data/data/whatevar) then move it back

12 comments:

  1. Thank you mate!!!

    You're really doing very good work with all that stuff!! ;) Congratulations!!!

    ReplyDelete
  2. hi,
    im sorry to sound noob but could you how you do it?i mean is it in ADB?or terminal emulator?and how do you input | ? and last question is what would happen if i decide to backup those applications say with my backup pro/or my backup root? would they backup and restore as normal or should i undo everything and then backup.
    thanks as it looks like great method to free up some space is just sad that i dont know how its done :)

    ReplyDelete
  3. hello,

    I got the following error when creating the moreapps folder:

    ¨can't create directory '/system/sd/.moreapps': Read-only file system¨

    how can this be solved?

    ReplyDelete
  4. ...and I got

    failed on '/data/data/com.navngo.igo.javaclient' - Cross-device link

    ReplyDelete
  5. hi,

    after i did cmd "du -sk /data/data/* | sort -rn | head"

    i got error "sort: standard output: broken pipe"

    any ideas?

    ReplyDelete
  6. @giedrius you start by writing in cmd the path starting with cd C:\blabla where balbla = tools folder and then type adb shell; thats it

    ReplyDelete
  7. Amazing!
    I might not have to buy the SG2 just yet ;)

    ReplyDelete
  8. 1) It will be much easier to go into recovery.
    2) # mv /data/data to /sd-ext/data
    (can only be done in recovery - i.e. when phone is "off")
    3) # ln -s /sd-ext/data /data/data

    Cheers,
    fusionstream.

    ReplyDelete
  9. Sry. Forgot to add:
    Between steps 1 and 2
    1.1) In clockworkmod, mount all the necessary partitions (I usually mount them all just in case)
    1.2) In clockworkmod, restart adb
    1.3) Connect phone to pc via usb
    1.4) In your cmd prompt, type "adb shell" to connect to your phone.

    ReplyDelete
  10. thanks again baadnws, i use this method every time i flash a new rom... it's great.
    but to avoid typos and generally to speed up things i do it this way:
    example, i want to move facebook data (/data/data/com.facebook.katana), in shell I do:

    for i in com.facebook.katana ; do mv /data/data/$i /system/sd/.moreapps/$i && ln -s /system/sd/.moreapps/$i /data/data/$i ; done

    where every "$i" assumes the value i put in the first part, in this case "com.facebook.katana"
    then to move another app's data i just have to change that part and the script will do the rest.. :D
    i hope this can be useful to someone!
    cheers

    ReplyDelete
  11. Sometimes when I try doing this after flashing a new rom it says-
    "mv /data/data/com.adobe.air /system/sd/.moreapps/com.adobe.air

    mv: can't rename '/data/data/com.adobe.air': No such file or directory"

    I keep having to reinstall the apps it says this at, any suggestions?

    ReplyDelete
  12. I noticed that when you typed:
    ls -al --color=none /data/data/com.opera.browser

    you had the following permissions lrwxrwxrwx 1 0 0

    I have 1 root root...
    How do I change that? The application force closes now and I had to remove the link and the folder, but that takes me to square 1

    ReplyDelete