Home > ROMs

How to Flash Various Files in A/B Partition Devices

In my earlier blog, I already covered the explanations about the A/B partitions, including how it works, its advantages, etc (You could refer here: How to Flash ROMs/Magisk/TWRP/Kernels on A/B Partition Devices). This guide will have an in-depth look at How to flash various files, including Custom ROMs, TWRP, Kernels, Magisk, etc in A/B Partition Devices. Just be sure to follow each and every part of this tutorial in the exact same manner as mentioned.

FLASH FILES IN A_B PARTITION DEVICES- CP

For your convenience, this tutorial will be broken down into short sections, with each section having instructions for different types of files to flash.


Before beginning with the process, keep the following things in mind:

  1. When you flash a ROM through Recovery, it will be flashed to the inactive slot. This is the reason why you need to switch slots every time (so as to move to the ‘inactive’ slot and in the process make it the ‘active’ one) after flashing a custom ROM and then flash everything else.
  2. But until you reboot the device from Recovery, your active slot isn’t going to change and you will still be the previous OS (and not the ROM you just installed). That is why we recommend rebooting the device so as to get to the slot where the newly installed OS is present, and hence make it the active one.
  3. Always flash the files in the following order:
    • TWRP
    • Custom ROM
    • Custom Kernel (optional)
    • Magisk (for root).

 Prerequisites

  • A complete backup of all the data on your device is extremely important. This is because, during the process, your device’s storage will completely be wiped off.
  • Keep your device at a minimum of 60% charged so that it doesn’t turn off in between.
  • Make sure to unlock the bootloader of your device. Refer to our guide on how to do so.
  • Download and install the ADB and Platform Tools. Now head over to this platform-tools folder, type in CMD in the address bar, and hit Enter. This will launch the Command Prompt.
    command prompt
  • Enable USB Debugging and OEM Unlocking on your device: Go to ‘Settings’ > ‘About Phone’ > Tap on the ‘Build Number’ 7 times > Go back to ‘Settings’ > ‘Developer Options’ > Toggle on the ‘USB Debugging’ and ‘OEM Unlocking’ switch.

    oem unlock usb debugging
    Reference Image

Downloads

  • Download the TWRP Recovery (both the image and zip file) for your device from the official site. If it isn’t officially released yet for your device, try the unofficial one. It would be available at the XDA forum.
  • Next, download the Custom ROM and Kernel of your choice. Custom ROMs could be downloaded here: Top 5 Custom ROMs based on Android 9.0 Pie (2019). or you could check out the XDA site as well.
  • Also, download the latest Magisk installer zip file: Magisk latest file (for root-access).
  • Finally, download the GApps package corresponding to the device’s architecture and Android OS. Then choose the desired variant.

A note on GApps

  • Under device architecture, select ARM64 for your device. However, if you want to double-check, download the ‘CPU-Z’ app. Under the ‘System’ tab, look for the ‘Kernel Architecture’- if it is armv7a,  armv8l or related types, then it is definitely ARM64.
  • If you are short on time (and also internet), then simply go for the ‘mini‘ variant. It contains the most basic yet important Google Apps and Services. The rest could be downloaded once the device boots up to the OS.
  • Some ROMs like the ‘Pixel Experience’ already have Gapps included, so you wouldn’t be needing it. Always check on the ROMs’ development/support page (or ask me in the comments section) before downloading the Gapps for any ROM.

STEP 1- Setting Up Your Device

If you are coming from a stock ROM, you need to wipe your data and files. Follow the below points:

  1. First off, connect your device to PC via the USB Cable.
  2. Next, in the PowerShell window, type in the below code to boot your device to fastboot mode:
    adb reboot bootloader
  3. Now type the below code to wipe all of your device’s data and files:
    fastboot -w

An important point worth discussing: The custom ROM you are about to flash will be flashed to the inactive slot. So we will be starting this tutorial by taking Slot B as the active slot (hence Slot A would be the inactive slot- where the custom ROM would be installed). If you have Slot A as the active, change it right now by typing the below code in the PowerShell Window:

fastboot set_active b

STEP 2: Installing TWRP Recovery

With Slot ‘B’ as the active slot, we will begin with the installation process. The process starts with booting the TWRP Recovery and then subsequently flashing it on your device. Carry out the below-mentioned steps for the same:

  1. Rename the downloaded TWRP recovery (the .img file) to twrp (the complete name would hence be twrp.img)
  2. Place it inside the folder where you have installed ADB and Fastboot Platform Tools.
  3. Now we will be temporarily booting the device to recovery mode. I have already explained in my previous guide that there is no separate recovery partition for A/B partition devices. Hence TWRP could not be flashed directly by fastboot commands. As it is present inside the boot partition, therefore we will be booting into recovery first and then flashing it. Type the below code to boot into recovery:
    fastboot boot twrp.img

    (If this method of booting to recovery doesn’t work out for you, refer to the FAQs section at the end of the guide).

  4. Your device will boot to TWRP Recovery. Now you need to erase all the data present on the device. Go to ‘Wipe’ > Select ‘System’ and ‘Data’ > Right swipe on the ‘Swipe to Wipe’ button to wipe the selected partitions.
    FLASH FILES IN A_B PARTITION DEVICES- WIPE PARTITIONS
  5. Next, go to ‘Mount’ and enable the ‘MTP’ option. The device will now be visible on your PC. Transfer the TWRP zip file, ROM, GApps package, Magisk, Kernel and anything else you need to flash. (If MTP didn’t work out for you, refer to the FAQs section at the end of this guide).
    FLASH FILES IN A_B PARTITION DEVICES- ENABLE MTP
  6. We will start by flashing the TWRP zip file. Go to ‘Install’, select the TWRP zip file and perform a right swipe on ‘Swipe to confirm Flash’.
  7. [IMPORTANT] Now reboot your device again to TWRP Recovery. Go to the ‘Reboot’ option of TWRP and select ‘Recovery’.

That’s it. The first part of the guide on how to flash various files in A/B partition devices is now over. Head over to the next section to install a Custom ROM.



STEP 3: Installing a Custom ROM/Kernel/Magisk

  1. Go to Install and select the ROM you wish to install.
  2. Right swipe on the ‘Swipe to confirm Flash’ to install the selected ROM.
  3. Currently, the ROM would be installed on the inactive slot (Slot A), whereas you are working on the active slot (Slot B).
  4. Go to ‘Reboot’ and select ‘Slot A’ – the current inactive slot on which the Custom ROM is installed.
  5. In order to make Slot A the active one, Reboot your device to Recovery. Tap the back button and select ‘Recovery’ from the TWRP ‘Reboot’ menu.
    FLASH FILES IN A_B PARTITION DEVICES- SLOT CHANGE
  6. Now flash ‘GApps‘ if required by your ROM.
  7. [Optional] Flash a custom kernel if you want.
  8. [Optional for Custom ROM, Compulsory for Stock] Flash DM-VERITY & FORCE ENCRYPT DISABLER. This is needed to disable DM verity and encryption in the vendor partition. Most of the custom ROMs already do this. But Stock ROM doesn’t. So it is necessary to flash this file if you prefer to stay on the stock. Still, if you are using a custom ROM, consider flashing it. It wouldn’t do any harm even if isn’t required by your custom ROM.
  9. Now, if you want root access, consider flashing the ‘Magisk‘ zip file. Select ‘Magisk-v19.3.zip’ and right swipe to confirm flash.
  10. Finally, go to ‘Reboot’ and select ‘System’. This will reboot the device to the Android Operating System.

Final Thoughts

After performing the above steps, you will be able to boot your device to the TWRP Recovery. Then using the Recovery, you would have flashed a custom ROM. And finally, you rooted the device using the Magisk Installer zip file. Therefore, in a nutshell, this is what we did:

  1. Temporary Booted to TWRP Recovery using Fastboot.
  2. Permanently installed the TWRP Recovery using the booted TWRP.
  3. Installed the Custom ROM via TWRP.
  4. Installed Kernel (if you chose to).
  5. Flashed DM Verity and Force Encrypt Disable (compulsory on stock, optional for custom ROMs).
  6. Finally, we flashed the Magisk zip file from the TWRP recovery to get root access.

So this was the comprehensive guide on How to Flash Various Files and Mods in A/B Partition Devices. If you are having any queries with respect to any part of this guide, first have a look at FAQs below. However, if the problem still persists, do let me know in the comments section below. Happy Flashing!

FAQs

Q1) How to boot my device to TWRP recovery if the fastboot boot twrp.img command fails?
A1) If the above command fails or gives you a bootloop, ‘force shutdown’ the device and try the above fastboot command again.

Q2) “Transferring files using MTP didn’t work”.
A2) You may try any one of the following alternatives:

  • USE THE SIDELOAD METHOD: Transfer the file to be flashed to ADB and Fastboot Platform Tool’s folder. Next, under TWRP, go to ‘Advanced’ > ‘Sideload’ > ‘Swipe to Start Sideload’. Now, in the PowerShell window, enter the following command- ‘adb sideload filename.zip’.
    FLASH FILES IN A_B PARTITION DEVICES- ADB SIDELOAD
  • USE THE ADB PUSH METHOD: The file to be flashed should be present inside the ADB and Fastboot Tools folder. Under TWRP, go to ‘Advanced’>’File manager’.
    FLASH FILES IN A_B PARTITION DEVICES- FILE MANAGER
    Now navigate to the ‘data/media’ folder. If the folder named ‘0’ is not present there, then create it. This can be done by going to ‘Advanced’>’Terminal’ and typing the below codes (codes are after the image):
    FLASH FILES IN A_B PARTITION DEVICES- DATA-MEDIA
cd /data/media
mkdir  0
  • Next, open PowerShell window on your PC and type the below code:
adb push filename.zip /data/media/0/

That’s all from the tutorial on How to Flash Various Files in A/B Partition Devices.

Share: