Background and Preparation

By Fenguoerbian

March 16, 2025

This post is for some background knowledge and preparation for tinkering my OnePlus 6.

In the end, my OnePlus 6 would be dual-booting both Android 15 (LineageOS 22 on slot A) and PostmarketOS (on slot B).

Preparation

On the computer

You will need a computer with fastboot tools(SDK platform tools). This can be obtained by installing the android-tools package on Linux or by installing the Android SDK Platform-Tools on Windows, Mac (or Linux).

On the phone

  1. Boot to LATEST stock system (Andoid 11) on BOTH slots.

    Note: OnePlus 6 is a ab-slot phone. You have to use the custom recovery mentioned later to manually change slot and update Android on each slot to the latest version. This is to guarantee that you have the latest firmware, which is packed in the stock OS in BOTH slots.

  2. Learn how to enter flash mode/fastboot with key combo (or adb command)

    flash mode/fastboot on the phone will be used multiple times in later procedures. This mode has some quick access, like entering usual system, entering recovery mode, and run some commands etc. For OnePlus 6, there’s multiple ways to enter this mode:

    • Key combo for Oneplus 6: Unplug from USB and hold Power and Volume Up until you see a screen showing the word START and information about the device.

    • Or the adb command adb reboot bootloader

    • Or (on phones with OxygenOS or HydrogenOS) enable the advanced reboot option in the later section so that you can directly reboot to fastboot mode or recovery mode instead of using the key combo.

  3. Unlock bootloader

    The bootloader needs to be unlocked so that different OS (be it Android ROMs or Linux such as PostmarketOS) can be installed on the phone. Because of this, the phone will state that the system might not be safe and some Android integrity checks (e.g. from Google Play service) might fail since they can not verify that your phone is at verified factory state.

    To unlock your bootloader. For the T-Mobile version of the device in the US, refer to Google for guides on obtaining an unlock code. If your device is not carrier locked, the following is all that’s needed to unlock the bootloader:

    1. Open Settings, go to “About” and tap on the “Build number” box ~10 times until the “You are now a developer” toast message appears.

    2. Go back to the main settings page, go to “System” and then “Developer options” (it might be hidden behind a dropdown menu). Toggle the switch to “Enable OEM unlocking”.

    3. Enable Advanced reboot at the same page, so that you can long-press power bottom and select fastboot/bootloader mode or recovery mode instead of using the key combo.

    4. Refer to “How to enter flash mode” above to get into fastboot mode, then re-attach your USB cable. Run the following command on your host:

      fastboot devices    # checking the device linked to your computer
      fastboot oem unlock    # unlock bootloader
      

      If you see < waiting for any device >, try running as sudo and restart your device into fastboot mode again by selecting “Restart Bootloader” on the device.

    5. Read the message displayed on your device screen. Once read, confirm the unlock if you’re willing to proceed. THIS WILL ERASE YOUR DEVICE’S INTERNAL STORAGE.

    All done! You can now continue with this guide.

  4. Install a custom recovery (after unlocking the bootloader)

    • TWRP recovery: this is a very popular recovery because it packs a lot of functionality. But its update pace is quite slow recently so it might not support recent Android. For me, it does not support installing LineageOS 22, which is Android 15, but does support OnePlus 6’s factory images, which are based on Android 11 at most.

      1. Download the latest TWRP image file(.img) from the website.

      2. Put the TWRP image to the root folder of the phone’s internal storage. For simplicity, you can rename it to twrp.img.

      3. Enter the flash mode (refer to previous notes) and connect to your computer via USB

      4. Temporary boot the downloaded image using the following command:

        fastboot boot twrp.img
        

        Preferred Installation Method: Once booted, navigate to the Advanced > Flash Current TWRP option. This will install the TWRP image you just booted permanently to the device.

        NOTE: You also need to use the “Fix Recovery Bootloop” option present in the same Advanced Tab. Use that option after you have installed the recovery ramdisk successfully to avoid boot loops happening from installing TWRP Permanently.

    • LineageOS recovery: this is a recovery recommended by Lineage community for installing LineageOS. It is simple, and packs only essential functionalities.

      The instruction for LineageOS recovery on OnePlus 6 is here. In summary, the steps are:

      1. Download the lates recovery, rename it to boot.img.

      2. Enter fastboot on your phone, and connect it to your computer. Use the following command to check the phone has been identified by the computer.

        fastboot devices
        
      3. Flash the recovery with fastboot commands from the computer:

        fastboot flash boot boot.img
        

        Note: Here boot.img is being flashed to boot without any _a/’_b’ indication, which means it should be flashed to BOTH the boot_a and boot_b partitions.

      4. Reboot to recovery to verify the installation.

  5. Install Magisk:

    To be added. I do not install Magisk on my phone.

    Note: seems like magisk can also detect/unpack/extract from a full stock image file to get the boot.img file that it needs to patch.