Understanding Partitions in AOSP
From storage basics to creating your own custom partition
1 min readWhat is a Partition?
A partition is a logical division of physical storage inside a device. Instead of treating the entire storage as one block, Android divides it into multiple independent sections. Each partition has a specific purpose, stores specific types of data, and has its own size, filesystem, and mount point.
- ▸/system - Android framework and core OS files
- ▸/vendor - Hardware-specific HAL implementations and binaries
- ▸/data - User apps, settings, and files
- ▸One physical storage chip is divided into multiple independent sections, each serving a distinct role
Storage Technologies: eMMC vs UFS
eMMC (embedded MultiMediaCard)
- ▸Older storage technology with slower performance
- ▸Handles one operation at a time (sequential access)
- ▸Commonly used in budget and older devices
- ▸Reliable, but limited throughput
UFS (Universal Flash Storage)
- ▸Modern storage technology with SSD-like performance
- ▸Supports parallel read and write operations simultaneously
- ▸Used in modern smartphones and most automotive-grade Android systems
- ▸Significantly faster than eMMC for both sequential and random access
Types of Partitions in AOSP
Core System Partitions
- ▸boot - Kernel and ramdisk; used for the boot process
- ▸system - Android framework, core services, and platform apps
- ▸vendor - HALs and vendor-specific binaries for hardware abstraction
- ▸product - OEM-specific customizations and preloaded apps
- ▸odm - Device manufacturer specific components, separate from vendor
Data and Runtime Partitions
- ▸userdata (/data) - User-installed apps, accounts, settings, and personal files
- ▸cache - Temporary data storage; largely deprecated in modern Android
- ▸metadata - Encryption metadata and filesystem state
Special Partitions
- ▸recovery - Recovery mode image for OTA and factory reset operations
- ▸persist - Critical calibration data that survives factory reset
- ▸misc - Boot control flags and miscellaneous system state
Dynamic Partitions (Modern AOSP)
- ▸Grouped inside a single 'super' partition on the physical storage
- ▸Includes system, vendor, product, and odm by default
- ▸Allows flexible resizing of individual partitions without changing the physical layout
- ▸Introduced in Android 10 as part of Project Treble improvements
The Persist Partition
The persist partition stores critical hardware calibration data that must survive a factory reset. While /data is wiped on reset, /persist is preserved. This ensures hardware continues functioning correctly after the device is reset to factory state.
- ▸Camera calibration data specific to the hardware module
- ▸Audio DSP tuning and EQ profiles
- ▸Sensor calibration offsets (accelerometer, gyroscope, etc.)
- ▸Wi-Fi and Bluetooth hardware configuration
- ▸Automotive-specific configs such as VHAL property defaults and ECU pairing data
Key AOSP Files for Partition Management
1. BoardConfig.mk
Defines the partition size and filesystem type. This is where physical dimensions are declared.
BoardConfig.mk - Partition Size Definition
BOARD_MY_CUSTOMIMAGE_PARTITION_SIZE := 104857600 BOARD_MY_CUSTOMIMAGE_FILE_SYSTEM_TYPE := ext4
2. Android.bp
Defines how the partition image is built during the Android build process.
Android.bp - Partition Image Build Definition
android_filesystem {
name: "my_customimage",
partition_name: "my_custom",
mount_point: "/my_custom",
}3. fstab (File System Table)
Tells Android where and how to mount each partition at boot time.
fstab - Mount Point Definition
/dev/block/by-name/my_custom /my_custom ext4 defaults wait
4. sepolicy (SELinux)
Defines SELinux security labels and access rules for the partition contents.
sepolicy - SELinux Label
/my_custom(/.*)? u:object_r:my_custom_file:s0
5. super_partition.xml (Dynamic Partitions)
Defines whether a partition exists inside the super partition and its allocated size.
super_partition.xml - Dynamic Partition Entry
<partition name="my_custom" size="104857600"/>
How to Create a Custom Partition in AOSP
- ▸Step 1: Define partition size in BoardConfig.mk - BOARD_MY_CUSTOMIMAGE_PARTITION_SIZE and FILE_SYSTEM_TYPE
- ▸Step 2: Create the partition image definition in Android.bp using android_filesystem{}
- ▸Step 3: Add the mount point entry in the device fstab file
- ▸Step 4: Add SELinux labels and access rules in sepolicy
- ▸Step 5: Register the partition in super_partition.xml if using dynamic partitions
Step 6: Build and Flash
Build and Flash Commands
m my_customimage fastboot flash my_custom my_custom.img
How to Add Content to a Custom Partition
During Build (via PRODUCT_COPY_FILES)
Copying Files at Build Time
PRODUCT_COPY_FILES += \
device/<vendor>/<device>/file.txt:my_custom/file.txtAt Runtime (via C/C++ code)
Reading/Writing at Runtime
FILE *fp = fopen("/my_custom/data.txt", "w");
fprintf(fp, "Hello");
fclose(fp);