How to Fix "Insufficient Storage Available"
"Insufficient Storage" when Installing and Upgrading Android / CyanogenMod Apps
One recurring problem users encounter on Android and its derivative CyanogenMod is the report "Insufficient Storage Available" when installing or upgrading an application. I have installed CyanogenMod on my Samsung Galaxy smart phone. It has plenty of memory and plenty of storage available, but after a while I ran into this problem. Google searches led me to some rather sketchy advice to install a number of "cleaner" programs. But there must be a straightforward solution. There is.
The Problem
The status bar at the top will show that one or more updates are available for installed apps. Normally you can tap that, which takes you to the application management screen, and simply click "Update All" and watch it happen. After several months past the last major CyanogenMod update, in which I had wiped the system, I started to get a few app update failures.
Insufficent storage available
A Workaround
I found that I could uninstall that app and then immediately reinstall it. Was the problem solved? No, I had just worked around it.
That's enough detail,jump to the solution!
Then it got worse.
I had the same initial failure when updating Google Maps. "Insufficient storage" to update it. OK, let's uninstall and then reinstall it.
Uh-oh. Now I can't install it...
As I mentioned above, Google searches yielded suggestions of various sketchy sounding "system cleaner" apps. Let's see if I can't figure out what's going on.
How Much Memory is Available?
The Samsung Galaxy S II comes in several varieties. I have the less common "Hercules" SGH-T989 variant sold through T-Mobile. It has a Snapdragon mobile SoC (or system on chip) with a 1.5 GHz dual-core Qualcomm APQ8060 (S3) Scorpion processor. Most of the other variants use a 1.2 GHz dual-core ARM Cortex-A9 processor in a Exynos 4210 System-on-Chip.
According to RgbenchMM, my phone does 475 Mflops for a single-threaded process, 1178 Mflops for a 2-thread process, and 1097 Mflops for a 4-thread process. It has 1 GB of RAM, plus 16 GB of flash memory functioning as a fixed disk plus up to 128 GB of storage on an added card.
Platform | Mflops (peak) |
RAM | Release | World's Fastest |
Cray-1 | 136 | 64 MB | 1976 | 1976–1982 |
Cray X-MP | 713 | 64 MB | 1982 | 1983–1985 |
Cray Y-MP | 2144 | 512 MB | 1988 | 1988–1989 |
Samsung Galaxy S II | 1178 | 1024 MB | 2011 | — |
RgbenchMM runs directly on the device rather than on the Java Virtual Machine. Discussion here says that the Linpack for Android app grossly under-reports the phone's performance. Its authors say "This test is more a reflection of the state of the Android Dalvik Virtual Machine than of the floating point performance of the underlying processor." Others have reported that with Linpack it's measured at 93.4 MFLOPS in single-threaded processes and 53.87 MFLOPS in multithreaded.
I have connected to my phone over SSH with SSHDroid running on the phone. Let's ask the running kernel for the details of the processor:
root@SGH-T989:/ # cat /proc/cpuinfo Processor : ARMv7 Processor rev 2 (v7l) processor : 0 BogoMIPS : 13.53 processor : 1 BogoMIPS : 13.53 Features : swp half thumb fastmult vfp edsp neon vfpv3 tls CPU implementer : 0x51 CPU architecture: 7 CPU variant : 0x0 CPU part : 0x02d CPU revision : 2 Hardware : QCT MSM8X60 FUSION FFA Revision : 000e Serial : 4d2588df75ea2f84
Now let's ask the kernel about the RAM. The phone has 1 GB of RAM, 780 MB remain available for use by applications:
root@SGH-T989:/ # cat /proc/meminfo MemTotal: 799632 kB MemFree: 59592 kB Buffers: 36524 kB Cached: 180260 kB SwapCached: 0 kB Active: 428060 kB Inactive: 112956 kB Active(anon): 325548 kB Inactive(anon): 2720 kB Active(file): 102512 kB Inactive(file): 110236 kB Unevictable: 1176 kB Mlocked: 0 kB HighTotal: 419840 kB HighFree: 52916 kB LowTotal: 379792 kB LowFree: 6676 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 604 kB Writeback: 0 kB AnonPages: 325412 kB Mapped: 109852 kB Shmem: 2860 kB Slab: 129140 kB SReclaimable: 100256 kB SUnreclaim: 28884 kB KernelStack: 8040 kB PageTables: 10252 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 399816 kB Committed_AS: 13518508 kB VmallocTotal: 434176 kB VmallocUsed: 46908 kB VmallocChunk: 294852 kB
However, that is the RAM, the memory used by running processes. The error messages said it was a shortage of storage, non-volatile memory.
How Much Storage is Available?
The "Hercules" SGH-T989 Galaxy S II has 16 GB of flash memory which functions as a fixed disk. It has a microSD slot in which you can insert a chip with up to 128 GB of storage. I have a 16 GB microSD card in mine.
The fixed on-board flash memory is mounted as
/storage/sdcard0
,
the microSD card is mounted as
/storage/sdcard1
.
Let's check the storage.
Note that much of the output is taken up with the system
itself and the root file system doesn't appear.
You could also use the /system/xbin/df
command
but its output is even more confusing.
root@SGH-T989:/ # df Filesystem Size Used Free Blksize /dev 390.4M 136.0K 390.3M 4096 /sys/fs/cgroup 390.4M 0.0K 390.4M 4096 /mnt/asec 390.4M 0.0K 390.4M 4096 /mnt/obb 390.4M 0.0K 390.4M 4096 /mnt/fuse 390.4M 0.0K 390.4M 4096 /firmware 199.8M 21.7M 178.0M 4096 /efs 9.8M 4.2M 5.6M 4096 /system 588.6M 499.3M 89.3M 4096 /data 2.0G 848.6M 1.1G 4096 /cache 297.2M 4.9M 292.3M 4096 /system/etc/firmware/misc_mdm 199.8M 23.7M 176.1M 4096 /mnt/media_rw/sdcard1 14.8G 1.8G 13.0G 32768 /mnt/secure/asec 11.3G 3.7G 7.5G 32768 /storage/sdcard1 14.8G 1.8G 13.0G 32768 /mnt/media_rw/sdcard0 11.3G 3.7G 7.5G 32768 /mnt/secure/asec 11.3G 3.7G 7.5G 32768 /mnt/media_rw/sdcard1/.android_secure 11.3G 3.7G 7.5G 32768 /storage/sdcard0 11.3G 3.7G 7.5G 32768
7.5 GB free on the internal storage, and 13 GB free on the microSD card — that clearly is far more than is needed to add an application of about 40 MB!
The Solution
Each application uses a subdirectory under
/data/app-lib
.
This is a separate file system, in the above output
we see that it is only about 40% full.
We can use the alternative df
to see
that it's one partition of the internal storage device:
root@SGH-T989:/ # cd /data/app-lib root@SGH-T989:/data/app-lib # /system/xbin/df . Filesystem Size Used Available Use% Mounted on /dev/block/mmcblk0p25 2.0G 848.8M 1.1G 42% /data
Google Maps is not installed, but look at this:
root@SGH-T989:/data/app-lib # ls -ld *maps* drwxr-xr-x 2 system system 4096 Mar 20 00:18 com.google.android.apps.maps-1 root@SGH-T989:/data/app-lib # ls -laR *maps* com.google.android.apps.maps-1: drwxr-xr-x 2 system system 4096 Mar 20 00:18 . drwxrwx--x 58 system system 4096 Mar 22 20:38 .. -rwxr-xr-x 1 system system 9408 Sep 21 2008 libcrashreporterer.so -rwxr-xr-x 1 system system 247252 Sep 21 2008 libgmm-jni.so
Uninstalling the app did not fully clean up. The problem is not really that we have insufficient storage. The problem is that the installation is failing as old files are in the way.
After once again verifying that Google Maps really is not installed, here is the fix:
root@SGH-T989:/data/app-lib # rm -r com.google.android.apps.maps-1
Now the application installs with no problem!
Apparently a similar problem has a similar solution.
If the application is currently installed,
there may be a directory for this verion plus one or
more for earlier versions.
The latest will have the app's name,
leftover data from the previous version in a directory
with that name plus -1
at the end,
the one before that with -2
, and so on.
For example, the wonderful Shatoetry app is installed on my phone, and the last update seemed to work perfectly. However, it didn't fully clean up:
root@SGH-T989:/data/app-lib # ls -ld *Shat* drwxr-xr-x 2 system system 4096 Mar 20 00:49 com.blindlight.Shatoetry drwxr-xr-x 2 app_111 app_111 4096 Dec 15 00:55 com.blindlight.Shatoetry-1
There's no problem now.
If there were a problem with updating
Shatoetry,
that older com.blindlight.Shatoetry-1
directory needs to be removed.