Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,804,760 Members 47,963 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
zach.xtr
Old
(Last edited by zach.xtr; 22nd February 2011 at 03:02 AM.)
#1  
zach.xtr's Avatar
Senior Member - OP
Thanks Meter 73
Posts: 939
Join Date: Apr 2010
Location: Tallahassee, FL
Default [SCRIPT][1/22/2011] A Simple Cache2Cache for CM 6.x and 7.x ROMs

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, 5841 views)
AT&T Samsung Rugby Pro rooted

ARCHIVE WORK
------------------------------------------------------------------------------------------------------------------------
HTC Eris - VanillaASOP - xtrROM - xtrSENSE
The Following 15 Users Say Thank You to zach.xtr For This Useful Post: [ Click to Expand ]
 
korben dallas
Old
#2  
Senior Member
Thanks Meter 2
Posts: 229
Join Date: Mar 2010
awesome i will try this now
 
doogald
Old
(Last edited by doogald; 22nd January 2011 at 02:54 PM.)
#3  
Senior Member
Thanks Meter 312
Posts: 1,303
Join Date: 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.]
 
zach.xtr
Old
#4  
zach.xtr's Avatar
Senior Member - OP
Thanks Meter 73
Posts: 939
Join Date: Apr 2010
Location: Tallahassee, FL
Quote:
Originally Posted by korben dallas View Post
awesome i will try this now
Success?

Sent from my ERIS using XDA App
AT&T Samsung Rugby Pro rooted

ARCHIVE WORK
------------------------------------------------------------------------------------------------------------------------
HTC Eris - VanillaASOP - xtrROM - xtrSENSE
 
kkpsichologist
Old
#5  
Member
Thanks Meter 7
Posts: 46
Join Date: Jun 2010
Location: Virginia or Tennessee (depends on the day)
Flash success on floyo 5.0. Gave e another 25 or so MB. Great work!!

Sent from my Floyo using XDA App
 
smileythom
Old
#6  
Junior Member
Thanks Meter 0
Posts: 14
Join Date: Jul 2010
Location: Arroyo Grande, CA
Thank you! Works great on my CELB4.2 . Gained an extra 25MB.

Sent from my ERIS using XDA App
 
galbro
Old
#7  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Feb 2010
Nicely done. Nonsensikal 16.1 went from 17 or 18 megs free to 67 megs. Working fine so far..
 
Hungry Man
Old
#8  
Senior Member
Thanks Meter 36
Posts: 2,105
Join Date: 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?
blah blah signature
 
galbro
Old
#9  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: 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.
 
zach.xtr
Old
#10  
zach.xtr's Avatar
Senior Member - OP
Thanks Meter 73
Posts: 939
Join Date: Apr 2010
Location: Tallahassee, FL
Quote:
Originally Posted by Hungry Man View Post
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...
AT&T Samsung Rugby Pro rooted

ARCHIVE WORK
------------------------------------------------------------------------------------------------------------------------
HTC Eris - VanillaASOP - xtrROM - xtrSENSE

The Following User Says Thank You to zach.xtr For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes