Flash storage in modern Android devices (typically UFS 3.1 or 4.0 storage modules) manages complex file layouts including the read-only system partitions (EROFs or ext4), dynamic user data (f2fs or ext4), app private sandboxes, and scoped storage media directories. When an Android device suffers from unexplained storage exhaustion, sluggish app loading times, or write-amplification delays, standard storage settings screens in the UI provide only high-level categorisations. To obtain granular partition metrics, cache utilisation, package payload sizes, and low-level disk performance indicators, the Android Debug Bridge (ADB) provides the dumpsys diskstats diagnostic command.
Understanding the dumpsys diskstats Service
The diskstats system service communicates with the Linux kernel block layer and Android\u2019s StorageManagerService. When queried, it reports:
- Partition Capacities: Total block counts, free space, and available storage across
/data,/cache, and system partitions. - App Footprints: Aggregate size breakdowns comparing app code (APK/dex), private data directories (
/data/data/<package>), and external media storage. - Cache Breakdown: Real-time tracking of reclaimable application cache data across all installed packages.
- Temporary Files: Storage consumed by downloaded update packages (OTA), download caches, and orphaned staging files.
Generating Full Disk Statistics with ADB
To inspect overall storage health and disk utilization across your connected Android device, execute:
adb shell dumpsys diskstats
The output presents a structured overview of all mounted storage partitions:
Latency: 1ms [512B write test]
Data-Free: 54,231,104K / 128,451,200K total = 42% free
Cache-Free: 492,100K / 512,000K total = 96% free
System-Free: 120,400K / 4,194,304K total = 2% free
Recent-Free: 54,231,104K
App-Data-Size: 18,452,100K
App-Cache-Size: 4,120,400K
Photos-Size: 12,850,000K
Videos-Size: 8,420,100K
Audio-Size: 1,420,000K
Downloads-Size: 2,100,500K
System-Size: 14,200,000K
Testing Storage Write Latency
Notice the first line emitted by diskstats:
Latency: 1ms [512B write test]
During the execution of dumpsys diskstats, the system service performs an instantaneous 512-byte synchronous write test directly to the physical storage controller. A normal result for modern UFS storage ranges between 0ms and 5ms. If this value consistently spikes to 50ms, 100ms, or higher:
- The physical flash controller is suffering from severe write amplification or background garbage collection stalls.
- The storage chips are running critically low on free flash blocks (causing block erase cycles before every write).
- Background applications are saturating storage I/O bandwidth with continuous log writes or database indexing.
Inspecting JSON-Formatted Storage Metrics for Automation
If you are writing scripts to monitor device storage health or build continuous integration (CI) test benchmarks, use the --json argument:
adb shell dumpsys diskstats --json
The command emits a structured JSON object detailing block devices, partition types, used space, and storage metrics:
{
"dataFree": 55532650496,
"dataTotal": 131534028800,
"cacheFree": 503910400,
"cacheTotal": 524288000,
"appDataSize": 18894950400,
"appCacheSize": 4219289600
}
You can pipe this output directly into jq on Linux or macOS to extract specific metrics:
adb shell dumpsys diskstats --json | jq .dataFree
Identifying Storage Consumed by Package Data and Caches
To inspect disk usage at the individual package level, combine diskstats with Android\u2019s package manager storage command:
adb shell pm get-installed-related-apps
Or query storage stats specifically for a single app package:
adb shell dumpsys package com.example.myapp | grep -A 10 "PackageSignatures"
To view directory-level usage in the /data partition directly (requires root access on test devices):
adb shell su -c "du -sh /data/data/* | sort -hr | head -n 15"
Triggering System Cache Clearing to Free Disk Space
If dumpsys diskstats indicates that App-Cache-Size is occupying excessive space and squeezing available storage:
You can instruct the Android package manager to reclaim all unneeded cached files across all installed applications using a target free space request:
adb shell pm trim-caches 10G
This command instructs Android to free up to 10 gigabytes of cached storage by pruning least-recently-used cache files across all app sandboxes without deleting user login credentials or database states.