AOSP Foundations
2 min read

userdata & metadata Partitions

Understand the read-write partitions where user applications, photos, and critical encryption keys are permanently stored.

The system, vendor, and product partitions are strictly read-only. Even if you have root access, modifying them on a modern retail device is virtually impossible due to cryptographic protections (dm-verity).

However, a smartphone must be able to save photos, download apps, and remember your Wi-Fi passwords. This read-write capability is entirely handled by the userdata and metadata partitions.

The userdata Partition

The userdata partition (mounted at /data) is the largest partition on the device, often consuming 90% of the physical flash storage.

  • App Storage: When you download an app from the Play Store, the APK is saved to /data/app/. The app's private databases (like your WhatsApp chat history) are securely saved to /data/data/<package_name>/.
  • Internal Storage: When you take a photo or download a PDF, it is saved to /data/media/0/ (which the Android UI presents to the user as /sdcard or "Internal Storage").
  • Dalvik Cache: The optimized machine code generated by the ART compiler (Ahead-of-Time compilation) is stored here to speed up app launch times drastically.
# To view how much space userdata is consuming via ADB
adb shell df -h /data

Factory Resets

When you trigger a "Factory Data Reset" in the Settings app, the Recovery environment simply executes a fast format command on the /data partition. Because the actual OS framework lives securely on the read-only /system partition, wiping /data instantly returns the phone to a brand-new, out-of-the-box state.

# A developer shortcut to perform a factory reset via fastboot
fastboot erase userdata

The metadata Partition

Introduced with Android 9 (Pie), the metadata partition is a tiny, highly secure read-write partition.

  • Purpose: Before the /data partition can be mounted, the operating system must decrypt it. The metadata partition stores the crucial cryptographic key blobs and encryption headers required by the File-Based Encryption (FBE) system.
  • OTA Updates: It also acts as a highly secure scratchpad for the update engine. When a seamless A/B update is downloading in the background, the progress and state flags are saved in the metadata partition so the system knows what to do if the user accidentally reboots the phone mid-download.

If the metadata partition is corrupted, the device will be completely unable to decrypt the user's data, resulting in a mandatory factory reset to recover the device.