Difference between revisions of "Partition Layout"

From postmarketOS
Jump to navigation Jump to search
 
Line 23: Line 23:
 
$ pmbootstrap init
 
$ pmbootstrap init
 
$ pmbootstrap install
 
$ pmbootstrap install
$ pmbootstrap export
+
$ pmbootstrap export # create a symlink to the rootfs image file for further usage
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 22:10, 6 July 2020

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 (contains kernel, initramfs, initramfs-extra)
p2 # label: pmOS_root (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

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. The postmarketOS boot and root partitions will become subpartitions of that partition.

For example, a typical Android installation consists of:

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

postmarketOS will be installed into the system partition, which means the postmarketOS boot partition becomes systemp1 and the postmarketOS root partition becomes systemp2.

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. 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.

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