Partition Layout
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
pmOS_boot and pmOS_root has to be labeled in the file system. The postmarketOS initramfs checks those partiton label via file system, not the gpt partition table.Also boot-deloy would specify the uuid of those partition via boot flag if the uuid of those partition is specified in /etc/fstab .If the uuid of those partition is specified via 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.)
As of now , pmOS only support subpartition on the system* (Any partition that has prefix of system like system_a system_b system) partition or userdata partition.Also system* and userdata has to be labeled in the gpt partition table. The postmarketOS initramfs checks those partiton label via gpt partition table , not the file system. |
system* partition partition doesn't have to be traditional partition.they also can be Android dynamic partitions.pmOS would map those Android dynamic partitions into block device druing boot |
Therefore , pmOS would have to split that partition into 2 two Subpartitions :
- Subpartition 1 : Labeled at pmOS_boot which is the boot partition
- Subpartition 2 : Labeled at pmOS_root which is the root partition
Example:
$ pmbootstrap init
$ pmbootstrap install
$ pmbootstrap flasher flash_kernel
$ pmbootstrap flasher flash_rootfs
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 usually android bootloader only boot boot.ing from the Android's boot 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.
That the flash_kernel
command fills system* partition or userdata partition with pmOS 's Subpartitions.
Stowaway
It is a way to storage 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
- Boot process, in particular how the partitions for boot and root are determined
- #953: idea to boot from an image file (did not go anywhere, open a new issue if you are interested in implementing this)
- Deviceinfo: flash methods
- Dual Booting/WiP #Stowaway
- Android dynamic partitions