Transparent data compression on Android
What is "transparent data compression"?
Transparent data compression consists of storing data in a compressed format and automatically decompressing it whenever it needs to be accessed, making the whole process transparent to the user. Non-transparent methods of accessing compressed data may be cumbersome to the user, as they often require manual action for the compressed data to be decompressed.
One such example of non-transparent access of compressed data would be WinRAR ".rar" files, which need to be manually decompressed by right-clicking the file and selecting WinRAR in the context menu before its data can be accessed.
Alternative solutions to transparent data compression
The ultimate goal of transparent data compression on Android is to release more storage space to the user, but the currently available methods are extremely complicated for non tech-savy people. As an alternative to transparent data compression, consider the following solutions:
- Do a general cleanup using SDMaid 2/SE
- Scan your storage usage using DiskUsage and delete big files.
- Delete unused files from the Downloads folder.
- Upload your files to the cloud, deleting the local copies and following the 3-2-1 backup rule.
- Move apps to the SD-Card using Link2SD and set the default install location for apps to the SD-Card using `adb shell pm setInstallLocation 2`
- Buy a bigger SD-Card.
- Buy a phone with a bigger internal storage.
The steps provided above should fix the low-storage problem for most users. If you're still in need of more storage though, go on reading.
How to enable transparent data compression on Android
There is no Android-native way to enable transparent data compression on Android. But for anyone determined enough, there is a workaround way to enable it on Android devices.
Transparent data compression is often implemented at the filesystem level, meaning that not all filesystems are capable of it. Most Android devices use "Yet Another Flash File System v2" (YAFFS2) for /system
and /cache
and vfat for /sdcard
.
Other devices use F2FS, a flash-friendly filesystem that does support transparent data compression.
Enabling compression on F2FS
To check if your device supports the F2FS filesystem you'll need to have root access, and run:
cat /proc/filesystems
Alternatively, you can also run this command to see which filesystem flags your kernel was compiled with:
zcat /proc/config.gz | grep _FS=
If F2FS is on the list of supported filesystems, you can enable compression on it by first formatting the partition with the compression option using the command mkfs.f2fs -O compression /dev/sdX
, and then mounting it with the appropriate compression algorithm specified, such as mount -o compress_algorithm=zstd /dev/sdX /mnt
.
To add F2FS support to a device that doesn't have it you must recompile its kernel.
If your device doesn't support F2FS, you can instead opt for NTFS, though this isn't recommended as F2FS has far better performance on flash-based devices than NTFS.
Enabling compression on NTFS in Android
If for some reason you opted for NTFS instead of F2FS, this would work the same way CompactGUI works on Windows, allowing compressed files to be accessed transparently as-needed.
These are the steps:
- Recompile the Kernel with NTFS support
Android devices do not natively support the NTFS filesystem. Using the NTFS-3G project, it's possible to enable NTFS support. A great guide for doing this is available at Full NTFS Read/Write Support for Android | XDA Developers. - Insert the SD-Card into Windows.
- Create an NTFS partition.
- Create a /data folder.
- Use compact.exe to enable the transparent compression features.
- Insert the SD-Card into the phone.
- Mount the NTFS partition.
- Move all of the app files into their respective /data folder in the NTFS partition.
- Create symbolic links for the app files.
Boom, transparent compression on Android.
NOTE: I offer support for most of my guides, but not for this one. Compiling Android kernels is beyond my area of expertise, and is not something I can guide someone else through.
Having trouble?
For a one-time USD$10 donation you can get one-on-one troubleshooting support for any of my guides/projects. I'll help you fix any issue you may have encountered regarding usage/deployment of one of my guides. More info in my Github Sponsors profile.