5

There's almost no Android user (and certainly no regular visitor of our site) who hasn't heard of the "insufficient storage" error – or even experienced it him/herself. That there must be at least 10% of storage free on /data sounds ridiculous at least when the total space on that partition goes at or beyond 8 GB. Thus we quite frequently have questions on this topic here.

On one of the latest I've done some investigation of the relevant code, and discussed that in my answer. Let me quote the relevant code-block (taken from the latest code) here again:

 * This class implements a service to monitor the amount of disk
 * storage space on the device.  If the free storage on device is less
 * than a tunable threshold value (a secure settings parameter;
 * default 10%) a low memory notification is displayed to alert the
 * user. If the user clicks on the low memory notification the
 * Application Manager application gets launched to let the user free
 * storage space.

Now please focus on lines 2+3:

If the free storage on device is less than a tunable threshold value (a secure settings parameter; default 10%)

(emphasis mine). So here comes my question:


TL;DR: If that threshold is tunable, how to tune it?


Is it something in settings we overlooked all those years? Is this supposed to be "tuned" by the "ROM bakers" only? Or, taking the hint of a "secure settings parameter", is there some app utilizing the WRITE_SECURE_SETTINGS permission to take care of that? By which means are we supposed to address this (if at all)?

4
  • According to developer.android.com/reference/android/provider/…: "Secure system settings, containing system preferences that applications can read but are not allowed to write. These are for preferences that the user must explicitly modify through the system UI or specialized APIs for those values, not modified directly by applications."
    – Rodrigo
    Jul 8 '16 at 16:55
  • So looks like it should be "something in settings we overlooked all those years", right?
    – Rodrigo
    Jul 8 '16 at 16:56
  • Seems like – or they forgot to implement that for user-control. The WRITE_SECURE_SETTINGS has protection level "development" – so not sure whether that would be granted to a "normal app" – but "system or signature" (i.e. the ROM baker) still could use it.
    – Izzy
    Jul 8 '16 at 17:59
  • 1
    I'm always wondered by so many "forgettings" that contribute to planned obsolescence.
    – Rodrigo
    Jul 9 '16 at 4:56
3

Low storage threshold is the minimum value of the two:

  • sys_storage_threshold_percentage (default is 5%, was 10% on Android 7 and older). It's multiplied with the total storage size to get threshold value in bytes. This setting is there since the early days of Android.
  • sys_storage_threshold_max_bytes (default is 500 MiB). This setting was added in Android 4.

In JellyBean both settings were moved from secure namespace to global. And the logic to calculate low threshold was moved from DeviceStorageMonitorService to StorageManager.

If the 5% of total space on /data is greater than 500 MiB, the threshold is always 500 MiB. In order to set the threshold to even smaller value, e.g. to 100 MB:

~$ settings put global sys_storage_threshold_max_bytes 100000000
0
0

That there must be at least 10% of storage free on /data sounds ridiculous at least when the total space on that partition goes at or beyond 8 GB

Forcing the user to have 10% free space is not ridiculous, or stupid. It helps wear levelling, and is highly recommended for european users due to the continental 2y waranty law. Some manufacturers like Crosscall even provide 3y waranty (no restriction).

Spending long time using a disk with less than 5% can damage it. A friend used to own a large Flash disk, and after 14 months with 1% free space, the disk died. Yes, 1% free was between 1GB and 10GB free space; but the system needs to write loads of cache and temp files; and always rewriting the same cells killed the disk.

That's why phone manufacturers are very happy in europe with the Android 10% limit. This limitation is very frustrating when it triggers; I suffered from it this week; but it's preventing the Flash dieing before the 2y waranty.

4
  • 1
    Are they basically designing these things to die shortly after the warranty expires? If so, after the warranty expires, society has to deal with tons of electronics waste and/or expensive repairs. Apr 19 at 1:24
  • Leaving space for over-provisioning and wear-leveling is manufacturer's duty. And good manufacturers do spare enough space already. Sparing space from within partitions and filesystems doesn't make much sense. Though usually it's beneficial for filesystem's performance depending on its fragmentation handling and other factors. But these factors are more prominent on HDDs, almost negligible on flash media. Apr 19 at 12:33
  • No, for both comments, to RockPaper and Irfan : it's exactly like when you buy a 4TB rotating disk, and complaint that after 15 years the head is dead. Product has limits, and to not burn the device, you need to either shutdown it to save MTBF, or use heavy RAID to protect your data. You are freee to play with limits; but people who care about their storage keep far away. All FLASH storages already include hidden spare sectors; but keeping free space helps a lot. Also, playing with sys_storage_threshold_* implies root which had previously void waranty. Apr 20 at 18:17
  • Leaving the rest being opinion-based, just a correction: writing to global namespace of Android's settings database using settings put global command does not require root privileges. You can simply execute the command from adb shell. Apr 22 at 0:48
-1

You need to build your own kernel with preferrable settings, this option not writable by "normal_apps".

1
  • 3
    not writable by "normal_apps" does not necessarily imply building an own kernel. Can you back that with a reliable source? A system app could have access to that. The requirement of building a specific kernel somehow contradicts the statement "tunable threshold value".
    – Izzy
    Oct 18 '16 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.