Jump to content

Partition Layout

From postmarketOS Wiki
(Redirected from Partition-layout)
Note this article is about pmOS partition infrastructure and has little to do with Android Partition layout. For the latter, see the Android documentation and the wiki pages for Android AB Slots and Android_dynamic_partitions.

A postmarketOS installation consists of two partitions, the boot and the root partition. This distinction was made to support FDE (full disk encryption). With FDE, the entire root partition gets encrypted, and the only non-encrypted part remains the boot partition (which does not hold any personal data).

p1 # label: pmOS_boot (boot partition which contains kernel, initramfs, initramfs-extra)
p2 # label: pmOS_root (root partition which contains everything else, can be encrypted)

Due to the wide range of devices we support, there are a few variations of where these partitions will be exactly after installing postmarketOS.

Use the whole storage device

Note pmOS_boot and pmOS_root have to be labeled in the file system. The postmarketOS initramfs checks those partition labels via the file system, not the GPT partition table. Also boot-deploy would specify the uuid of those partitions via a boot flag if the uuid of those partitions is specified in /etc/fstab. If the uuid of those partitions is specified via a boot flag, the postmarketOS initramfs would check the uuid instead of the label.

Both partitions are directly written to the storage device (SD card, eMMC, ...), for example /dev/mmcblk0p1 and /dev/mmcblk0p2.

This is always done with SD cards. With the eMMC (internal storage), this is only done if it the factory OS can be flashed back without relying on a specific partitioning layout. (This is not possible with Android, see subpartitions below.)

A typical SD card installation:

$ pmbootstrap init
$ pmbootstrap install --sdcard=/dev/path-to-sdcard-device

A typical eMMC installation (you would flash the resulting image with a tool like Jumpdrive):

$ pmbootstrap init
$ pmbootstrap install
$ pmbootstrap export  # create a symlink to the rootfs image file for further usage

Subpartitions

Android (and other factory OS) require a specific partition layout. In order to make it feasible for the user to switch back to Android on their device, we install postmarketOS only into an existing partition. For example, a typical Android installation consists of (see also the Android docs):

  • boot
  • system
  • userdata
  • (more partitions with firmware etc.)


Note As of now, pmOS only supports subpartitions on a system* partition (any partition that has prefix of system including system_a and system_b on A/B devices) or the userdata partition. The system* or userdata partition has to be labeled in the GPT partition table. The postmarketOS initramfs checks those partition labels via the GPT partition table, not the file system.
Note The system* partition doesn't have to be a traditional GPT partition, it can also reside on a super partition, see Android dynamic partitions. pmOS would map those Android dynamic partitions into block devices during boot

Therefore, pmOS would have to split the chosen partition into two subpartitions:

  • Subpartition 1: Labeled pmOS_boot which is the boot partition
  • Subpartition 2: Labeled pmOS_root which is the root partition

Example:

$ pmbootstrap init
$ pmbootstrap install
$ pmbootstrap flasher flash_kernel
$ pmbootstrap flasher flash_rootfs

Note that the flash_kernel command fills Android's boot partition with a boot.img file, that consists of the Linux kernel and initramfs from postmarketOS. The files are duplicated on the postmarketOS boot partition, but not used from there (due to the Android bootloader usually only booting from the boot partition, not the root partition). Some Android devices have a strict size limit for this boot.img file, which is why we load additional files from the initramfs-extra file from the postmarketOS boot partition.

Note that the flash_rootfs command fills the system* or userdata partition with pmOS's subpartitions.

Stowaway

It is a way to store pmOS in a folder that is in the phone's data partition.

Pick a different subpartition

While on some devices, the system partition is bigger than the userdata partition, it is the other way around on others. So it is possible to switch to the userdata partition with pmbootstrap flasher flash_rootfs --partition userdata. To clear a previous postmarketOS installation from the system partition, use fastboot format system (otherwise, the initramfs may boot into the wrong installation!).

On-device installer

The on-device installer starts with three partitions (boot, reserved space, installer). It installs postmarketOS into the reserved space, and removes the third partition, so in the end it looks like the regular boot and root partition layout. Details are in the on-device installer article.

See also