[MOD] [GUIDE] Save /data space and use that /cache partition!

Search This thread

Bert98

Senior Member
Jul 24, 2012
1,093
393
23
Padova
Moto G
Redmi K20 / Xiaomi Mi 9T
LINK TO THE THREAD WITH THE AUTOMATED SCRIPT (thanks to @skyguy126): http://forum.xda-developers.com/moto-g/general/mod-storage-reloacting-dalvik-cache-t2953616

Hello everybody

as you may know, our Moto G's internal eMMC card has a ~600Mb partition called /cache, which is not used since the apps' cache is stored in /data, so the latter fills up and the first one stays empty.

Owning a 8Gb model, having 600Mb not available for storage really bugged me, because my phone's memory (/data partition) was always full because it's a 5.7Gb space shared between apps and microSD files.

Well, thanks to @skyguy126, who linked me to this guide, I managed to link the dalvik cache files to the /cache partition :D

Now, it may not work for you if:
a) you have A LOT of apps installed.
And by "a lot", I mean more than 90-100 apps, but if you have a 8Gb model, you probably don't :laugh:

b) you're running ART
Since ART uses a lot more space than dalvik, the space in the /cache partition probably won't be enough. When I was running ART, it used 1Gb more than dalvik.​

Other than that, all you need is a rooted phone, the Terminal Emulator app installed (HERE), a root file manager, at least one hand and a working brain :D

I TAKE NO RESPONSIBILITY FOR ANY DAMAGE THAT HAPPENS TO YOUR PHONE, CONTINUE AT YOUR OWN RISK.

Steps:
1) Open any text editor, messaging app, notes app or anything that allows a text input. write the following line, select it and copy it to your clipboard (you'll need it later).
Code:
ln -s /cache/dalvik-cache /data/dalvik-cache
Also, make sure you open the Terminal Emulator app and type in "su" (without quotes), then grant it superuser access. You'll need to switch to it quickly.

2) Open your root file manager, while making sure you still see the terminal emulator's notification (I used Root Explorer but any other app should work just fine), go to /data, select the /dalvik-cache folder (just to be sure, hit "properties" to check its size. If it's less than 600Mb you're good to go. If it's not, this won't work, sorry) and move (NOT copy, MOVE) it to /cache. If it asks you to merge two folders, do it.

NOTE: now some apps may start force closing, it's normal, keep going

3) Switch to the Terminal Emulator app (via the recents screen or by tapping its notification" and paste the text you copied at the beginning by long-pressing the black screen and hitting "Paste" (DUH?!?:eek:), hit enter, make sure no error messages come up, then reboot.

TA-DAAAA!

Your dalvik cache is now linked to the /cache partition, enjoy that half a gigabyte :cool:

If you need any help, feel free to PM me :)

"But Bert, what if it doesn't work and my phone explodes?"

Well, if it blows up there's nothing much I can do, but if it's just stuck at bootanimation/bootlogo/somewhere where you can't use it, simply head to the recovery and wipe dalvik-cache. This will revert the process and delete the link, putting the phone as it was before :)
 
Last edited:

skyguy126

Senior Member
Sep 17, 2014
454
110
github.com
Batch File to Automate the Process!!! :D

Look at reply #58 for latest information


Old:
Batch file complete, credit goes to @Bert98 for devising a method.

USE THIS COMPLETELY AT YOUR OWN RISK! You may NOT rehost, take credit, or make a paid download without the permission of @skyguy126 or @Bert98

This will only work on windows based computers!
I tested this on my moto g xt1032 16GB running CM11 Nightly and it worked fine.

Click that thanks button if it helped! :D

How to use:
Step 1: Download the attached file and extract.
Step 2: Double click the cachemove.rbat file and follow the onscreen instructions.

EDIT: THIS IS NOT WORKING ON MOTO G STOCK 4.4.4!!!
I am working on this issue but any help is greatly appreciated!

Common errors:
"adbd root cannot run as root in production builds"
Solution: http://forum.xda-developers.com/showthread.php?t=1687590
Install the app and run it. Enable insecure binary.

Changelog:
v1.1 - Fixed some minor bugs in script.
v1.2 - Added a restore script.


 
Last edited:
  • Like
