Post Reply

[SCRIPT][1/22/2011] A Simple Cache2Cache for CM 6.x and 7.x ROMs

OP zach.xtr

22nd January 2011, 02:24 PM   |  #1  
zach.xtr's Avatar
OP Senior Member
Flag Tallahassee, FL
Thanks Meter: 73
 
939 posts
Join Date:Joined: Apr 2010
More
Due to a number of requests I have built a flashable .zip that will install a simple cache2cache script for CyanogenMod 6.x and 7.x ROMs.

NAND backup BEFORE you try this!

From user feedback it seems that if you are ALREADY running Apps2sd this causes issues with apps that where installed to the SD card and you will have to remove and re download them. There have been no reports of issues if you flash PRIOR to enabling Apps2sd ...


Per dingermtb: check out post http://forum.xda-developers.com/show...6&postcount=58 for an easy fix for Apps2sd.

By using this script the dalvik-cache has been relocated from the internal /data/dalvik-cache/ directory to the internal /cache/dalvik-cache directory. The Eris comes with an internal /cache/ file block of 130mb that is not used much (CyanogenMod does store the cache of system apps in the /cache file block but NOT any apps that are downloaded from the market)! So by moving the dalvik-cache to this free area you now have more space on internal /data/ for apps and over 75mb in internal /cache/ for dalvik-cache. This means that you can probably install close to 75-100 apps WITHOUT having to worry about apps2sd!

This IS NOT a Custom MTD script as I wanted to keep it simple. This solution is not as "ideal" as a Custom MTD scripts work but it is a bit easier, safer, and simpler... Plus it works

How do I know it worked?
So why does my Settings>SD card & phone storage>Internal phone storage only show 150mb or less? This is because this number ONLY reflects the /data/ file block on your phone and does not "see" the /cache/ block that is now being used for dalvik-cache storage.

From adb or Terminal Emulator (you can get it free from the market if your ROM does not already have it) run the follow command:

Code:
df -h
You will see that your /cache partition now is more used and that your /data partition is less used.

Also you can browse to the /cache/dalvik-cache/ folder using your favorite file explorer and see that you now have files starting with "data@..." and not just "system@..."

What does it do?
Since CyanogenMod already uses an init.d framework that runs during boot on his ROMs it was easy to add a new shell script that would automatically run with the other boot scripts in the /system/etc/init.d/ folder.

This simply adds the following 07cache2cache file to /system/etc/init.d/

Code:
# !/system/bin/sh
#
# Author: zach.xtr Jan 2011
# Moves the /data/dalvik-cache files to largely unused /cache/dalvik-cache location and symlinks
# This code is intended for the ERIS, use on other phones may not work due to predefined file block sizes...

log -p i -t cache2cache "Running cache2cache to move data/dalvik-cache to cache/dalvik-cache..."; 

# Mount filesystem
/system/xbin/busybox mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system

# Make sure final /cache/ location is setup correctly
if [ ! -d /cache/dalvik-cache ];
then
	log -p i -t cache2cache "/cache/dalvik-cache directory not found, creating and adding permissions..."; 
	/system/xbin/busybox mkdir /cache/dalvik-cache;
	/system/xbin/busybox chown 1000:1000 /cache/dalvik-cache;
	/system/xbin/busybox chmod 777 /cache/dalvik-cache
fi;

