FORUMS
Remove All Ads from XDA

Help understanding A/B partitions

196 posts
Thanks Meter: 47
 
By guardianali, Senior Member on 11th February 2018, 06:07 PM
Post Reply Email Thread
I finally just moved from my old Nexus 6p to the Pixel XL.

The 6P still used the tried and true forever method of flashing ROMs, but the Pixel is the first one to have the new A / B partitions.
I understands why and their uses but am having trouble figuring out the proper way to going between roms.

I managed to install a custom rom from stock, and magisk just fine via TWRP 3.2.0.0. But being new to the phone, I want to naturally try different roms to see which one I would like the best.

So assuming I'm on a custom rom, and want to switch to another.....as I understand it, you have to be in the opposite partition correct? Cause when you flash it flashes to the opposite? Or does that NOT apply to TWRP?

If my current custom Rom is in A, do I stay in A in twrp and go the install instructions for that rom? Or do I swap to B and then do it?
I have the generic steps down.
-flash rom
-flash twrp zip
-reboot recovery
-flash vendor and/or gapps depending on rom
-reboot and run
-boot to recovery and flash magisk.

The part im confused about is understanding what partition I should be when i first go in to twrp to flash a new custom rom from a custom rom. (not updating the rom, but a new one)
11th February 2018, 06:27 PM |#2  
Member
Thanks Meter: 7
 
More
I'm getting out the pop-corn hoping someone can explain this? I've asked and asked for help but still on stock.
11th February 2018, 08:38 PM |#3  
ironmaskusa's Avatar
Senior Member
USA
Thanks Meter: 118
 
Donate to Me
More
I second that question.
12th February 2018, 01:27 AM |#4  
aoaleman's Avatar
Senior Member
Flag San Antonio, TX
Thanks Meter: 873
 
More
No stay on A for ROMS. Usually root like Magisk goes on the B but usually is installed automatically via the script. To flash a new ROM, you usually flash ROM then TWRP zip, if you want to keep TWRP. Then reboot to Recovery (yes back to it) then flash other zips. Gapps if needed, audio mods, etc. If you want root, need to boot into the ROM first, then back to Recovery and flash root like Magisk. This is the procedure for most custom ROMS.

Edit: sounds like you got it down. Start on A. You usually have to wipe system, data, and cache, not sdcard anyway to flash a new ROM.
The Following 2 Users Say Thank You to aoaleman For This Useful Post: [ View ] Gift aoaleman Ad-Free
13th February 2018, 12:33 AM |#5  
Senior Member
Thanks Meter: 493
 
More
There's a fairly comprehensive article on a/b partitions here: https://source.android.com/devices/tech/ota/ab/. Though it is mainly from the perspective of an OEM/dev, it does describe what has changed and how quite clearly.

To summarize, in the olden days we used to have the following key partitions:
  • recovery
  • boot
  • cache
  • system
  • vendor
  • data

Both boot and recovery partitions included their own kernel images, and the bootloader/fastboot would decide whether the phone should boot into recovery or boot (and onwards to system).

With the a/b system, the partitions look following:
  • boot_a
  • boot_b
  • system_a
  • system_b
  • vendor_a
  • vendor_b
  • data

You will notice Google has gotten rid of both recovery and cache partitions. I suspect cache was removed to decrease the impact on available storage we get from having 2 system and vendor partitions (and also because it was no longer needed to store OTA update images, for instance). FYI, cache is now within the data partition at /data/cache.

As there is no dedicated recovery partition, instead recovery has now been integrated into the boot_a and boot_b partitions.

The general idea is that if user is using "a" partition (i.e. system booted from boot_a and is using system_a and vendor_a), then updates can be applied to "b" partition while the system is running. After the update has been successfully applied to "b" partition, the bootloader is told to set "b" partition active for next boot. Upon reboot, the bootloader will load boot_b, which in turn loads system_b and vendor_b, thereby "seamlessly" switching to the new system.

The next update will be applied to the "a" partition while the user is using the "b" partition, and the cycle continues.

The advantage is that if something goes wrong with the update (fails to apply or fails to boot), the bootloader can switch back to the original partition, and the phone remains usable.

The main headache for hobbyists like us here at XDA is the fact that we no longer have a nice, independent recovery partition to stick TWRP onto. Instead, we need to replace the stock recovery inside the boot partition, while leaving the rest of the boot partition intact.

Because it is not possible to modify partitions over fastboot (only overwrite them), it is necessary to first boot into TWRP by loading the recovery image from the PC (fastboot boot twrp.img), and then while in TWRP (which is running from RAM instead of disk), run the installer which pulls the boot image from the disk, patches the recovery files and pushes it back.

The TWRP installer does this for both boot_a and boot_b, to make sure the user is able to access a recovery regardless of which partition is active at any point in time.

The problem arises from the fact that other mods (magisk, supersu, xposed, custom kernels) also rely on modifying the boot partition, and therefore flashing any of these carries a risk of either replacing files already modified by TWRP, or making the boot image (or ramdisk) so large it no longer fits the partition.

Apart from the above complication, I personally much prefer the a/b partition scheme. For a lonely hobbyist like myself who prefers to build my AOSP images, when I wasn't sure if my build would boot fully or not, I used to have to go to TWRP and make backups of both boot and system partitions, so I can restore back working system if the new build didn't boot.

Now, I just switch the active partition and flash boot.img and system.img images to the corresponding partition. If it doesn't work, I set active back to the working partition, and try again after a new build.
The Following 42 Users Say Thank You to jisoo For This Useful Post: [ View ] Gift jisoo Ad-Free
7th June 2018, 08:33 AM |#6  
Junior Member
Thanks Meter: 0
 
More
Good
23rd July 2018, 03:59 PM |#7  
Junior Member
Thanks Meter: 29
 
More
I think part of the problem is the lack of immediate control. When I flash something I can't directly choose which slot it flashes to which is counterintuitive. I have to remember that ROMs flash to the opposite slot and gapps/magisk flash to the current slot. Then there is all the automatic slot switching which not only wouldn't be needed if you were consciously choosing which slot you flashed, but just overall causes more confusion as the phone switches slots without you realizing or doesn't switch slots when you otherwise thought it had. It will just take some getting used to.
23rd July 2018, 06:07 PM |#8  
Phalanx7621's Avatar
Senior Member
Flag Bethany Beach, Delaware
Thanks Meter: 2,284
 
Donate to Me
More
Quote:
Originally Posted by Severus Snape

I think part of the problem is the lack of immediate control. When I flash something I can't directly choose which slot it flashes to which is counterintuitive. I have to remember that ROMs flash to the opposite slot and gapps/magisk flash to the current slot. Then there is all the automatic slot switching which not only wouldn't be needed if you were consciously choosing which slot you flashed, but just overall causes more confusion as the phone switches slots without you realizing or doesn't switch slots when you otherwise thought it had. It will just take some getting used to.

You can see which slot you are in in recovery.
11th August 2018, 11:20 PM |#9  
xdadevnube's Avatar
Senior Member
Thanks Meter: 155
 
More
This seemed like an appropriate thread for a question about setting up dual booting.

So I flashed the full factory image NJH47F to both A and B partitions.
I flashed TWRP and booted into Slot B.
Wiped everything and installed PureNexus 7.1.2.
Booted into TWRP Slot A.
Installed Elemental kernel and Magisk 14.3.
Got Xposed 89 and a bunch of modules working, yay!

So now I was thinking, why not use the other slot to install crDroid 7.1.2? Great idea, right?

So I have PureNexus installed on Slot A. I'm thinking stock is installed on Slot B. It should be as simple as booting into TWRP Slot B, wipe System, then boot into TWRP Slot A, then install crDroid, right?

This should result in PureNexus on Slot A and crDroid on Slot B.


Primary question 1:
Does wiping actually affect the currently selected Slot? I assume Data and Cache are shared with each Slot. Specifically, does wiping System affect the currently selected Slot?

Primary question 2:
Should the initial custom ROM installation procedure involve first wiping the opposite Slot? In other words, to install a custom ROM to Slot A:
Boot to Slot A
Wipe System (should be able to wipe Data from either Slot (Cache will be wiped with Data))
Boot Slot B
Install custom ROM
Boot Slot A
Install kernel and Magisk

Primary question 3:
Why is it I've never had to install the vendor image? If installing from TWRP, it should go to the opposite Slot just like the ROM, correct? If installing with fastboot, it will install to the selected Slot, correct?
Regardless, I think the reason I haven't beem prompted by the ROM upon boot about the vendor image is because I already have the correct vendor image since I flashed the full factory image with the matching vendor image to both Slots already.

