[GUIDE] Flash ROMs/Magisk/TWRP/Kernels on A/B Partition Devices

Ever since Android Devices have been launched with A/B Partitions, more and more users are getting confused regarding the flashing instructions. Most of them end up flashing the files on the opposite partition. Therefore steps needed to flash a Custom ROMs, TWRP, Kernel, Magisk, etc on A/B partition device are covered in this guide. The sequence in which these applications are to be flashed has also been mentioned. Make sure to install them exactly in the same manner as mentioned in this guide.

Flash files on A-B Partition Devices- CP

Partitions in Android

A partition is nothing but a section on your device’s internal storage that holds data. What type of data it holds depends on many factors like hardware, OS, etc. Each Android device has quite a lot of partitions within it (OnePlus 6 has close to 72 partitions!). But as a geeky user, we mostly deal with 5-6 of them. They are:

  • system– it holds Android OS, system apps, system media like boot animations, stock ringtones, and wallpapers, etc.
  • boot– stores the kernel. On A/B partition devices, it also holds the recovery.
  • recovery– holds the recovery. Only present in devices with a single (A-only) partition.
  • userdata– holds all of your apps and internal storage data.
  • cache– it stores temporary data.



How does the A/B Partition Works

Every device that has an A/B Partition works in the following manner:

  1. Out of the two partitions, the Android OS would be present in one of them. let us say that slot is ‘B’. This slot is bootable, active and the current slot.
  2. Now whenever an OTA update is received, it will begin installing it to the inactive slot. In this case, it is the Slot ‘A’.
  3. Till the update process is being carried out, Slot A would remain as unbootable. Even if you try to reboot your device, it will be booted from slot ‘B’.
  4. When the update is finished installing, but you haven’t rebooted your device, Slot ‘B’ would still be the bootable and current slot, but it is no longer the active slot. Slot ‘A’ has now become the active slot.
  5. When you reboot the device, update_verifer would now make the device boot via Slot A. This slot now becomes the bootable, active and the current slot.

Advantages of A/B Partition

But why Google has released the devices with A/B partitions? What advantages does it hold? Well, it has quite a lot of advantages, to be frank, and is quite interesting as well. Read the below points:

  1. Suppose Slot ‘B’ is the active slot. So your device will be running on this slot.
  2. Now you receive an OTA Update. You begin the installation process.
  3. If you had only a single partition, then the OTA would be installed in the same partition- i.e. the active partition currently being used by the OS. If the update gets hindered in between due to some reasons or is not installed successfully, the chances of your device getting bricked increases exponentially. the same would happen if the update gets installed successfully but the device gets failed to boot correctly.
  4. But now, since the device comprises two partitions, the OTA always goes to the inactive slot (Slot ‘A’). In doing so, it ensures that whatever actions it performs has no effect on the other slot- i.e. the active one currently in use by the OS (i.e. Slot ‘B’). So even if the update fails for some reason, your device would remain intact. You could just reboot the device and give the update another try.



A/B vs A: Two Slots, Twice the Storage Consumption?

Now, this is a very interesting question that may come up in your mind- “Earlier my device had a single Slot, but now since the number of Slots has doubled, so is the overall partitions. Hence, will it now consume twice the storage space?”

The answer surprisingly comes out to be NO, not at all. But how has Google managed to do so? What the Silicon Valley Giants have done is on the devices having A/B partitions, they have removed the /cache as well as the /recovery partition. Plus they have also sort of ‘compressed’ to nearly half the size than compared to a device having just a single slot.

Let us take an  example of Google Pixel device, with and without A/B Partitions:

[table id=1 /]

So even after the number of partitions getting doubled, there is only a slight increase in storage consumption (320MB, as opposed to 4680MB). Quite impressive, Google!

Does Custom ROM create any Issues in A/B Partition Devices?

This is among the greatest misconception that many users have. Flashing a custom ROM in  A/B partition devices have been given so much unnecessary negative attention that users think twice before attempting to flash a custom ROM. But very few knew the real picture behind it.

When you flash a custom ROM, TWRP does most of the work for you behind the scene. You will never have to select a slot while flashing a custom ROM, it will be automatically flashed to the inactive slot. It is the same scenario as in the case of an OTA. You only need to select the ROM zip and right swipe to flash. Then after the installation is over, just Reboot your device. The device will now function on the opposite slot- the slot on which you just installed the ROM. This slot is now the active slot, whereas the earlier one becomes inactive. That’s it.


Flashing Different Types of Files in A/B Partition Devices

Till now you might have got a fair bit of picture regarding the Slots and A/B Partition. With the required knowledge in hand, let’s move on to the most important section of this guide- How to Flash various files (like Custom ROM, Custom Recovery, etc) in devices having the A/B Partition.

TUTORIAL : How to Flash Various Files in A/B Partition Devices

Hence, this was a detailed guide covering various aspects regarding how to flash ROMs, recovery, etc on A/B partition including its advantages and other interesting facts. After going through the guide, I hope you might have got the message: dealing with the A/B partition devices is not as difficult as it seems.

Even for the developers, it has been a boon. Here is what the LineageOS team says on A/B partition- “Many around the Android community have bashed A/B as being ‘hard to support’ and ‘not developer-friendly’, when in fact, properly implemented it is easier to support and just as developer-friendly“.

With this, we come to the end of the guide on How to Flash ROMs/Magisk/TWRP/Kernels on A/B Partition Devices. If you have any queries whatsoever, just have your say in the comment section below. Also, if you want a similar detailed explanation guide on any other topic related to Android, just raise a request by going over to the Request Page. Happy Flashing!

SOURCE:  GOOGLE’S ANDROID BLOG | XDA