Moving data and dalvik-cache to sd card to fix market issues

acromack

Well-known member
Jan 10, 2011
300
49
0
Visit site
So if you've installed a custom rom, and you have a ton of apps, you may have noticed market errors when downloading new apps or updating existing ones. These can say either insufficient space on device or invalid package file. The reason for this is because although you may have plenty of extra space in your /data/ partition for all the apps you have, your /cache/ partition is likely full. Most custom roms have also moved the dalvik-cache from /data/ over into /cache/ to make more room for apps. The problem with this is that the /cache/ partition will most likely fill up before your /data/ partition does, which is what causes the market download/install errors. The easiest way to fix this is to just uninstall a bunch of apps, then wipe your cache to rebuild the list, and that will likely get you the space you need. But if you want a more long-term solution, this mod is for you.

I have completed this successfully and tested to be working flawlessly on Drew's latest CM7 build, but it should work for all other CM7 builds. I can't say for sure about froyo roms, but if you want to try, then by all means go for it. Standard disclaimer: I am not responsible for any damages that may occur to your phone as a result of you attempting the following procedure. As always, make a nandroid backup and backup your entire sd card, in case anything does go wrong.

Before you start, you NEED an sd card of the VERY least class 4 or above. I'd recommend even higher - have a class 10 4 gb card that works perfectly. The stock card that comes with the Optimus S will not work - it's pretty much junk. Invest in a better one - you won't be sorry.


  1. Your phone should be rooted, which is a moot point since you're already running a custom rom.
  2. Backup all your apps using titanium or similar.
  3. (Optional) Start off by rebooting into recovery. To verify that you need this, plug your phone into your computer and fire up a command prompt or terminal window. Go into mounts and go ahead and see that all partitions are mounted. Then enter the following:
    Code:
    adb shell
    df
    That will give you an overview of all mounted partitions and their capacities. You will likely see that /cache/ is very close to 100%. If it's not, then stop here. You're imagining your problems :p
  4. Assuming everything is backed up, boot back up and remove all user apps. I used titanium to do this. This may not actually be necessary, but I wasn't able to boot up and complete this mod without doing it - probably too much for it to handle... So I recommend it.
  5. At this point, you need to reboot into recovery. We need to create the partition on the sd card for things to be moved to. DO A NANDROID BACKUP FIRST BEFORE ANYTHING!!! With xionia clockwork, go through the prompts to partition sd card (under mounts and storage? Sorry, I can't remember right now, lol). I got by fine with a 512mb partition, and the default swap size. You could also do this with any other partition program on your computer, but this is just easier.
  6. While in recovery, go to mounts, and make sure /system/ and /cache/ are mounted. In a command prompt or terminal window, type:
    Code:
    adb shell
    rm /system/etc/init.d/01mvdalvik
    rm -r /cache/dalvik-cache/
    This will remove the script that's baked into CM7 that runs on boot which essentially moves dalvik-cache to /cache/ partition, which is the root of our problems. It also removes the dalvik-cache in /cache/, which will be rebuilt in /data/ upon reboot.
  7. Boot back up and make sure everything is okay. It might take a bit longer to boot, since dalvik-cache has to be rebuilt in the default /data/ location. Once back up, go to market and install Simple2ext (S2E). This gives us a GUI for installing a new script so we don't have to do as much adb trickery. Since partitioning the sd card in recovery only makes an ext-3 partition, we need to go into the settings for this app and check the box for 'mount as ext-4' since this is how CM7 reads ext partitions. It should still work fine, don't worry just yet. Once that is checked, go back to the main app, and check the box to move dalvik-cache. You might as well check the box to move app data and download cache as well, since I did that and with all my apps have less than half of the partition filled. Trust me, there's enough space.
  8. At this point, you'll have to reboot to apply the changes. This is why we got rid of all user apps at the beginning, since the script will now move the dalvik-cache from /data/ to /sd-ext/. It will take a little bit longer, but it should do it's thing. Once back up,fire up S2E and go to menu>information. You don't necessarily have to download the app it tells you about, but it is nice to have (now that you have the space for it). You'll see that there's still some space being filled in /cache/ but that's due to some apps like browser and email still using it - no big deal. You will, however, notice that /sd-ext/ has some of its space filled up. It'll be small at this point, since there aren't any user apps restored back onto the phone. When it looks like everything is all set, go ahead and restore all your apps. When you do this, change the option to restore to internal memory instead of sd card, since the link has already been made for this to really go to sd card. All new apps will also follow this precedent.

At this point, you should have everything working flawlessly, and never see that damned market error again (assuming you don't fill up your new sd-ext partition... My performance since doing this is rock solid, maybe even better than before. Flashing rom updates will break this, though, so make sure it's an update you really want, otherwise you'll just have to run through this again.
 
Last edited:
  • Like
Reactions: MasterTec

glitchsta

Well-known member
Dec 19, 2010
152
18
0
Visit site
I wonder if it is possible to make a flashable zip to do this? Or if nick could set this up in reborn, hopefully rom builders can incorporate this, this new marketplace is pathetic to download anything, Also in titanium u back all user thanks I am gonna try now...in titanium do you do backup all user apps + system data in batch mode I believe so u back up the system apps to....?
 

sfhub

Well-known member
Jan 15, 2011
2,384
741
0
Visit site
Out of curiosity, have you tested the behavior if you removed the micro sd card? I don't think it is a very well tested case for the dalvik cache partition to be unavailable and I'm curious how it behaves (and recovers when you replace the card)
 

acromack

Well-known member
Jan 10, 2011
300
49
0
Visit site
Fishable zip has potential to work, I'll have to look into it. That would definitely make updates easier. As fit performance, I actually have noticed out as better.. And don't remove the card unless you like ask your apps force closing at once. Happened to me in testing when I removed the original dalvik-cache folder. The system still holds out though so you should be fine to trove it and put out back in if you really needed to. I'd still recommend powering off beforehand.

So I guess next step is to look at making this a fishable zip. At least this shows that it is possible..
 

acromack

Well-known member
Jan 10, 2011
300
49
0
Visit site
I wonder how to do this with reborn rom...

Sent from my LS670 using Tapatalk

Is reborn built on froyo? I would start with a "df" command in adb after mounting all partitions (easiest to do this through recovery) to see where things are to start. If the dalvik-cache is in /cache/ as it is with these gingerbread builds, then the first half of the procedure is the same. This seems to be pretty common practice, so I doubt it's in the /data/ partition as it would be otherwise. Since s2e is built to only work with cm7 (gingerbread) builds, it wouldn't work with froyo - they read ext partitions differently.

So - if someone running it could upload a zip of the init.d folder in /system/etc/, so I can see what scripts are already there, and find out where dalvik-cache currently is located... I found a script that I'm pretty sure will work, just looking it over now - seems like it should do the job fine. Slightly different method but should still accomplish the same thing.

In fact, go up until completion of step 6, then flash this zip: http://krikun.ru/download/android/cm-app2sd-dalvik.zip It should be able to move both app data and dalvik-cache to the newly created sd-ext partition. I'll try later to see if it can be made to work with gingerbread as well, as that would be a much easier process..
 
Last edited:

glitchsta

Well-known member
Dec 19, 2010
152
18
0
Visit site
Is reborn built on froyo? I would start with a "df" command in adb after mounting all partitions (easiest to do this through recovery) to see where things are to start. If the dalvik-cache is in /cache/ as it is with these gingerbread builds, then the first half of the procedure is the same. This seems to be pretty common practice, so I doubt it's in the /data/ partition as it would be otherwise. Since s2e is built to only work with cm7 (gingerbread) builds, it wouldn't work with froyo - they read ext partitions differently.

So - if someone running it could upload a zip of the init.d folder in /system/etc/, so I can see what scripts are already there, and find out where dalvik-cache currently is located... I found a script that I'm pretty sure will work, just looking it over now - seems like it should do the job fine. Slightly different method but should still accomplish the same thing.

In fact, go up until completion of step 6, then flash this zip: http://krikun.ru/download/android/cm-app2sd-dalvik.zip It should be able to move both app data and dalvik-cache to the newly created sd-ext partition. I'll try later to see if it can be made to work with gingerbread as well, as that would be a much easier process..
After hours of searching...I finally figured it out...

I found this modified data2ext on the optimus v forums and it does work with Reborn 2.2.4 just create a partition in recovery, adb shell in recovery, follow instructions @ Data2ext CyanogenMOD - UPDATE 26/01/11 - xda-developers, i did the new user ext4 instructions, then flashed this modifed zip...boom 512MEG of internal storage when I booted up, no more messing up marketplace...
 

basketthis

Well-known member
Nov 22, 2010
1,470
473
0
Visit site
Is reborn built on froyo? I would start with a "df" command in adb after mounting all partitions (easiest to do this through recovery) to see where things are to start. If the dalvik-cache is in /cache/ as it is with these gingerbread builds, then the first half of the procedure is the same. This seems to be pretty common practice, so I doubt it's in the /data/ partition as it would be otherwise. Since s2e is built to only work with cm7 (gingerbread) builds, it wouldn't work with froyo - they read ext partitions differently.

So - if someone running it could upload a zip of the init.d folder in /system/etc/, so I can see what scripts are already there, and find out where dalvik-cache currently is located... I found a script that I'm pretty sure will work, just looking it over now - seems like it should do the job fine. Slightly different method but should still accomplish the same thing.

In fact, go up until completion of step 6, then flash this zip: http://krikun.ru/download/android/cm-app2sd-dalvik.zip It should be able to move both app data and dalvik-cache to the newly created sd-ext partition. I'll try later to see if it can be made to work with gingerbread as well, as that would be a much easier process..

This zip works well for moving the whole data and cache partitions to the sd-ext... Make sure it's formatted to ext4... However, it does not display as internal memory so it's almost as if your apps are stored in a hidden folder. lol. Anyway, if there was anyway to merge this zip and the data2extV4.zip and have them both work, it would be perfect. But, for now I will probably use this. Nice find!
 

bread22

Member
Jul 21, 2011
5
0
0
Visit site
my 2 cents
I just removed the script /system/etc/init.d/01mvdalvik
then use link2sd as usual, mapping the whole cache partition to sd card makes the phone unable to boot w/o sdcard
since i mapped all app and app cache to sd card using link2sd, then the data partition have enough space to handle whatever it need. Removing the mapping to cache partition for dalvik frees up the space in cache partition, then there is no problem for market any more
 

pha149

New member
Jan 31, 2012
1
0
0
Visit site
I tried doin that but when I enter the first line in the emulator to remove /system/etc/init.d/01mvdalvik it wont let me an says that it is a read only file. I have the optimus c an I updated from the 7.0 to the 7.2 an the 7.2 runs so much butter but I have that prob with my market, that it wont either download or install apps that I want. On both 7.0 an 7.2 my MMS doesn't work an I installed the cricketmms fix file an it still doesn't fix it. CAN U PLEASE HELP ME ASAP I LIKE 7.2 ALOT AN DONT WANNA GO BACK TO 7.0. if u want u can email me phasson80@gmail.com. or if there is another way I can fix it thank u
 

lsiden

Member
Jun 4, 2012
5
0
0
Visit site
Thank you @aacromak for the great post.

You will likely see that /cache/ is very close to 100%. If it's not, then stop here. You're imagining your problems

Well, I must be imagining things then because "df" shows that my cache partition has > 153M free, but the Market app still throws up the message "Invalid Package File" when I try to download really large files. This still seems to happen mostly with larger files. When I use Root Explorer (or some other file browser) to go into /cache/download, the apk is right there with the icon, so it "looks" like it isn't corrupted but when I try to select and install it directly it fails.

Several months ago I did try to use s2e to link /cache/download to /sd-ext2/download but that didn't work either so I unlinked it and re-created /cache/download as a normal directory.

****
A bit more info:
I just tried installing it manually from the apk in /cache/download and it failed. Logcat said: "Package com.priceline.android.negotiator has no certificates at entry res/drawable/car_status_image_page.png: Ignoring!"

But if I disable wifi and install it again, it works like a charm (albeit the download is slower).

So I'm stymied. Any ideas why it finds a missing certificate over the Wifi, but installs fine when it's downloaded over the radio?
 

acromack

Well-known member
Jan 10, 2011
300
49
0
Visit site
Talk about bringing and old thread back from the dead lol..

Where does the df command list your dalvik cache? If you deleted the init.d file, it's back in data partition. Mine is actually on sd-ext since I have my data partition linked to there. But if you don't have a large number of apps, your cache probably won't be filling up. I'd try deleting everything in that download cache folder, clearing cache for market app, then retrying your download.
 

lsiden

Member
Jun 4, 2012
5
0
0
Visit site
./adb shell df
Filesystem Size Used Free Blksize
/dev 207M 32K 207M 4096
/mnt/asec 207M 0K 207M 4096
/mnt/obb 207M 0K 207M 4096
/app-cache 8M 0K 8M 4096
/system 350M 161M 188M 4096
/data 426M 296M 129M 4096
/cache 160M 6M 153M 4096
/sd-ext 961M 296M 665M 4096
/mnt/secure/staging 13G 5G 7G 8192


# ls -l /cache
drwxrwxrwx root root 2012-06-03 20:23 download
-rwxr-xr-x root root 184 2012-06-03 13:40 dowipedalvikcache.sh
drwxrwx--- root root 2012-04-02 20:21 lost+found
drwxrwx--x system system 2012-04-02 20:21 dalvik-cache
drwxrwx--- system cache 2012-06-03 13:45 recovery


Not sure what's in dowipedalvikcache.sh and adb won't reconnect right now, but I don't think anything here gets run automatically at startup so it shouldn't matter.

Ominously, /sd-ext is still full of .apks that I once moved and linked to with link2sd, even though I since used Titanium Backup to move them back to ROM. Is it possible that TB is "fooled" by the links that link2sd created? Or does it just not bother to delete them after it "moves" them back to ROM?

In any case, everything else is working perfectly right now. I just need to disable the Wifi whenever I want to update large apps from the market, a minor but persistent nuisance that has plagued my Evo despite having rooted it and trying out several different ROMs including CM7.
 

Forum statistics

Threads
943,154
Messages
6,917,546
Members
3,158,851
Latest member
jeneral2