Reactions: Chris Kurisu

KahosTch

Member
Nov 25, 2012
34
5
Hello everybody

as you may know, our Moto G's internal eMMC card has a ~600Mb partition called /cache, which is not used since the apps' cache is stored in /data, so the latter fills up and the first one stays empty.

Owning a 8Gb model, having 600Mb not available for storage really bugged me, because my phone's memory (/data partition) was always full because it's a 5.7Gb space shared between apps and microSD files.

Well, thanks to @skyguy126, who linked me to this guide, I managed to link the dalvik cache files to the /cache partition :D

Now, it may not work for you if:
a) you have A LOT of apps installed.
And by "a lot", I mean more than 90-100 apps, but if you have a 8Gb model, you probably don't :laugh:

b) you're running ART
Since ART uses a lot more space than dalvik, the space in the /cache partition probably won't be enough. When I was running ART, it used 1Gb more than dalvik.​

Other than that, all you need is a rooted phone, the Terminal Emulator app installed (HERE), a root file manager, at least one hand and a working brain :D

I TAKE NO RESPONSIBILITY FOR ANY DAMAGE THAT HAPPENS TO YOUR PHONE, CONTINUE AT YOUR OWN RISK.

Steps:
1) Open any text editor, messaging app, notes app or anything that allows a text input. write the following line, select it and copy it to your clipboard (you'll need it later).
Code:
ln -s /cache/dalvik-cache /data/dalvik-cache
Also, make sure you open the Terminal Emulator app and type in "su" (without quotes), then grant it superuser access. You'll need to switch to it quickly.

2) Open your root file manager, while making sure you still see the terminal emulator's notification (I used Root Explorer but any other app should work just fine), go to /data, select the /dalvik-cache folder (just to be sure, hit "properties" to check its size. If it's less than 600Mb you're good to go. If it's not, this won't work, sorry) and move (NOT copy, MOVE) it to /cache. If it asks you to merge two folders, do it.

NOTE: now some apps may start force closing, it's normal, keep going

3) Switch to the Terminal Emulator app (via the recents screen or by tapping its notification" and paste the text you copied at the beginning by long-pressing the black screen and hitting "Paste" (DUH?!?:eek:), hit enter, make sure no error messages come up, then reboot.

TA-DAAAA!

Your dalvik cache is now linked to the /cache partition, enjoy that half a gigabyte :cool:

If you need any help, feel free to PM me :)

Hello! Thnk you for the tip, but, with me, i think, didnt work.
Im stuck in the boot, can you helpme to restore the directories? BTW, i have folloed all the steps like you say, i dont know why not work, im using CRom

Greetings!
 
  • Like
Reactions: Bert98

fabus

Senior Member
Nov 12, 2013
188
68
Wroclaw
Hello! Thnk you for the tip, but, with me, i think, didnt work.
Im stuck in the boot, can you helpme to restore the directories? BTW, i have folloed all the steps like you say, i dont know why not work, im using CRom

Greetings!
To get it working just wipe dalvik cache in cwm, it will re-create directory in /data.

I had the same issue..

I will try to investigate what went wrong with this....
 

fabus

Senior Member
Nov 12, 2013
188
68
Wroclaw
I have found an issue. When you are copying /data/dalvik-cache to /cache/dalvik cache permissions can be mismatched (different partition type).

