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

From postmarketOS
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

Custom Partition

Splitting userdata for a/b slot dual booting

Using a modified recovery, it is possible to split the userdata partition. (Keep in mind to first use Android 9-based recovery, and match the version mentioned in the modified recovery's name, as suggested in the link above)

A/B partitioning was tested and works perfectly with FDE enabled on pmOS and FBE enabled on Android, although data sharing will not work with an A/B partition layout if encryption is used. A common data partition may be possible with the A/B/C layout option available. Since the pmOS initramfs searches for a partition label instead of a specific partition, it will automatically detect the partition that the pmOS rootfs was installed to.

Reverting back to stock partition layout from spliting userdata

Reverting to a stock partition layout from the modified userdata layout is extremely simple. Simply boot into TWRP on either slot, push the Dualboot mod to /tmp/ as before, and flash. When the installer asks if you would like to keep your current layout, select no, and then select the stock layout when prompted. Follow the rest of the instructions as you would like (if you are going to be reflashing OOS afterwards, these options do not matter).

Partitioning for booting pmos via Renegade Project/uboot

First remove unused partition (see #Erasing unused partitions/Custom formatting)

Note pmOS_boot and pmOS_root has to be labeled in the file system . postmarket os initemfs check the partiton label via file system not the gpt partition table.
Note pmOS_boot has to be fat32

Then create two partition : pmOS_boot and pmOS_root (see Partition Layout)

Partitioning for dual booting pmos with other uefi based os via Renegade Project/uboot (windows may not able to boot via uboot)

First fellow #Partitioning for booting pmos via Renegade Project

Next create partition for your uefi based os needed (for example : openbsd , netbsd , freebsd ,windows) useually need 2 partition : uefi/boot partition , root partition).

Erasing unused partitions/Custom formatting

Icon WARNING: After performing these steps, it will be IMPOSSIBLE to run ANY downstream OS, including, but not limited to OxygenOS stock ROMS, ANY custom Android ROMs, ANY Halium-based Linux distro, or anything else not using a MAINLINE Linux kernel from the sdm845-mainline team/Linaro.

On Oneplus 6, It is safe to wipe partitions /dev/sda13-17 (system_a , system_b , odm_a , odm_b , userdata) without any harm being done to the bootloader. Erasing these partitions will leave only mainline kernels bootable.

If you haven't flashed vbmeta_a and vbmeta_b with --disable-verity and --disable-verification, the bootloader performs some checks on the system partition, so only odm and userdata can be safely removed.

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

Since only advanced users should be doing this, no detailed instructions are going to be provided in this guide (ie: no copy/pasting Terminal commands). Man pages are helpful here if you do not know how to use a tool.

There are two way to do to custom partition:


1. Using partition tools on OnePlus 6/6t
You need to find a working aarch64 binary of sgdisk, parted or other partition tools. If you have an OS of any kind installed to your phone, you can get it from there. Then find a way to run that binary in a Terminal on your device like using a Custom android recovery (like orange fox, twrp), livingbooting/Netbooting mainline Linux (pmOS supports netboot) or a custom postmaketos android boot image that has the debug shell enabled and included the parted or sgdisk or other partition tools. They all will work as long as nothing is accessing the device storage. (For some reason parted error out on custom android recovery when doing custom partition).


2. Partiting via other device
Renegade Project 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.
You can delete some partitions (See the text above) and create whatever partitions you want, then change the labels to whatever you want. For instance Syboxez created two partitions of different sizes: one named 'rootfs_stable' for postmarketOS, and one named 'rootfs_temp' for other mainline distros. Make sure your labels do not conflict with any existing partitions.

After creating the partitions, fastboot will successfully flash images to those partitions using the labels you assigned to them. So for instance, 'pmbootstrap flasher flash_rootfs -- partition rootfs_stable' would work fine, along with using 'fastboot flash rootfs_temp linuxdistrotwoelectricboogaloo.img' Converting to sparse images isn't necessary, since fastboot will do that for you.

Reverting to stock partition

To revert to stock, MsmDownloadTool or bkerler's edl tool with an extracted ops is necessary. Normal unbricking instructions through EDL mode apply here. If for any reason, it is impossible to access EDL mode anymore by plugging in a USB cable while the phone is off and volume up is being held down, then the phone is bricked.

Dual booting

Dual boot pm os with android via a/b slot

Note You need to partition your phone phone first. (See #Splitting userdata for a/b slot dual booting).

To install Android on slot A and pmOS on slot B:
(NOTE: if you would like to use Jumpdrive, then you will need to put pmOS on Slot A)

  • Remember that all zips will always flash to the opposite slot.
  • First, install the latest version of OOS 10 onto both slots via recovery, or via stock local upgrade. (In Syboxez cases, it was possible to just install LineageOS in both slots, which allows to skip the next step and installing Android custom ROM later on.)
  • Because OOS 10 was installed, "fastboot boot" will stop working, so you may need to flash a working recovery (such as LineageOS recovery) to either boot_a or boot_b (or just boot to flash to your current slot) partitions from fastboot is necessary.
fastboot flash boot lineageos-18.1-202xxxxx-enchilada-recovery.img
  • Select Reboot Recovery and sideload a working version of TWRP.
adb sideload twrp-3.4.0-3-enchilada-installer.zip
  • Reboot recovery. Push the Dualboot zip:
adb push Dualboot_TWRP_OP6_enchilada_v6_2.zip /tmp/
  • Now in TWRP, install and navigate to /tmp/Dualboot_TWRP_OP6_enchilada_v6_2.zip and install it. Select the options that you would like.
    For encryption, keep slot B as-is, and make sure you select no for Magisk on slot B.
    Options for Slot A are up to the user.
  • After installation, Reboot to recovery. Go to reboot, select Slot B, and reboot to recovery again.
  • Install the Android ROM you would like, then without rebooting, reflash the Dualboot mod to repatch the boot.img with the recovery ramdisk.
  • Reboot to recovery again.
  • Currently, there seems to be a bug with the Dualboot installer, where it will always disable encryption on Android.
    If you would like file-based encryption enabled, you will have to manually patch the fstab.
# If you want encryption enabled in Android:
adb shell mount /dev/block/sde16 /vendor #Mounts vendor_a to /vendor
adb pull /vendor/etc/fstab.qcom ./
  • In the line that mounts userdata, there will be an option listed as such: "... ,=ice, ...". If you would like encryption enabled, change that to "fileencryption=ice" and push it back with
# If you want encryption enabled in Android:
adb push ./fstab.qcom /vendor/etc/fstab.qcom
  • Select reboot and make sure Slot A is the current slot, then back out without rebooting.
    Install any addons you may want (GApps if you need them, for example).
    Format data (do not just wipe Internal Storage) and reboot.
  • Once Android boots, verify that your phone is either encrypted or not encrypted (depending on what you wanted) and reboot to the bootloader.

To flash postmarketOS to slot B, follow the general OP6 pmbootstrap install instructions (optionally with --fde to enable full disk encryption) and flash:

fastboot --set-active=b
fastboot erase dtbo_b
pmbootstrap flasher flash_rootfs --partition userdata_b
pmbootstrap flasher flash_kernel --partition boot_b
fastboot reboot

You should now be booting into postmarketOS.

  • Note: Make sure OTA updates are disabled in your Android ROM. It will mess with things if it is not.
  • Note: In mainline Linux, userdata_a is /dev/sda17 and userdata_b is /dev/sda18

Rebooting to specific OS

On the go

To reboot to pmOS from Android:

  • either use bundled Dualboot Companion app (note - it did not work for me, because Syboxez did not root my Android ROM)
  • or simply boot the recovery, go to Reboot, switch to the opposite slot then pick Reboot and Do not install.

To boot Android from pmOS, use command:

sudo qbootctl -s a

Using fastboot

To switch to Android, reboot to bootloader, and use fastboot to switch slots:

fastboot --set-active=[a|b]
fastboot reboot

Updating Android

Updating Android is a bit more of a pain, since Android ROMs are always flashed to the opposite slot.

  • Backup your pmOS boot.img (located at /boot/boot.img in pmOS) to your PC.
  • Grab this script (adapted from LineageOS original), which will copy your boot and dtbo partitions from Slot A to Slot B, temporarily overwriting the pmOS kernel/initram.
  • Boot into TWRP on your Android slot (Slot A in this case) and start sideloading:
adb sideload copy-boot.zip
  • Switch to your pmOS slot (Slot B in this case), reboot to recovery, update your ROM, flash the Dualboot mod again, repatch the fstab on vendor_a in Slot A recovery for encryption if necessary (or just copy back the one you modified before), install GApps/other addons in Slot A if necessary, and reboot to bootloader.
  • Reflash the pmOS kernel:
fastboot --set-active=b
fastboot erase dtbo_b

#If you have a pmOS boot.img backup:
fastboot flash boot_b /path/to/backup/pmOS/boot.img

#Alternatively if you did not make a boot.img backup (do not run the command below if you ran the command above this line):
pmbootstrap flasher flash_kernel --partition boot_b

fastboot reboot

Dual booting pmOS with other uefi based os via Renegade Project/uboot(windows may not able to boot via uboot)

Note You need to partition your phone phone first. (See #Partitioning for dual booting pmos with other uefi based os via Renegade Project).

By default (expect for The generic Qualcomm SDM845 port ) , pmOS utilize subpartitions to fit the boot partition (pmOS_boot) and root partition (pmOS_root) into a one normal partiton on oneplus 6/6t and many device (see Partition Layout).That partition scheme isnt suitable for booing pm os via Renegade Project because of leak of uefi partition so you need to convert pm os "subpartitions" partition scheme to "Use the whole storage device" partition scheme. (pmOS_boot had to be fat32/16). After that you you need to add pm os to Renegade Project boot menu (make sure uefi runtime checkbox isnt ticked otherwise the audio will not work) or install a uefi bootloader to pm os.(if you want the aduio to work , do the first one ) or make a boot menu in uboot via custom config or custom build of uboot.

Note Most of the pre-build os disk image found online are not made for 4k sectors.The oneplus 6/6t use 4k sectors.Therefore you have to convert those os image to 4k sectors before you flash the partition image to your phone partituon.

After all that , you can install other uefi based os by fellow their guies.If you done all that correctly , you should saw a boot entry for other uefi based os in Renegade Project or .If you are using uboot then you need to make a boot menu via custom config or custom build of uboot.

Dual booting pmos with other uefi based os and android via Renegade Project/uboot(windows may not able to boot via uboot) and slot A/B

Note Dont delete the userdata partition

First install android in slot a (See #Dual boot pm os with android via a/b slot )

Next install Renegade Project slot b

Then fellow #Dual booting pmos with other uefi based os via Renegade Project/uboot(windows may not able to boot via uboot)