System Apps on CyanogenMod

Some of you may know that I have been a fan of the Android operating system for phones for some time. Some of you may also know that I own 2 HTC Dream handsets. Don’t worry I won’t do into the hassles I’ve had with the hardware. Due to Leaf, the local HTC distributors, not providing software updates for the phone, other than 1.1 to 1.5, I have been using the CyanogenMod aftermarket firmware.

Now I’ve been very happy with the CyanogeMod firmware and have found it to be much more stable and responsive then the default firmware supplied by Leaf. A few weeks ago I was trying to figure out why I kept running out of storage space though, especially when updating apps. now I know the HTC Dream has a rather small amount of storage in it. When looking in the “Manage Applications” menu, I noticed that apps that used to only show under the All tab, now showed up under Downloaded. When then looking at the app details, I then had the option to Uninstall Updates. This lead me to investigate further.

Wanting to dig into the guts of my phone, I broke out ADB(Android Debug Bridge) which is part of the Android SDK. ADB gives me console access to the phone via a USB cable. From this point my phone is essentially a Linux system, since that is what Android is based on. To start with I wanted to know how my filesystem was layed out. Using the mount and df commands I was able to see a bit of how things are put together.

# mount
rootfs on / type rootfs (ro,relatime)
tmpfs on /dev type tmpfs (rw,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
none on /acct type cgroup (rw,relatime,cpuacct)
tmpfs on /mnt/asec type tmpfs (rw,relatime,mode=755,gid=1000)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
/dev/block/mtdblock3 on /system type yaffs2 (ro,relatime)
/dev/block/mtdblock5 on /data type yaffs2 (rw,nosuid,nodev,relatime)
/dev/block/loop0 on /system/xbin type squashfs (ro,relatime)
/dev/block/mtdblock4 on /cache type yaffs2 (rw,nosuid,nodev,relatime)
/dev/block/vold/179:1 on /mnt/sdcard type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/179:1 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
tmpfs on /mnt/sdcard/.android_secure type tmpfs (ro,relatime,size=0k,mode=000)
# df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 49300 0 49300 0% /dev
tmpfs 49300 0 49300 0% /mnt/asec
/dev/block/mtdblock3 92160 88356 3804 96% /system
/dev/block/mtdblock5 91904 77812 14092 85% /data
/dev/block/loop0 4096 4096 0 100% /system/xbin
/dev/block/mtdblock4 30720 19144 11576 62% /cache
/dev/block/vold/179:1
986016 774008 212008 78% /mnt/sdcard
/dev/block/vold/179:1
986016 774008 212008 78% /mnt/secure/asec
#

From this we see that there isn’t much space at all. Digging around, I found that apps are stored in 2 locations, /system/app/ and /data/app/ I found that “system apps” are the apps that are on the phone when you bit it up for the first time. “data apps” are apps that you install yourself, and software updates. The fun bit I noticed was that /system is mounted read-only, so as you install software updates, you have the new version of an app in /data/app and the old one sitting in /system/app. This doesn’t work for me so I set out to rectify the situation.

Since my an android phone is just a Linux system under the hood, I figured my usual sysadmin type tricks would work, so I tried to re-mount /system in read-write mode.

# mount -o remount,rw /system

This worked. Great, now to not destroy my phone.

Looking in /data/app I see the following

# ls /data/app
com.adobe.reader-1.apk
com.appspot.swisscodemonkeys.apps-2.apk
com.botsync-1.apk
com.dropbox.android-2.apk
com.evernote-1.apk
com.farproc.wifi.analyzer-2.apk
com.google.android.gm-1.apk
com.zegoggles.smssync-1.apk
ki.wardrive-1.apk
#

Knowing what apps are on my phone, I assume that com.google.android.gm-1.apk is the updated version of the Gmail app. Looking in /system/app/ I see that the version there is named Gmail.apk. So after making a backup copy of the original APK file to my SDcard, I move the updated app to the /system/app/ directory.

# cp /system/app/Gmail.apk /sdcard/
# mv /data/app/com.google.android.gm-1.apk /system/app/Gmail.apk
#

At this point I figured a reboot of the phone might be a good idea just in case something was in memory that relied on that app. You may also want to wipe the app data and cache for any apps that you move, just to be safe that noting is still addressing the old location. After the reboot everything still works ok and I have some extra space in /data/app/ that I can use for more apps.

Warning: This worked for me, but I have not checked with anyone else that it is a good idea. I did this first on my “test phone” and after I was happy that everything worked, I did it to my “stable phone”. If you only have one phone. Please be careful since if you do something wrong you may need to re-flash your firmware to get things working again.

Anyway, I hope someone finds this useful.

cya

SB

2 thoughts on “System Apps on CyanogenMod”

  1. For what it’s worth, you can also do this using Titanium Backup (I can’t remember if you need the “pro” version or not). Note that making this sort of modification while the phone is booted is not possible if the security flag (S-ON) is set by the boot loader; in this case, the flash memory rejects writes, and remounting the filesystem R/W is not possible. (There are ways to get “S-OFF” for most HTC phones, however)

  2. Thanks for the info, I’ll look into Titanium Backup.

    In my case the security flag is off since I had top root my phone to get CyanogenMod in there. I cant remember whether it was off before I rooted it, or if I had to fiddle something to turn it off. Its been a while.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>