So I've had my HTC Desire now for approxmately 2 years now and whilst it has served me well I've had a bug bear with it for a long time. Essentially the phone has only 148 MB of internal storage and after the basic Android OS has been installed this is reduced to under 134 MB. Now I knew that this phone didnt have much memory when I bought it, and as a result when I bought the phone I bought it with a 16 GB microSD card.

-wikipedia.org

However, there are a lot of apps that dont like to play if they're installed to the SD card. And it doesnt take too many apps such as Google+ (at over 20 MB) and suddenly you cant update any apps through a lack of phone space due to apps being downloaded to phone memory before being moved.

Eventually I've got completely sick of this and as I have my phone rooted and running Cyanogenmod I thought I'd use some basic Linux file system trickery to move all apps to the SD card but set some symbolic links in the link file system so that the apps still think they're on phone memory.

So, here's what I've done. This isnt for the faint of heart and if you're worried either dont bother or backup your phone first. All apps you can redownload for free from the Android Market in any case, but I'm not going to take responsibility for your actions.

So open the Terminal Emulator program, and then give it super user permissions so we can access and change core Android.

su

A message prompt should appear saying that the Terminal Emulator has been given super user permissions, if you havent done it before then you need to Allow access. Remember that Android (and linux) is case sensitive

cp -rv /data/data /sdcard/Android

The -rv flag means; r to copy recursively (ie every folder), and v to show us in the terminal every file that is copied. We could copy to any folder on the SD card but I've stuck it into the folder where apps are stored when you send them to the SD card anyway.

With the files copied across we can now remove the old ones (we could have used the mv command but I was prefer a copy and remove, it's a bit safer)

rm -r /data/data

Then we need to link the new location back to the old with a symbolic link

ln -s /sdcard/Android/data /data/data

Sorted! This should have now cleared up an awful lot of space. But if space is still an issue we can move the Dalvik cache. The Dalvik cache is the cache for Dalvik, which doesnt help much unless you know that Dalvik is the Java virtual machine for Android, so the Dalvik cache is basically the space where all the program information gets dumped whilst it's running.

To do this is pretty simple too, following the above:

cp -r /data/dalvik-cache /sdcard/Android

rm -r /data/dalvik-cache

ln -s /sdcard/Android/dalvik-cache /data/dalvik-cache

Obivously, the problem with this is that you can now, never remove your SD card without having to move these back to the phone.

Also note that your apps will take a second or two to start the first time after the move as it rebuilds the cache.

 


Update: After doing a restart (as the battery ran flat), I ran into a huge number of problems with apps not responding; most annoying the keyboard restarting every 10 seconds.

Poking around online I came across a few things. For those not wanting to risk experimental builds then there is a fantastic resource here for managing your apps onto SD. However, newer builds of Android, namely those with an ICS flare have automated memory management by partitioning off part of the SD card to apps so that the root system seems the partition as part of phone memory.

So with a quick flash to Ice Cream Sandwich using a Cyanogenmod 9 beta and everything is hunky-dorey

 

About Morgan Bye

Scientist, programmer and all around techie

Latest Posts By Morgan Bye

Category

Blog