if [ -d /data/dalvik-cache ] && [ ! -h /data/dalvik-cache ];
then
	log -p i -t cache2cache "Moving files from /data/dalvik-cache to /cache/dalvik-cache"; 
	/system/xbin/busybox cp -fp /data/dalvik-cache/* /cache/dalvik-cache;
	/system/xbin/busybox rm -r /data/dalvik-cache;
	log -p i -t cache2cache "Creating Symbolic Link of /cache/dalvik-cache as /data/dalvik-cache";
	/system/xbin/busybox ln -s /cache/dalvik-cache /data/dalvik-cache;
	/system/xbin/busybox chown 1000:1000 /data/dalvik-cache
	/system/xbin/busybox chmod 0771 /data/dalvik-cache
fi;

# Clean up 
/system/xbin/busybox mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
How do I remove it?
Since it only adds 1 file all you need to do is delete the /system/etc/init.d/07cache2cache file and reboot your phone. One could use adb or RootExplorer (or similar) file manager.

NOTE: if you have been using this for a while and have installed enough apps and THEN remove it I am not sure what will happen when you reboot... Basically you may not have enough space in the /data file block alone.
Attached Files
File Type: zip xtrCMCache2cache.zip - [Click for QR Code] (259.1 KB, 5845 views)
Last edited by zach.xtr; 22nd February 2011 at 03:02 AM.
The Following 15 Users Say Thank You to zach.xtr For This Useful Post: [ View ]
22nd January 2011, 02:27 PM   |  #2  
Senior Member
Thanks Meter: 2
 
229 posts
Join Date:Joined: Mar 2010
awesome i will try this now
22nd January 2011, 02:36 PM   |  #3  
Senior Member
Thanks Meter: 321
 
1,328 posts
Join Date:Joined: May 2010
Oh my gosh, bless you! This is great.

Downloading and installing onto CELB 4.3 right now...

[edit - Reported phone storage remaining went from 28 MB to 70 MB free. It did restart my phone on the first restart; I'm not sure if that's normal, but things seem to be working fine.]
Last edited by doogald; 22nd January 2011 at 02:54 PM.
22nd January 2011, 03:43 PM   |  #4  
zach.xtr's Avatar
OP Senior Member
Flag Tallahassee, FL
Thanks Meter: 73
 
939 posts
Join Date:Joined: Apr 2010
More
Quote:
Originally Posted by korben dallas

awesome i will try this now

Success?

Sent from my ERIS using XDA App
22nd January 2011, 04:01 PM   |  #5  
Member
Flag Virginia or Tennessee (depends on the day)
Thanks Meter: 7
 
46 posts
Join Date:Joined: Jun 2010
More
Flash success on floyo 5.0. Gave e another 25 or so MB. Great work!!

Sent from my Floyo using XDA App
22nd January 2011, 04:25 PM   |  #6  
Junior Member
Arroyo Grande, CA
Thanks Meter: 0
 
14 posts
Join Date:Joined: Jul 2010
More
Thank you! Works great on my CELB4.2 . Gained an extra 25MB.

Sent from my ERIS using XDA App
22nd January 2011, 04:28 PM   |  #7  
Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Feb 2010
Nicely done. Nonsensikal 16.1 went from 17 or 18 megs free to 67 megs. Working fine so far..
22nd January 2011, 04:29 PM   |  #8  
Senior Member
Thanks Meter: 36
 
2,105 posts
Join Date:Joined: Jun 2010
Pretty cool. I'm never low on space so I won't need this, but thanks for creating it.

Is it possible for this to cause apps to slow down, since when they try to access the cache it'll be on the (slower) SD card?
22nd January 2011, 04:40 PM   |  #9  
Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Feb 2010
However, app2sd is now a little confused, and the apps it thinks are on the sd card cannot be found when I try to move them back to the phone. However, they are operable.
22nd January 2011, 05:28 PM   |  #10  
zach.xtr's Avatar
OP Senior Member
Flag Tallahassee, FL
Thanks Meter: 73
 
939 posts
Join Date:Joined: Apr 2010
More
Quote:
Originally Posted by Hungry Man

Pretty cool. I'm never low on space so I won't need this, but thanks for creating it.

Is it possible for this to cause apps to slow down, since when they try to access the cache it'll be on the (slower) SD card?

No

This does not use the SD card in any way; it only redistributes from the INTERNAL /data file block to the INTERNAL /cache file block...

If anything you may gaine a minor permormance improvement as you will have more "working" space...

The Following User Says Thank You to zach.xtr For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes