OnePlus 6 (oneplus-enchilada)/Multi Booting and Custom Partitioning

From postmarketOS Wiki
Icon WARNING: THIS PROCESS CAN BRICK YOUR PHONE IF DONE INCORRECTLY! IF YOU DON'T FEEL COMFORTABLE RECOVERING YOUR PHONE VIA EDL MODE, DO NOT ATTEMPT THIS
Note Currently,There are 2 UEFI Implementation support 6/6t (Renegade Project,this fork of uboot(See Qualcomm_SDM845_(qualcomm-sdm845))

Custom Partition

Editing Partition Table

In this sector we will cover variant of way to edit partition table

Using partition tools on OnePlus 6/6t

Custom recovery mode

You need to find a working aarch64 binary of sgdisk, parted or other partition tools. Then find a way to run that binary in a Terminal on your device like using a Custom android recovery (like orange fox, twrp).For some reason parted error out on custom android recovery when editing custom partition.

pmOS

Netbooting pmOS or a (Modified) postmaketos boot.img (like Jumpdrive )would work in that case. They all will work as long as they has included the parted or sgdisk or other partition tools , nothing is accessing the device storage.

Partiting via other device

Some UEFI Implementation (like Renegade Project,uboot) has provide usb mass storage mode which can expose the whole ufs via usb mass storage so you can do partitioning via another device and this mode.

Custom Partition Scheme

Android

Before you create any custom partition , it is always a good idea to follow those 2 guides at below to free up some space for custom partition.

Shrink Uesrdata

Shrink Uesrdata is required to free up space for custom partition.

1. Shrink Uesrdata in the partition table

2. boot up to twrp to format userdata

After that you should able to see some free space for custom partition.

Remove Android Partition

On Oneplus 6, It is safe to wipe those android partition /dev/sda13-17 (system_a , system_b , odm_a , odm_b , userdata) without any harm being done to the bootloader.

However on Oneplus 6T,you can only safely remove userdata (/dev/sda17).


pmOS

Creating Custom Partition for Subpartitions partition scheme
Note As of now , pmOS only support subpartition on the system* (Any partition that has prefix of system) partition or userdata partition.Also system* and userdata has to be labeled in the gpt partition table. The postmarketOS initramfs checks those partiton label via gpt partition table , not the file system. Therefore the partition have to have a system prefix in the label.However In order to not confuse the bootloader.DO NOT LABEL THE PARTITION WITH NAME LIKE system system_a system_b system_c userdata.For example systempmos is a perfect name that would work.

1. Create a Partition that named as systempmos in the partition table.

Creating Custom Partition for "Use the whole storage device" partition scheme
Note pmOS_boot and pmOS_root has to be labelled in the file system. The postmarketOS initramfs checks those partiton label via file system, not the partition table. However It is recommended to label those partition in the partition table if you want them to be flashable in fastboot.(It doesn't matter what you have labelled them in partition table.As long as fastboot is able to read those label.)
Note The disk image the generated by pmbootstrap has already been labelled

1 . Create a new boot partition that labelled as pmOS_boot in the file system

2 . Create a new root partition that labelled as pmOS_root in the file system

Windows

In order to boot Windows you need to create :

  • ESP partition: Windows's Boot/EFI Partition
  • Windows partition: Windows's Main Partition

Multi Booting

There are few configuration for multi booting :

UEFI Implementation Only

Android

Since you don't boot Android in this configuration , please follow #Remove Android Partition

UEFI OS
Note if you want to install pmOS as UEFI OS,please refer to #pmOS in #Tips and trick
Note Most of the pre-build OS disk images found online are not made for 4k sectors. The OnePlus 6/6t uses 4k sectors. Therefore you have to convert the OS image to 4k sectors before you flash the partition image to your phone partition.

After freeing some space , then make some custom partition for the UEFI OS of your choose and follow the installation instructions of the UEFI OS.You should able to see the UEFI OS in the boot menu of the UEFI Implementation.If your UEFI Implementation dont have boot menu and you have multiple installed UEFI OS, you might need use a bootloader for managing multiple UEFI OS.

UEFI Implementation

There nothing special to it.As long as it boot then is it fine.

UEFI Implementation + A/B slot

Currently It is possible to dual boot variant UEFI OS and Android via A/B slot.

Android

The Android OS should be installed on the phone's slot A already and you need to fellow #Shrink Uesrdata to free some space for custom partition.

UEFI OS

See #UEFI OS in #UEFI Implementation Only

UEFI Implementation
Note As of now most of the UEFI Implementation cant replace the stock bootloader due to chain of trust thus they useually are chainloaded from the stock bootloader.

Currently this configuration only support those UEFI Implementation that is chainloaded from the stock bootloader.

1. Flash the boot.img of the UEFI Implementation in to slot b (boot_b)

After that , The UEFI implementation should boot if you selected slot b.

A/B slot Only

Currently, the dedicated port of pmOS would generate boot.img by default so that allow pmos to be directly booted from the stock bootloader.Due to that it is possible to dualboot pmos and android using via A/B slot mechanism from the stock bootloader.However generic port would not generate boot.img by default (due to it only support UEFI) but it is possible to make the generic port generate boot.img by editing /etc/deviceinfo.

Android

There are not much need to do.The Android OS should be installed on the phone's slot A already.If you want to/need to do custom partition then fellow #Shrink Uesrdata to free some space for custom partition.

pmOS

There are two ways to run pmos : run pmOS in dedicated partition or Stowaway (Sharing userdata with android).


Before Flashing pmOS's Subpartitions/Stowaway/boot,root partition to your device , you have to

1. Flashing pmOS's boot.img into slot B

2. fastboot erase dtbo_b


After following all the instructions (including those that are at below) , The pmOS should boot if you selected slot b.

Run pmOS in dedicated partition :

There are two partition scheme you could use for that : "Use the whole storage device" and "Subpartitions"

Note Currently Only the generic port use "Use the whole storage device" partition scheme.However the dedicated port of 6/6t use "Subpartitions" scheme .Once pmaports!5369 is merged,new installation would use "Use the whole storage device".
"Subpartitions"

If you don't want to do custom partition then flash pmOS Subpartitions to system_b but you will be limited to the the small partition size of system_b. If you want to bigger partitions then follow #Creating Custom Partition for Subpartitions partition scheme and install pmOS to your own custom partition.

"Use the whole storage device"

It is required to do custom partition for this partition scheme.

1. Follow #"Use the whole storage device" partition scheme to create a custom partition

2. Flash to the boot partition and root partition to your custom boot,root partition

Stowaway

See Dual Booting/WiP#Stowaway

Switching OS

UEFI

You should able to switch variant OS via boot menu of your UEFI implementation boot menu or bootloader (if you use Bootloader to managing multiple UEFI OS).

Slot A/B

fastboot

you can switching to Slot different slot via fastboot mode

Switch to slot A
$ fastboot set_active a
$ fastboot reboot
Switch to slot b
$ fastboot set_active b
$ fastboot reboot
Check Current Slot
$ fastboot getvar current-slot

pmOS

Note Those instruction may not work if pmOS is installed as UEFI OS
Switch to slot A
$ qbootctl -s a
Switch to slot b
$ qbootctl -s b
Check Current Slot
$ qbootctl -c

Android

There are a Android apps Switch My Slot . It is for switch slots.It required root access to work.

UEFI implementation

Depend on your uefi implement.There might be a option for switching slot in the boot menu.

Tips and Trick

UEFI Implementation

uboot

There are boot menu in the fork of uboot .However that isn't for booting multiple UEFI OS.you might need to make your own custom boot menu or use a bootloader for managing multiple UEFI OS.

UEFI OS

pmOS

Note The following sector is for installing/booting pmos at UEFI OS
Note Currently Only the generic port support UEFI.However the dedicated port of 6/6t dont .Once pmaports!5369 is merged,dedicated port of 6/6t would support UEFI.
Note Under #UEFI Implementation Only configuration , you might not need to create a boot partition.For example you can be used some Android partition (like op1} as boot partition.

pmOS would use "Use the whole storage device" if it is installed at UEFI OS.Please follow #Creating Custom Partition for "Use the whole storage device" partition scheme if you need to do custom partition.Also Depend on UEFI implementation , you might not need to do `fastboot erase dtbo`

Renegade Project UEFI Implementation

The following sector is for issue with pmos and Renegade Project UEFI Implementation. Renegade Project can boot pmOS without without uefi runtime (See [1]).

Audio don't work

Booting pmOS under Renegade Project UEFI Implementation via the normal uefi way is known to have broken audio . However it is possible to boot pmos without uefi runtime for getting around the issue.

pmOs_boot dont appear in the boot menu

For some reason it failed to read fat32 that flashed from image that made by pmbootstrap.Those follow step seemed to fix the issue :

1. Copy anything that in the boot partition

2. Reformat the boot partition

3. Copy everything back

4. Modifies the fstab to have the new uuid of the reformatted boot partition

5. Regenerate the boot config via mkinitfs

Android

Upgrading/Flashing Android

Icon WARNING: Make sure you selected the right slot before you upgrading/flashing android.

If you decided to upgrade Android or fresh another Android spin off,then It is always a good idea to backup system_b boot_b because Android might wipe off partition that on the other slot during the process of upgrading/flashing.Generally speaking android wont touch those custom partitions.

See Also