For dual boot pmOS you need a boot method and a way to store data. After selecting both and following the guide, you will have a working device with dual boot.
For many methods, you will need pmbootstrap
booting from computer
This is the simplest option, but you will need a computer to boot pmOS. If the SD card is used to store data, nothing will be modified on the phone.
Run after entering fastboot mode on your phone pmbootstrap flasher boot To start pmOS.
recovery partition
| alert: Doing this will cause you to lose Android recovery mode, and overwrite any recovery OS/software installed on the recovery partition (like TWRP) |
If the pmOS kernel is written on the recovery partition, your device will boot into pmOS upon entering recovery mode. You can get the kernel image by running pmbootstrap exportAnd
fastboot flash recovery /tmp/postmarketOS-export/boot.img Flashing it for recovery.
Under this method, you need to find a way to store pmOS as user data is used by Android (however, you can share user data between pmOS and Android with #Stowaway).
A/B Slot
On phones that have A/B slots, you can flash the PMOS in the system partition of slot B, and leave slot A and user data for Android. If you want larger partition for pmOS, please see #Custom Partition.
Slot switching can be done using a computer fastboot --set-active=[a/b] While the phone is in fastboot mode.
Alternatively, you can use any of the following Android apps to switch to pmOS:
On pmOS you can use qbootctl to switch back to Android.
u-boot
Implement multiboot connected to Android in u-boot_porting#one_device_port
On the Nokia N900 and other devices that use U-Boot (e.g. MangoPi MQ-Pro (mangopi-mq-pro), Xunlong Orange Pi 3 (xunlong-orangepi3)), U-Boot provides a mechanism to select the OS. Nokia N900#Installation and View Bootmenu on U-Boot Dock
On some Amlogic devices with U-Boot, there is a multi-boot mode: amlogic#boot process
lk2nd/lk1st
lk2nd/lk1st
On devices with lk2nd the boot image is loaded from an ext2 boot partition onto an eMMC or SD card. Since lk2nd has backward compatibility with Android boot images, you can flash your Android Boot.img via lk2nd, and it will boot to that image as long as an SD card with postmarketOS is inserted.
keexec
Never tried it but kexec could potentially work. Either your Android needs to support it or your postmarkets does. The other direction can also be solved by a plain old reboot.
ticketless passenger
Some devices (such as the Pixel 3) use metadata/FBE encryption to encrypt the data partition. This is not supported in pmOS, and will cause failure. Devices launched with Android 9 or higher have encrypted metadata/FBE. To check if it is in your phone, run dmctl table userdataIf it throws an error, you can use Stowaways,
Is it possible to disable Encryption Multidisabler (for Samsung devices) [1],
Read everything before doing anything. It only works on edge.
The end result will be that a folder(.stowaway/pmos/) will be used for root in a partition. This is useful for Android devices where modifying the partition table is not recommended.
Preparation
To use this method, you need to put the files from the root into a .stowaway/pmos/ On your phone. To transfer these files, we will use tar. And to boot with this method, you need to force pmOS to boot the partition that contains the stowaway.
Here is a simple script that will create a pmos.tar and force the user data to boot.
pmbootstrap init
# Modify deviceinfo to force booting on userdata
pmbootstrap install --split
pmbootstrap shutdown
cd ~/.local/var/pmbootstrap/chroot_rootfs_*/
# Change userdata if you want to use a different partition
echo "deviceinfo_kernel_cmdline_append=\"pmos.stowaway pmos_root=/dev/disk/by-partlabel/userdata\"" | sudo tee -a etc/deviceinfo
sudo sed -i '3,0s/^/#/' etc/fstab # don't mount /boot
pmbootstrap install --split
# Make pmos.tar
pmbootstrap export
mkdir /tmp/PMOS_ROOT
sudo mount -o loop /tmp/postmarketOS-export/*-root.img /tmp/PMOS_ROOT
sudo mount -o loop /tmp/postmarketOS-export/*-boot.img /tmp/PMOS_ROOT/boot/
cd /tmp/PMOS_ROOT
sudo tar -cf ../pmos.tar *
cd /tmp
sudo umount /tmp/PMOS_ROOT/boot/
sudo umount /tmp/PMOS_ROOT
#fastboot flash boot /tmp/postmarketOS-export/boot.img
The flash command is commented out because, I don’t want to override someone’s Android install
Unpacking pmos.tar on your phone
move now /tmp/pmos.tar on your phone using the command adb push /tmp/pmos.tar /sdcard
For this part you will need root or TWRP, run mkdir /data/.stowaways/pmos And mv /sdcard/pmos.tar /data/.stowaways/pmosThis will create a directory and move our tar into it, We have to run to open it cd /data/.stowaways/pmos And tar -xf pmos.tarNow we can delete pmos,tar rm pmos.tar,
mkdir -p /data/.stowaways/pmos
mv /sdcard/pmos.tar /data/.stowaways/pmos
cd /data/.stowaways/pmos
tar -xf pmos.tar
rm pmos.tar
SD card
You can flash the file system to an SD card. Then pmOS will be able to use it.
pmbootstrap install
pmbootstrap export --no-install #the generated root and boot FSes are linked together, export would regenerate (reinstall) them (unless you pass --no-install) which might be undesired if you used pmbootstrap install --sdcard=... in the previous step
# flash /tmp/postmarketOS-export/[device].img to SD card
The target when flashing should be the full drive, not a partition (eg). /dev/sdb instead of /dev/sdb1optional pmbootstrap install --sdcard=... can be used instead
custom partition
| alert: If done incorrectly this process can damage your phone! If you don’t feel comfortable recovering your phone via deep flashing, don’t try this |
On some devices, it may be possible to create a custom partition.
shrink userdata
| alert: This process will destroy your phone data. |
First, you need to shrink the UserData partition to free up space for the custom partition for pmOS.
1. Shrink userdata in partition table
2. Boot up to TWRP to format user data
Then, depending on the partition scheme, you may need to follow #Creating CustomPartition for the “Subpartition” partition scheme or #Creating CustomPartition for the “Use the entire storage device” partition scheme to create a custom partition for pmOS.
Creating custom partition for “Subpartition” partition scheme
| Under the subpartition partition scheme, PMOS will look for subpartitions in the partition that are labeled USERDATA or SYSTEM* (any partition whose name has a SYSTEM prefix) in the partition table, thus the label of the partition must have a SYSTEM prefix. However, in order not to confuse the bootloader. Do not label the partition with a name like system_a system_b system_c userdata. For example, systempmos is a perfect name that would work. |
1. Create a partition named systempmos in the partition table.
Creating a custom partition for the “Use entire storage device” partition scheme
| Under the “use the entire storage device” partition scheme, 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 partition table. However, it is recommended to label those partitions in the partition table if you want them to be flashable in fastboot. (It doesn’t matter what you label them in the partition table. As long as fastboot is able to read those labels.) |
| The disk image generated by pmbootstrap has already been labeled |
1. Create a new boot partition labeled pmOS_boot in the file system
2. Create a new root partition labeled as pmOS_root in the file system