Boot process

From postmarketOS
Revision as of 22:38, 23 February 2018 by MayeulC (talk | contribs) (Add a link to Mediatek#Booting_procedure)
Jump to navigation Jump to search

postmarketOS has a boot process quite similar to the other linux distributions, with a few peculiarities that come from the devices it runs on.

First stage boot loader

This isn't something controlled by postmarketOS, and most of the time the user doesn't control it either.

Usually there is a first stage bootloader (actually, more of a second or more stage, depending on the device) installed somewhere on the device. That bootloader loads the linux kernel compiled by pmbootstrap in memory, as well as an initramfs (Initramfs development), which contains the smallest possible set of tools for the rest. It then passes the execution on to the kernel, which extracts the initramfs in memory and mounts it as a root filesystem. It does so, while passing on the kernel command line option, and sometimes the Device Tree Blob (dtb).

Various devices have various ways of doing this (It would be nice to document this here):

  • heimdall-isorec devices expect to find the initramfs packed with the vmlinuz image, as they can't load it themselves. For these, postmarketOS has a small initramfs in the vmlinuz image that loads the usual minimalist initramfs from another partition.
  • Boot process on Mediatek devices

Inside the initramfs

The task goes on to the Linux kernel, which initializes some of the peripherals, then executes the postmarketOS initramfs init script[1].

This script initializes USB Networking, looks for a postmarketOS boot partition [2][3]. At that point, you can Inspect the initramfs if you want to, and the various hook scripts are ran.

The boot partition is mounted, and the second initramfs, initramfs-extra, is loaded (a splash is displayed if not found). This initramfs contains other the remaining tools necessary for the boot process, but is kept separate in order to minimize the size of the boot image (that needs to fit on every device).

The init script then proceeds to find the root partition (it displays a splash if it isn't found), to resize it, to unlock it, to mount it at /sysroot, and then chroots in, executing /sbin/init.

In the root partition

TODO: complete this section

See also