Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Android LP metadata (super.img)

From ReverseEngineering.wiki
Format
Magic gDla (geometry), 0PLA (metadata header)
Extensions .img
Endianness little
License Apache-2.0 (AOSP liblp)
On this wiki Facts · Code · Notes · Topics

Logical partition metadata of Android dynamic partitions at the start of the super partition: geometry (magic 'gDla' = 0x616c4467) at 4096, backup geometry, then a '0PLA' header (0x414C5030) with partition, extent, group and block-device tables that map system, vendor, product... onto linear extents.

Overview

Since Android 10 system, vendor, product, system_ext and odm live as logical partitions inside one physical partition named super (LP_METADATA_DEFAULT_PARTITION_NAME). A super.img is that partition (sometimes sparse, see Format:Android sparse image). The logical partitions are plain extent lists; there is no filesystem around them. Tools: lpdump, lpunpack (AOSP), lpmake.

Layout of the super partition

In order: 4096 reserved bytes (LP_PARTITION_RESERVED_BYTES), disk geometry, geometry backup, metadata slots, backup metadata, then the logical partition data. Offsets from liblp utility.cpp (read; the functions reader.cpp calls): primary geometry at 4096 (LP_PARTITION_RESERVED_BYTES); backup geometry at 4096 + 4096 = 8192 (LP_METADATA_GEOMETRY_SIZE is 4096); primary metadata slot n at 4096 + 2*4096 + metadata_max_size * n = 12288 + metadata_max_size * n; backup slot n at 12288 + metadata_max_size * metadata_slot_count + metadata_max_size * n. Each slot starts with the 256-byte header followed by the tables; tables_size may not exceed metadata_max_size.

LpMetadataGeometry (little-endian, packed)

Offset Field
0 magic u32 = 0x616c4467 (bytes 67 44 6C 61, "gDla")
4 struct_size u32
8 checksum[32] (SHA-256)
40 metadata_max_size u32
44 metadata_slot_count u32 (a backup copy of each slot is kept)
48 logical_block_size u32

Offsets are computed from the field order.

LpMetadataHeader (256 bytes)

Offset Field
0 magic u32 = 0x414C5030 (bytes 30 50 4C 41, "0PLA")
4 major_version u16 (10)
6 minor_version u16 (0 to 2)
8 header_size u32
12 header_checksum[32] (SHA-256 of the header computed with this field zero)
44 tables_size u32
48 tables_checksum[32]
80 partitions descriptor
92 extents descriptor
104 groups descriptor
116 block_devices descriptor
128 flags u32 (minor 2+): 0x1 VIRTUAL_AB_DEVICE, 0x2 OVERLAYS_ACTIVE
132 reserved[124]

A table descriptor is offset u32, num_entries u32, entry_size u32 (12 bytes). The tables follow the header contiguously; the offsets are relative to the end of the header: reader.cpp reads tables_size bytes after the header into a buffer and indexes it as buffer + header.partitions.offset.

Table entries

  • LpMetadataPartition: name[36], attributes u32, first_extent_index u32, num_extents u32, group_index u32. Attributes: 1 READONLY, 2 SLOT_SUFFIXED, 4 UPDATED, 8 DISABLED. Names end in _a or _b when slot-suffixed.
  • LpMetadataExtent: num_sectors u64, target_type u32 (0 LINEAR, 1 ZERO), target_data u64 (first physical sector for LINEAR), target_source u32 (index in the block device table). Sectors are 512 bytes (LP_SECTOR_SIZE).
  • LpMetadataPartitionGroup: name[36], flags u32, maximum_size u64 (flag 1 SLOT_SUFFIXED).
  • LpMetadataBlockDevice: first_logical_sector u64, alignment u32, alignment_offset u32, size u64, partition_name[36], flags u32.

Extracting a logical partition

Find the geometry, read the header and tables of slot 0, then for each partition concatenate its extents (target_data * 512, num_sectors * 512 bytes) from the super image; zero extents yield zeros. The output is a filesystem image (usually erofs or ext4, sometimes with AVB hashtree appended).

The sizes and group names also appear in the OTA manifest, see Format:Android OTA payload (payload.bin).

Sources: AOSP platform/system/core fs_mgr/liblp/include/liblp/metadata_format.h.

Code & repositories

  • https://android.googlesource.com/platform/system/core @ a3b721a32242006b59cb12bd62c9133632af3a2d · license: Apache-2.0 (declared by the contributor; GitHub's detector did not recognize a license file)
    libsparse/sparse_format.h and fs_mgr/liblp/include/liblp/metadata_format.h
    Tested on: source read, not run · checked 2026-10-18; last activity 2025-03-27