Jump to content

Boot process

From postmarketOS Wiki

Overview

Once you press the power button on your postmarketOS device, it goes through the following steps:

  1. Device specific bootloader
  2. postmarketOS initramfs
  3. Init
  4. getty
    (If the UI is none, it stops at here)
  5. Display manager
  6. User Interface of choice

Early boot process

In the early boot process, the device specific bootloader will intialize the device hardware. After that the way it boots the OS in device-specific ways. (See below) See Category:Bootloaders to learn more about how different bootloaders work.

UEFI

On devices that support UEFI, pmOS generally boots via systemd-boot

Android boot image

On most Android devices, the bootloader on that device would boot the Android boot image that is in the partition labeled as boot. That file contains the initramfs and kernel. Generally, pmOS would put its initramfs and kernel into a Android boot image and flash it to the boot partition. However, there are some Android devices that don't support Android boot images.

isorec

Very few Android devices don't expect a boot.img file written to the Android boot partition, but rather just the Linux kernel, with an embedded initramfs. But we want the initramfs packaging to be independent of the kernel (not require a kernel rebuild to change the initramfs!). Therefore we use the so-called "isorec" trick here: the initramfs script built into the kernel is just a very small stub, that loads the real initramfs from the postmarketOS boot partition (example).

Android 12 bootloader

Android 12 bootloader getting DTB only from vendor_boot partition, DTBO can be erased if qcom,board-id and qcom,msm-id exist in DTB. The boot partition is used for kernel, ramdisk and cmdline. recovery partition just for ramdisk, it use kernel and cmdline from boot partition.

Here is map

boot -> kernel, ramdisk (optional, normal boot), cmdline (optional)
recovery -> ramdisk (recovery)
vendor_boot -> DTB, ramdisk (optional), cmdline (optional), bootconfig (optional)

Difference between normal boot and recovery only in ramdisk. In normal boot mode bootloader give ramdisk from boot partition and when recovery mode it give ramdisk from recovery partition. Other things like kernel, DTB and cmdline are the same for both modes.

Commands to build boot, vendor_boot and recovery partitions:

# build vendor_boot with DTB
mkbootimg --header_version 4 --vendor_boot vendor_boot.img --dtb linux/output/arch/arm64/boot/dts/qcom/sm8450-oneplus-taro.dtb --pagesize 4096

# optional build vendor_boot with DTB and ramdisk
mkbootimg --header_version 4 --vendor_boot vendor_boot.img --dtb linux/output/arch/arm64/boot/dts/qcom/sm8450-oneplus-taro.dtb --vendor_ramdisk initramfs-linux.img --pagesize 4096

# optional build vendor_boot with DTB, ramdisk, cmdline and bootconfig
mkbootimg --header_version 4 --vendor_boot vendor_boot.img --dtb linux/output/arch/arm64/boot/dts/qcom/sm8450-oneplus-taro.dtb --vendor_ramdisk initramfs-linux.img --vendor_bootconfig bootconfig --vendor_cmdline 'bootconfig' --pagesize 4096

# build boot.img with kernel, ramdisk and cmdline
mkbootimg --kernel linux/output/arch/arm64/boot/Image.gz --ramdisk initramfs-linux.img --header_version 4 --pagesize 4096 --os_version 12.0.0 --os_patch_level 2025-12-00 --cmdline "console=tty0 root=/dev/sda14 rootwait rw" -o boot.img

# build recovery.img with ramdisk
mkbootimg --ramdisk initramfs-linux.img --header_version 4 --pagesize 4096 --os_version 12.0.0 --os_patch_level 2025-12-00 -o recovery.img

Newer bootloaders (which use init_boot partition) seems looks like use boot partition for kernel and cmdline. The init_boot only for ramdisk (like recovery)

See also