Dual-boot PostmarketOS
By Fenguoerbian
March 16, 2025
PostmarketOS (Dualboot with android)
To dual boot postmarketos with android, it’s recommended to have android on slot A and postmarketos on slot B. Also TWRP recovery is used here for sgdisk (parted, or other partitioning tools).
-
Boot into TWRP recovery and in
Advanced->Terminal
you can usesgdisk
to check the status of your internal drive#Get userdata number and info on the disk sgdisk /dev/block/sda --print
-
Prepare partition for postmarket os. I’m using Slot B only and shrink down the
userdata
partition for installing postmarket osNote: This is a change to your partition table and you will loss ALL data and systems installed on your device! I’m re-flash Android rom to slot A after this work!
sgdisk /dev/block/sda --delete=17 # 17 (sda17) is `userdata` in my sda, originally it's 229.2 GiB #Make userdata 200 gigabytes, minimum size unknown (postmarket website uses 2G, which is still not the minimum) sgdisk /dev/block/sda --new=0:0:+200G --change-name=0:userdata # !!! Here you need to format the new `userdata` as well # maybe `ext4` is suited?
Stay in TWRP recovery for the next step.
-
Next, the choice is either to use a subpartition to store postmarketos, or the WHOLE DISK.
-
Subpartition
-
WHOLE DISK
#Make pmOS boot partition 256 megabytes (default size) sgdisk /dev/block/sda --new=0:0:+256M --change-name=0:pmOS_boot #Make pmOS system partition uses the rest of the disk # __NOTE:__ This is a DANGER step! It will take all the remaining sectors # and make `sgdisk` not able to modify partitions any more! # You better keep at least 10 sectors for the end! # That's because GPT parition table will be saved on both ends of the disk! sgdisk /dev/block/sda --new=0:0:0 --change-name=0:pmOS_root
-
-
(Optional) use
parted
to save the wrongsgdisk
partition table.Currently my
sgdisk /dev/block/sda --print
shows the following:OnePlus6:/ # sgdisk /dev/block/sda --print Warning! Main partition table overlaps the first partition by 6 blocks! You will need to delete this partition or resize it in another utility. Disk /dev/block/sda: 61677568 sectors, 235.3 GiB Sector size (logical/physical): 4096/4096 bytes Disk identifier (GUID): 714F415D-AEF4-7531-A367-496564A0F5EE Partition table holds up to 32 entries Main partition table begins at sector 2 and ends at sector 2 First usable sector is 6, last usable sector is 61677562 Partitions will be aligned on 2-sector boundaries Total free space is 0 sectors (0 bytes) Number Start (sector) End (sector) Size Code Name 1 6 7 8.0 KiB A02C ssd 2 8 8199 32.0 MiB A026 persist 3 8200 8455 1024.0 KiB A01F misc 4 8456 8711 1024.0 KiB FFFF param 5 8712 8839 512.0 KiB A02D keystore 6 8840 8967 512.0 KiB FFFF frp 7 8968 74503 256.0 MiB A039 op2 8 74504 77063 10.0 MiB FFFF oem_dycnvbk 9 77064 79623 10.0 MiB FFFF oem_stanvbk 10 79624 81647 7.9 MiB FFFF reserve1 11 81648 85695 15.8 MiB FFFF reserve2 12 85696 85823 512.0 KiB FFFF config 13 85824 817983 2.8 GiB A038 system_a 14 817984 1550143 2.8 GiB FFFF system_b 15 1550144 1575743 100.0 MiB FFFF odm_a 16 1575744 1601343 100.0 MiB FFFF odm_b 17 1601344 54030143 200.0 GiB 8300 userdata 18 54030144 54095679 256.0 MiB 8300 pmOS_boot 19 54095680 61677562 28.9 GiB 8300 pmOS_root
And from
parted
’sprint free
command, it shows:(parted) print free Model: SAMSUNG KLUEG8U1EA-B0C1 (scsi) Disk /dev/block/sda: 253GB Sector size (logical/physical): 4096B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 20 0.00B 4095B 4096B boot, esp 21 0.00B 4095B 4096B 12.3kB 24.6kB 12.3kB Free Space 1 24.6kB 32.8kB 8192B ssd 2 32.8kB 33.6MB 33.6MB ext4 persist 3 33.6MB 34.6MB 1049kB misc 4 34.6MB 35.7MB 1049kB param 5 35.7MB 36.2MB 524kB keystore 6 36.2MB 36.7MB 524kB frp 7 36.7MB 305MB 268MB ext4 op2 8 305MB 316MB 10.5MB oem_dycnvbk 9 316MB 326MB 10.5MB oem_stanvbk 10 326MB 334MB 8290kB reserve1 11 334MB 351MB 16.6MB reserve2 12 351MB 352MB 524kB config 13 352MB 3350MB 2999MB ext2 system_a 14 3350MB 6349MB 2999MB ext2 system_b 15 6349MB 6454MB 105MB ext4 odm_a 16 6454MB 6559MB 105MB ext4 odm_b 17 6559MB 221GB 215GB ext4 userdata 18 221GB 222GB 268MB pmOS_boot 19 222GB 253GB 31.1GB pmOS_root 253GB 253GB 12.3kB Free Space
And I use
parted
to remove partitions with number 18 and 19 (since I want to use subpartition for postmarketos, not the entire space.) and Remove partition with number 20 and 21 (this seems to be created by postmarket OS when I previously install to use the whole space? I’m not sure about this, but maybe this is causing the overlapping in partition table problem.)After that,
sgdisk
seems to work fine and I just reboot to recovery again to test if this really works.Turns out we indeed need to reboot to recovery! Then
sgdisk
will complain about partition tables differ! And you will needgdisk
to fix this problem.gdisk /dev/block/sda
Then use
?
command to show detail help page, find the “recovery/…..(expert only)” mode, and regenerate backup partition table at then end of storage (because for me it’s the end-device version that’s being corrupted.)The
sgdisk
,gdisk
,parted
tools can be push to your recovery with adb enabled. (TWRP comes with some of these commands available, but for Lineage recovery you can just adb push these commands.)adb push path/to/local/parted /sbin/parted # push local `parted` to oneplus's /sbin folder adb shell # access phone device shell with adb chmod 777 /sbin/parted # give `parted` exceutable attribute parted # then you can use it!
For my device, it’s arm64, but seems like the 32bit and 64bit version both work for my.
-
Flash postmarket os to your slot B and the newly created partitions
fastboot erase dtbo_b # erase the device tree on slot B
-
option 1: If you use subpartition
sudo fastboot flash systempmos 20250219-1313-postmarketOS-v24.12-phosh-22.5-oneplus-enchilada.img sudo fastboot flash boot_b 20250219-1313-postmarketOS-v24.12-phosh-22.5-oneplus-enchilada-boot.img
-
option 2: If you want to use ALL disk space (including android userdata)
fastboot flash pmOS_boot /tmp/postmarketOS-export/oneplus-enchilada-boot.img fastboot flash pmOS_root /tmp/postmarketOS-export/oneplus-enchilada-root.img fastboot flash boot_b /tmp/postmarketOS-export/oneplus-enchilada-boot.img
fastboot set_active b ls fastboot getvar current-slot fastboot reboot
-
After works
Dual boot status
The Oneplus 6 uses A/B slots, so it has dtbo
, boot
, system
both with A and B, i.e. dtbo_a
and dtbo_b
, boot_a
and boot_b
, and system_a
and system_b
. The android system is flashed to system
partitions and recovery flashed to boot
partitions. The postmarket os data is flashed to systempmos
partition (I’m using the subpartition method) and boot image is flashed to boot_b
.
Therefore, for a working dual boot device, I have:
-
dtbo_a
: the android device tree. -
boot_a
andsystem_a
: the android recovery and system, currently I’m using LineageOS recovery and LineageOS. -
dtbo_b
: erased for booting postmarket OS. -
boot_b
: the postmarketOS boot image. -
system_b
: the backup android system image. -
systempmos
: the system data of postmarket os.
Switch slots:
- postmarketos(slot B) to android (slot A): use the `qbootctl` in postmarketos
- android (slot A) to postmarket os (slot B): boot to fastboot mode and `fastboot set_active b`
Upgrade LineageOS:
1. flash back android images to `dtbo_b` and `boot_b`
```
fastboot flash dtbo_b dtbo.img # not sure if this is necessary. It works out for me without this dtbo flash
fastboot flash boot_b boot.img
```
After this, the android in Slot B should be accessible, then you have android just like before.
__Note:__ You might also need to fix the overlapping partition problem mentioned before for the update to work.
1. Upgrade LineageOS version according to their manual. Just remember to make sure you got slot A the latest version of LineageOS.
1. Check the Lineage OS in slot A is updated and works fine, then go to fastboot/flash mode
1. Flash the boot image for postmarketos
```
fastboot erase dtbo_b
fastboot flash boot_b postmarketos-boot.img
fastboot set_active b # activate postmarket os to check its status
fastboot reboot
```
Upgrade postmarketos:
To be added.
Configure postmarketos (phosh UI)
1. Update and reboot the system
1. Enable SSH
1. Manual scale factor to 2.5
1. Install (Re-install flathub remote repo) according to Alpine linux's flathub guidance (https://flatpak.org/setup/Alpine/)
1. Chinese input method?
Reference
A post about unlock and installing TWRP recovery on OnePlus 6
A post offering attachment of parted
A post about change the size of system partition, offering links to gdisk
attachment