Primary question 4:
If dual booting ROMs, I can expect to use ROMs with the same vendor image and kernel. They should share Data and Cache. Does this mean there is an appropriate time to wipe Cache? What sort of things can happen with shared Data and Cache? Can an app from a ROM Slot overwrite data from the other Slot? If so, is it best to use different apps on the 2nd ROM Slot to avoid strange app behavior?

Not sure how many people are interested, but it seems like dual partitions is the future so we ought to get this figured out!


Sent from my HTC6525LVW using Tapatalk
The Following 2 Users Say Thank You to xdadevnube For This Useful Post: [ View ] Gift xdadevnube Ad-Free
12th August 2018, 10:50 AM |#10  
Phalanx7621's Avatar
Senior Member
Flag Bethany Beach, Delaware
Thanks Meter: 2,284
 
Donate to Me
More
Quote:
Originally Posted by xdadevnube

This seemed like an appropriate thread for a question about setting up dual booting.

So I flashed the full factory image NJH47F to both A and B partitions.
I flashed TWRP and booted into Slot B.
Wiped everything and installed PureNexus 7.1.2.
Booted into TWRP Slot A.
Installed Elemental kernel and Magisk 14.3.
Got Xposed 89 and a bunch of modules working, yay!

So now I was thinking, why not use the other slot to install crDroid 7.1.2? Great idea, right?

So I have PureNexus installed on Slot A. I'm thinking stock is installed on Slot B. It should be as simple as booting into TWRP Slot B, wipe System, then boot into TWRP Slot A, then install crDroid, right?

This should result in PureNexus on Slot A and crDroid on Slot B.


Primary question 1:
Does wiping actually affect the currently selected Slot? I assume Data and Cache are shared with each Slot. Specifically, does wiping System affect the currently selected Slot?

Primary question 2:
Should the initial custom ROM installation procedure involve first wiping the opposite Slot? In other words, to install a custom ROM to Slot A:
Boot to Slot A
Wipe System (should be able to wipe Data from either Slot (Cache will be wiped with Data))
Boot Slot B
Install custom ROM
Boot Slot A
Install kernel and Magisk

Primary question 3:
Why is it I've never had to install the vendor image? If installing from TWRP, it should go to the opposite Slot just like the ROM, correct? If installing with fastboot, it will install to the selected Slot, correct?
Regardless, I think the reason I haven't beem prompted by the ROM upon boot about the vendor image is because I already have the correct vendor image since I flashed the full factory image with the matching vendor image to both Slots already.

Primary question 4:
If dual booting ROMs, I can expect to use ROMs with the same vendor image and kernel. They should share Data and Cache. Does this mean there is an appropriate time to wipe Cache? What sort of things can happen with shared Data and Cache? Can an app from a ROM Slot overwrite data from the other Slot? If so, is it best to use different apps on the 2nd ROM Slot to avoid strange app behavior?

Not sure how many people are interested, but it seems like dual partitions is the future so we ought to get this figured out!

You can't dual boot ROMs as far as I'm aware. Indeed the idea seems like it should work, but as far as I'm aware there's no way unfortunately on our device.
30th November 2019, 02:10 AM |#11  
Junior Member
Flag Richmond
Thanks Meter: 1
 
More
A/B slots, which one to start from...
Quote:
Originally Posted by aoaleman

No stay on A for ROMS. Usually root like Magisk goes on the B but usually is installed automatically via the script. To flash a new ROM, you usually flash ROM then TWRP zip, if you want to keep TWRP. Then reboot to Recovery (yes back to it) then flash other zips. Gapps if needed, audio mods, etc. If you want root, need to boot into the ROM first, then back to Recovery and flash root like Magisk. This is the procedure for most custom ROMS.

Edit: sounds like you got it down. Start on A. You usually have to wipe system, data, and cache, not sdcard anyway to flash a new ROM.

Man thank you a bunch!!! I have read page over page trying to understand this flashing from A/B and nothing in the end really made any sense because of the depth most get into trying to explain.. Your short, simple answer you gave made more sense than everything I have read today, thx and keep the great work up
The Following User Says Thank You to KyBoi1128 For This Useful Post: [ View ] Gift KyBoi1128 Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes