A/B Partition A/B System Update Android Updates Developments Featured Full XDA Google Pixel Google Pixel 2 google Pixel 2 XL Google Pixel XL HTC U11 Life HTC U12+ Lenovo Moto X4 LG G7 moto x4 Moto X4 Android One moto z2 force Motorola Moto G6 Motorola Moto G6 Play Motorola Moto G6 Plus Motorola Moto X4 Motorola Moto Z2 Force News nokia 6 Nokia 7 Nokia 7 Plus Nokia 8 OnePlus 6 project treble Razer Seamless System Update seamless update Sharp Aquos S2 Sony Xperia XZ2 t-mobile moto z2 force Tech XDA Analysis XDA Android XDA Editorial XDA Feature Xiaomi Mi A1

How A/B Partitions and Seamless Updates Affect Custom Development on XDA

How A/B Partitions and Seamless Updates Affect Custom Development on XDA

When Android Nougat launched, it had us speaking about all types of latest options. We received a newly up to date consumer interface for starters together with long-awaited multiwindow capabilities and Vulkan Graphics API help. However one under-the-hood addition flew over the heads of most customers. Android Nougat launched “Seamless Updates” on units that help A/B partitions. The overwhelming majority of present Android units (excluding the brand new Google Pixel and Google Pixel XL) didn’t have A/B partitions on the time and thus couldn’t reap the benefits of seamless updates. The essential premise of this function is that the system has a second set of the system, boot, vendor, and different essential partitions, and whenever you get an OTA replace the replace occurs within the background whereas the second set of partitions are patched which helps you to reboot into an up to date software program construct seamlessly. If an replace fails, you’ll be kicked again to a working construct, which means corporations may have fewer complications to cope with and shoppers are higher protected.

Supporting seamless updates just isn’t a requirement for any new Android gadget, in contrast to Challenge Treble. As such, the overwhelming majority of latest Android units don’t help the function. We’ve been preserving an inventory of all of the supported units up to now, and it’s clear that this function shouldn’t be extensively supported. That’s a disgrace as a result of A/B partitions convey numerous advantages for each common customers and power-users alike. Nevertheless, the function has a little bit of a nasty fame within the fanatic group as a result of it’s perceived to make Android improvement and flashing customized modifications harder. This isn’t truly the case, so we needed to demystify seamless updates and clarify how A/B partitions have an effect on customized improvement on XDA.

Many because of XDA Senior Member npjohnson, a contributor to LineageOS and maintainer of the Motorola Moto Z2 Drive, who helped us reality examine this text.

Partitions on an Android system

A partition is just a discrete part on the telephone’s inner storage the place knowledge is stored. What sort of knowledge is stored on every partition relies upon on the hardware, working system, and many different elements. The bootloader may have one, the system (Android OS) may have one, the consumer knowledge could have one… and so on and so forth. Whenever you see individuals speak about “/system” and “/cache”, they’re referring to the given names for these partitions. The OnePlus 6, for instance, has 72 partitions. That seems like lots, however the OnePlus 6 is likely one of the units that helps seamless updates which suggests many of those partitions are merely duplicates of one another.

Partial output of the partitions on the OnePlus 6. Some A/B partitions are underlined for demonstration functions.

There are numerous partitions on a tool that you’ll by no means have to fret about as a consumer. Many of those partitions are by no means modified when flashing customized ROMs, kernels, recoveries, or modifications like Magisk or Xposed. Plenty of these partitions will both be unused for our functions or are too harmful to the touch until you recognize what you’re doing (XLOADER and OEMINFO on Huawei/Honor units come to thoughts.) For the overwhelming majority of Android customers, the partitions that we principally cope with are system, boot, restoration, userdata and extra lately vendor and vbmeta. Right here’s a quick rationalization of the aim of every partition:

  • system – holds the Android OS, system libraries, system apps, and different system media like bootanimations, inventory wallpapers, ringtones, and so forth.
  • boot – holds the kernel, ramdisk, and on A/B units additionally the restoration as nicely
  • restoration – holds the restoration, the place TWRP is mostly flashed on A-only units (A/B units don’t have a devoted restoration partition)
  • userdata – holds your whole app, system, and inner storage knowledge
  • vendor – holds platform and device-specific HALs, the information crucial for the Android OS to speak with the underlying hardware
  • vbmeta – the partition for Android Verified Boot 2.zero which verifies the integrity of the boot course of

Gadget OEMs can change their partition schemes to make use of no matter format they need. For example, Huawei splits the boot partition into ramdisk_recovery and kernel. There are additionally a number of additional partitions which will include different system apps resembling cust, product, and oem, and whereas these are protected to switch, it’s usually not beneficial if you wish to make it simpler on your self to return to inventory. So the place do A/B partitions play a task?

The A/B Partition Scheme

How updates work on units with seamless updates

The quite simple picture I made under illustrates how an replace is dealt with on a tool with A/B partition help. The partition that’s illustrated is the system partition, although different partitions resembling boot and vendor can also be up to date with any given OTA replace from an OEM. This replace course of occurs with not solely main Android model updates but in addition safety patch updates.

  1. We begin with two system partitions, system_a and system_b, each on the identical model of Android.
  2. Assuming that system_a is lively, the OTA replace will patch system_b, the inactive partition, within the background.
  3. system_a is about to inactive and system_b then turns into lively as soon as the consumer reboots.
  4. The now-inactive partition, system_a, shall be up to date when the subsequent OTA replace rolls out.

What are the advantages of this replace course of?

  1. If an replace fails, the system will roll again to the working construct on the opposite slot.
  2. Your knowledge is stored completely intact, even when the replace is borked, as there is just one partition (userdata) which homes your knowledge.
  3. Replace streaming: In case your knowledge partition is full, then the replace could be downloaded and streamed to the inactive slot. It’s a reasonably neat function and signifies that you don’t should waste any short-term storage on your updates. That’s why there’s no cache partition on A/B units as they’re not wanted.

What impression does the A/B partitioning scheme have on the storage of a tool?

Does the truth that seamless updates end in a bunch of duplicated partitions imply you’re dropping a bunch of space for storing? By no means. Google says that units with seamless replace help ought to solely be down about a number of hundred Megabytes because of eradicating the /cache and /restoration partitions. Eradicating each balances the price of including a second set of partitions. In response to Google, the Pixel’s A/B system picture is half the dimensions of the A-only system picture. A lot of the further storage utilization truly comes from the addition of a second vendor partition. That is sensible as the seller partition homes all the proprietary binaries utilized by OEMs (a part of Venture Treble), so it’s anticipated to take up fairly a little bit of area. Whereas Google doesn’t advocate having A/B partitioning on units with 4GB of storage (because it’s almost 10% of complete out there storage), they do advocate it on units with 8GB and greater.

Right here’s a breakdown of the space for storing used on a Google Pixel with and with out A/B partitions.

Partition Sizes A/B A-only Bootloader 50MB*2 50MB Boot 32MB*2 32MB Restoration zero 32MB Cache zero 100MB Radio 70MB*2 70MB Vendor 300MB*2 300MB System 2048MB*2 4096MB Complete 5000MB 4680MB

What occurred to the restoration partition?

The underlying Linux kernel on Android units is what lets Android acknowledge and use the hardware correctly on a smartphone. On A-only Android units, you usually have two variations of the kernel: One is packed inside the restoration partition whereas the opposite is within the boot partition. On A/B units supporting seamless updates, the restoration is now inside the boot picture together with the kernel. The restoration’s principal perform was to put in updates, however since that’s dealt with by the system itself (update_engine) whereas Android is booted up the devoted restoration partition is not wanted.

To put in a customized restoration on A/B units, we thus want to switch the boot partition and substitute the inventory restoration with our personal. This is the reason to put in TWRP you might want to use a fastboot command in addition a customized boot picture first and then flash the TWRP set up script, as fastboot can’t patch partitions—solely flash over them solely. You possibly can technically pre-patch your present boot picture with TWRP and then flash it by way of fastboot, however that’s extra hassle than it’s value. The TWRP installer script patches each the boot_a and boot_b partitions to put in TWRP.

Enjoyable reality: The Android update_engine which handles seamless updates is principally ripped straight from Chrome OS. Solely just lately have been strings containing “Chrome OS” faraway from update_engine’s log to keep away from confusion for anybody who occurs to examine logcat.

Does my Android smartphone help A/B partitions for seamless updates?

Whereas we hold an inventory of all units that help it, it’s also possible to simply examine your self.

How do seamless updates have an effect on customized improvement?

Consumer Notion of A/B Partitions

Deemed a hindrance to customized software program improvement by many customers, seamless updates are literally a boon to builders. The rationale that A/B units are perceived to have poor improvement help comes right down to the worth of the primary A/B units. In any case, the Google Pixel units have been a number of the first to help seamless updates and in comparison with the Nexus smartphones of yesteryear they have been comparatively costly. Moreover, because of the myriad of enhancements Google has been making to the Android OS which has made customized ROMs and modifications much less widespread on Google units, the Google Pixel smartphones didn’t take off on our boards almost in addition to the Nexus smartphones. A mixture of exterior elements led to a lower in customized improvement on the Google Pixel smartphones, although most customers selected accountable A/B partition help as an alternative. Examine the supply of customized improvement on units just like the Google Pixel with units just like the Xiaomi Mi A1 on our boards.

As well as, a lack of information of how A/B partitions modified the best way customers want to put in customized ROMs, kernels, recoveries, and modifications led to A/B partition help being unpopular. With the restoration now dwelling inside the boot picture, flashing modifications within the fallacious order reminiscent of Magisk or Xposed may cause conflicts and can result in a bootloop. What order you flash these mods in may be necessary, although within the case of customized ROMs you shouldn’t want to fret about what slot you’re flashing to. Opposite to widespread perception, the set up script for many customized ROMs doesn’t flash to each slots. You principally don’t want to fret about that as you shouldn’t must be swapping slots manually.

How Builders View A/B Partitions

When constructing a ROM, builders could make use of each partitions to check separate builds. If one doesn’t work, they will simply revert again to the working partition and rebuild their ROM. Builders may also check for regressions by merely putting in an replace, switching the lively partition, and evaluating the 2 with out having to wipe knowledge. Right here’s how the LineageOS group views A/B partition help:

“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.” – jrizzoli, LineageOS Changelog 19

The preliminary problem with A/B help for builders got here from modifying their present instruments to help these units. The developer of Magisk, topjohnwu, added official help for the Google Pixel a yr after it was launched—not as a result of it was troublesome, however moderately as a result of it took him a yr to truly get hold of the system to work on. TWRP help got here fairly shortly on A/B units after the lead developer, Dees_Troy, took a crack at it. LineageOS 15.1 now helps A/B units after volunteers discovered time to repair their addon.d script.

How to replace an A/B system that has a customized restoration, kernel, or different mods

Custom ROMs

Flashing updates on a tool with a customized ROM signifies that you’ll should be cautious of which slot you’re flashing too, proper? Not fairly. TWRP will truly deal with lots of that for you, and it defaults to the inactive slot for flashing a customized ROM. In case your lively slot is A and you flash a customized ROM, you’re truly flashing to fit B. Once you reboot, the lively slot is now B. Builders can modify the set up script and flash to each slots to make it simpler on the top consumer, though most customized ROM set up scripts at present solely flash to a single slot. Lastly, customized ROMs can implement an A/B updater of their ROM in order that customers don’t even have to mess with manually flashing updates—the newest LineageOS 15.1 features a Lineage Updater software, and XDA Senior Member USA-RedDragon made a generic A/B updater that different builders can use.

Inventory ROMs

However isn’t it problematic in case your gadget is operating the inventory ROM with numerous modifications and you need to set up an replace with out dropping all of those mods? It may be should you don’t know the suitable steps to put in an replace. On the OnePlus 6, for instance, you possibly can’t flash an incremental OTA on your modified system as a result of the incremental OTA will try and patch your modified boot picture. Thus, you’ll possible find yourself with a bootloop, and that’s why it’s a must to flash the complete ROM replace to utterly overwrite your modified boot picture. Listed here are the overall steps you could take to put in an OxygenOS replace on your OnePlus 6 whereas nonetheless retaining TWRP, Magisk, and optionally a customized kernel.

  1. Downloaded the newest full ROM zip
  2. Flash the complete ROM zip in restoration
  3. (Non-compulsory) Flash customized kernel
  4. Flash TWRP installer
  5. Reboot straight again to restoration
  6. Flash Magisk

On the Google Pixel units, you’ll be able to flash the manufacturing unit picture with out wiping knowledge, then boot TWRP, set up TWRP by way of the set up script, then set up Magisk.

Extracting an replace to flash particular person partition photographs

Replace information for a lot of A/B units are a bit of totally different in comparison with A-only units. They’re not only a zip file containing numerous photographs (excluding Google and Razer’s manufacturing unit photographs), as an alternative, they’re within the type of a payload.bin file. You possibly can extract this file and flash every half manually, nevertheless it requires a particular device to take action. When you’re concerned with studying how to take action on the OnePlus 6, Xiaomi Mi A1, and many different A/B units, learn on.

Setting as much as extract payload.bin

  1. Make you positive you might have Python three.6 put in.
  2. Obtain payload_dumper.py and update_metadata_pb2.py right here.
  3. Extract your OTA zip and place payload.bin in the identical folder as these information.
  4. Open PowerShell, Command Immediate, or Terminal relying on your OS.
  5. Enter the next command: python -m pip set up protobuf
  6. When that’s completed, enter this command: python payload_dumper.py payload.bin
  7. It will begin to extract the pictures inside the payload.bin file to the present folder you’re in.

You’ll be able to flash every of those photographs individually now by way of fastboot if you want. The subsequent part exhibits you ways to try this.

Utilizing fastboot to flash photographs on a tool that helps seamless updates

There are a selection of instructions which are unique to A/B partition system units. You’ll be able to change your lively slot and flash to particular slots. In case you have a Undertaking Treble-compatible system and need to discover ways to flash Generic System Pictures, you ought to be accustomed to these instructions. Check out the desk under.

Fastboot instructions Command Get present lively slot fastboot getvar all | grep “current-slot”

For those who’re on a Home windows PC, the “grep” command gained’t work.

Set different slot as lively fastboot set_active different Set specified slot as lively fastboot set_active $


fastboot –set-active=_$slot

the place $ is both a or b

Flash picture to the required partition within the present slot fastboot flash partition partition.img Flash picture to the required partition within the specified slot fastboot flash partition_a partition.img

fastboot flash partition_b partition.img

(Word: On A/B units, you’ll be able to both specify a partition in a specific slot to flash to or you’ll be able to miss the slot suffix and it’ll flash to the present lively slot. For instance, you’ll be able to substitute “partition” within the flash command with “system”, “system_a”, or “system_b.”)

On Home windows PCs, you possibly can’t use grep, so simply take away that half and search for “current-slot”.

A Phrase on Challenge Treble and Seamless Updates

A standard false impression is that having Venture Treble help and A/B partition help are associated to at least one one other, however that’s not truly the case. Having one doesn’t suggest the opposite. The Motorola Moto Z2 Drive makes use of an A/B partitioning scheme however doesn’t help Treble. Then again, the Honor 9 Lite helps Challenge Treble, but is an A-only gadget.

The Honor 9 Lite helps Challenge Treble however doesn’t help Seamless Updates

Steadily Requested Questions/Abstract

  • What are the advantages of A/B partitioning?
    • A/B partitioning lets you replace your Android smartphone whereas utilizing it, merely rebooting whenever you’re able to boot into the brand new model. It additionally acts as safety towards bricks—if the replace goes flawed you’ll return to the working set up.
  • Does having A/B partitioning hinder improvement?
    • Whereas it did take builders a little bit of time to adapt, the reply is just about no. In reality, it may possibly assist builders as they will twin boot their customized ROM with the previous model and a brand new testing model to verify for regressions.
  • How do A/B partitions have an effect on mods akin to customized kernels, Magisk, or Xposed?
    • It’s a must to watch out when putting in them, however there are at present no points. Magisk formally helps units with seamless updates, and as long as you flash issues in the correct order you should not have any issues. Be sure that to flash the customized kernel earlier than flashing your different mods, and you need to be good to go.
  • Can I flash two totally different ROMs on every partition and twin boot?
    • In principle, sure. Issues come up due to the shared knowledge partition although, so it’s not beneficial.
  • Does having an A/B partition scheme imply that I’ve decreased storage?
    • Nope! Google says that units which help seamless updates solely sacrifice a couple of hundred Megabytes of storage to help it. The advantages outweigh that value.
  • My system helps A/B partitions, does that imply I could make use of a Venture Treble Generic System Picture?
    • Not essentially. Undertaking Treble and A/B help are unrelated. The Motorola Moto Z2 Pressure doesn’t help Venture Treble, but it helps the A/B partition scheme.
  • My gadget helps Venture Treble, does that imply I’ve an A/B partition scheme?
    • This isn’t all the time the case. The Honor 9 Lite is a primary instance because it helps Undertaking Treble but doesn’t have an A/B partition scheme.
  • Why do I have to boot TWRP with fastboot first and then flash it?
    • That is due to how fastboot works and the truth that the restoration partition not exists. Restoration is positioned inside the boot partition, so we now have to switch each boot_a and boot_b. You possibly can’t patch a partition in fastboot, solely flash over it. You might, in principle, make a prepatched boot picture and then flash that as an alternative.
  • Are there any risks with A/B partitions? How does rollback safety have an effect on issues?
    • Google has tried their hardest to make this not a problem, however within the case of the Motorola Moto Z2 Drive, there have been recognized instances of a tool reactivating the older slot after upgrading to Android Oreo. This meant that rollback safety kicked in, and system house owners might solely rescue their smartphone with EDL restoration. Google says that rollback safety solely kicks in after first boot although, so the slot must be absolutely functioning after an replace earlier than you’ll be able to not downgrade.

Need extra posts like this delivered to your inbox? Enter your e mail to be subscribed to our publication.

fbq(‘init’, ‘403489180002579’); // Insert your pixel ID right here.
fbq(‘monitor’, ‘PageView_XDA’);