To fix it just:
- Go to CWM
- Connect phone to PC (should be recongnized as ADB device, if not check in Hardware Manager how it was recongizes)
- issue "ADB shell" command
- in Android shell: chmod 644 /cache/dalvik-cache/*
- reboot and you are done :)

I have made up an easier way to achive dalvik-cache on /cache partition:

On running android:
- make sure /cache/dalvik-cache folder is empty!!
- Rename /data/dalvik-cache to /data/dalvik-cache2
- ln -s /cache/dalvik-cache /data/dalvik-cache
- reboot and done :)

Android will recreate dalvik cache in /cache/dalvik-cache dir, it will take about 10 minutes, so be patient :)

if something goes wrong, just rename /data/dalvik-cache2 by ADB (e.g. in CWM)

I hope if was helpfull.

Cheers,
 

AndroidHtc101

Senior Member
Apr 8, 2013
358
131
Guys could some experts code a batch file for this?
I appreciate the guide but terminal codes etc are beyond me.....
600mb is quite a lot of space to gain for an 8gig moto g:)

Sent from my XT1032 using XDA Free mobile app
 

dethrat

Senior Member
Jan 2, 2012
410
99
Guys could some experts code a batch file for this?
I appreciate the guide but terminal codes etc are beyond me.....
600mb is quite a lot of space to gain for an 8gig moto g:)

Sent from my XT1032 using XDA Free mobile app
It's up to 600mb. It's what ever size your dalvik cache is. I don't think this will work on android 5.0 since the change to art.
 

AndroidHtc101

Senior Member
Apr 8, 2013
358
131
Skyguy

I have around 125apps and 500mb free, would installing the batch screw my phone up?

Thanks for helping :)

Sent from my XT1032 using XDA Free mobile app
 

AndroidHtc101

Senior Member
Apr 8, 2013
358
131
Hi Bert

It's 466.92mb

If I could get 500mb of more free space I would have a gig free which would really help my 8gb moto g:)

Sent from my XT1032 using XDA Free mobile app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 21
    LINK TO THE THREAD WITH THE AUTOMATED SCRIPT (thanks to @skyguy126): http://forum.xda-developers.com/moto-g/general/mod-storage-reloacting-dalvik-cache-t2953616

    Hello everybody

    as you may know, our Moto G's internal eMMC card has a ~600Mb partition called /cache, which is not used since the apps' cache is stored in /data, so the latter fills up and the first one stays empty.

    Owning a 8Gb model, having 600Mb not available for storage really bugged me, because my phone's memory (/data partition) was always full because it's a 5.7Gb space shared between apps and microSD files.

    Well, thanks to @skyguy126, who linked me to this guide, I managed to link the dalvik cache files to the /cache partition :D

    Now, it may not work for you if:
    a) you have A LOT of apps installed.
    And by "a lot", I mean more than 90-100 apps, but if you have a 8Gb model, you probably don't :laugh:

    b) you're running ART
    Since ART uses a lot more space than dalvik, the space in the /cache partition probably won't be enough. When I was running ART, it used 1Gb more than dalvik.​

    Other than that, all you need is a rooted phone, the Terminal Emulator app installed (HERE), a root file manager, at least one hand and a working brain :D

    I TAKE NO RESPONSIBILITY FOR ANY DAMAGE THAT HAPPENS TO YOUR PHONE, CONTINUE AT YOUR OWN RISK.

    Steps:
    1) Open any text editor, messaging app, notes app or anything that allows a text input. write the following line, select it and copy it to your clipboard (you'll need it later).
    Code:
    ln -s /cache/dalvik-cache /data/dalvik-cache
    Also, make sure you open the Terminal Emulator app and type in "su" (without quotes), then grant it superuser access. You'll need to switch to it quickly.

    2) Open your root file manager, while making sure you still see the terminal emulator's notification (I used Root Explorer but any other app should work just fine), go to /data, select the /dalvik-cache folder (just to be sure, hit "properties" to check its size. If it's less than 600Mb you're good to go. If it's not, this won't work, sorry) and move (NOT copy, MOVE) it to /cache. If it asks you to merge two folders, do it.

    NOTE: now some apps may start force closing, it's normal, keep going

    3) Switch to the Terminal Emulator app (via the recents screen or by tapping its notification" and paste the text you copied at the beginning by long-pressing the black screen and hitting "Paste" (DUH?!?:eek:), hit enter, make sure no error messages come up, then reboot.

    TA-DAAAA!

    Your dalvik cache is now linked to the /cache partition, enjoy that half a gigabyte :cool:

    If you need any help, feel free to PM me :)

    "But Bert, what if it doesn't work and my phone explodes?"

    Well, if it blows up there's nothing much I can do, but if it's just stuck at bootanimation/bootlogo/somewhere where you can't use it, simply head to the recovery and wipe dalvik-cache. This will revert the process and delete the link, putting the phone as it was before :)
    4
    I have found an issue. When you are copying /data/dalvik-cache to /cache/dalvik cache permissions can be mismatched (different partition type).

    To fix it just:
    - Go to CWM
    - Connect phone to PC (should be recongnized as ADB device, if not check in Hardware Manager how it was recongizes)
    - issue "ADB shell" command
    - in Android shell: chmod 644 /cache/dalvik-cache/*
    - reboot and you are done :)

    I have made up an easier way to achive dalvik-cache on /cache partition:

    On running android:
    - make sure /cache/dalvik-cache folder is empty!!
    - Rename /data/dalvik-cache to /data/dalvik-cache2
    - ln -s /cache/dalvik-cache /data/dalvik-cache
    - reboot and done :)

    Android will recreate dalvik cache in /cache/dalvik-cache dir, it will take about 10 minutes, so be patient :)

    if something goes wrong, just rename /data/dalvik-cache2 by ADB (e.g. in CWM)

    I hope if was helpfull.

    Cheers,
    3
    I had a different device, and actually tried this sometimes ago. Didn't remember exactly which device but upon reboot, /cache will be emptied so its useless.

    Anyway if it can work for anyone, things you might want to do in Terminal Emulator:

    Code:
    su
    busybox df -h /cache
    busybox du -h /data/dalvik-cache

    If free space permits then:

    Code:
    su
    mkdir /cache/dalvik-cache
    busybox chown 1000.1000 /cache/dalvik-cache
    busybox chmod 771 /cache/dalvik-cache
    busybox cp -a /data/dalvik-cache/* /cache/dalvik-cache/
    mv /data/dalvik-cache /data/dalvik-cache-bak
    ln -s /cache/dalvik-cache /data/dalvik-cache
    sync

    Now reboot and if its working, you can delete dalvik-cache-bak. If you're low on space you'll have to rm instead of mv anyway, because if this fails, you'll be out of space because the old dalvik is still there and thr system didn't have enough space to recreate a new one.

    From what I read in the posts, there're some missing steps in the commands to properly maintaining permissions, leading to failure. This didn't work for me last time anyway (as I stated above) but it might work for your device, ymmv.

    Note that I used busybox instead of internal command for some, because on some ROMs its broken but not busybox's.

    Hope this helps someone.

    ---------- Post added at 04:45 AM ---------- Previous post was at 04:27 AM ----------

    Symlinking the dalvik cache could conflict with application processed and cause crashes, missing icons etc..
    Same as symlinking /data/app to /sdcard/apps2sd

    Yes, only if sdcard is fat or fuse, but no problems if its f2fs or ext2/3/4 (best thing to do is to use exact fs for the partition which you're replacing/mirroring etc). Technically its all about permissions. I'm speaking of experience, which worked for me. YMMV.

    It's the same case with /data/data/hosts case, its not Linux or Android but rather OEM or SELinux doing its things.
    2
    Hello! Thnk you for the tip, but, with me, i think, didnt work.
    Im stuck in the boot, can you helpme to restore the directories? BTW, i have folloed all the steps like you say, i dont know why not work, im using CRom

    Greetings!
    To get it working just wipe dalvik cache in cwm, it will re-create directory in /data.

    I had the same issue..

    I will try to investigate what went wrong with this....
    1
    Batch File to Automate the Process!!! :D

    Look at reply #58 for latest information


    Old:
    Batch file complete, credit goes to @Bert98 for devising a method.

    USE THIS COMPLETELY AT YOUR OWN RISK! You may NOT rehost, take credit, or make a paid download without the permission of @skyguy126 or @Bert98

    This will only work on windows based computers!
    I tested this on my moto g xt1032 16GB running CM11 Nightly and it worked fine.

    Click that thanks button if it helped! :D

    How to use:
    Step 1: Download the attached file and extract.
    Step 2: Double click the cachemove.rbat file and follow the onscreen instructions.

    EDIT: THIS IS NOT WORKING ON MOTO G STOCK 4.4.4!!!
    I am working on this issue but any help is greatly appreciated!

    Common errors:
    "adbd root cannot run as root in production builds"
    Solution: http://forum.xda-developers.com/showthread.php?t=1687590
    Install the app and run it. Enable insecure binary.

    Changelog:
    v1.1 - Fixed some minor bugs in script.
    v1.2 - Added a restore script.