Android Upgrades, Custom ROMs (LineageOS), & Kernels

Advanced A/B Partition Repair: How to Rebuild Corrupt Slots and Restore Seamless Updates

Google AdSense Native Placement - Horizontal Top-Post banner

Introduction to A/B Partitioning and Seamless Updates

Android’s A/B (seamless) system updates are a critical feature designed to minimize device downtime during software updates. Instead of traditional block-based updates that require the user to wait for installation, A/B updates operate on two separate sets of partitions: Slot A and Slot B. While one slot (e.g., A) is active and running the current OS, the update is downloaded and installed silently in the inactive slot (e.g., B) in the background. Once the installation is complete, a simple reboot switches the active slot from A to B, making the new OS version immediately available. This system offers enhanced reliability by providing a fallback mechanism: if the updated slot fails to boot, the device can revert to the previous working slot, greatly reducing the risk of a bricked device.

Despite their robustness, A/B partitions are not immune to corruption. Issues can arise from various factors, leading to failed updates, boot loops, or an inability to switch between slots. Understanding how to diagnose and repair these corruptions is essential for maintaining device stability and ensuring the smooth functioning of seamless updates, especially for users of custom ROMs like LineageOS or those who frequently flash kernels.

Common Causes of A/B Slot Corruption

A/B partition corruption can manifest in several ways and stem from diverse origins:

  • Failed OTA Updates: An interrupted or incomplete Over-The-Air update, often due to power loss or network issues, can leave the inactive slot in a partially updated or corrupted state.
  • Incomplete or Incorrect Custom ROM Flashes: Flashing custom ROMs without proper slot management, especially if not using a unified package that handles both slots, can lead to one slot being perfectly flashed while the other remains in an incompatible state.
  • Kernel Mishaps: Flashing an incompatible kernel to one slot, or experiencing an error during a kernel flash, can render that slot unbootable.
  • Filesystem Corruption: Though less common for system partitions, underlying flash memory issues or severe software bugs could corrupt the filesystem within an A/B slot, preventing it from booting or updating correctly.
  • User Error: Incorrect `fastboot` commands, such as flashing an image to the wrong slot suffix (e.g., `_a` instead of `_b`), can also cause significant issues.

Diagnosing A/B Partition Issues

Before attempting any repairs, accurate diagnosis is crucial. You’ll need the Android Debug Bridge (ADB) and Fastboot tools installed and configured on your computer.

1. Checking Active Slot and Bootloader Status

Boot your device into Fastboot mode (usually by holding Power + Volume Down from a powered-off state). Connect it to your PC and open a terminal or command prompt.

fastboot devicesfastboot getvar all

The `fastboot getvar all` command provides a wealth of information, including bootloader version, current slot, and other device-specific variables. Pay close attention to output lines like `(bootloader) current-slot:a` or `(bootloader) current-slot:b`.

fastboot getvar current-slot

This command explicitly tells you which slot is currently active. If your device is boot-looping, this indicates the slot it’s attempting to boot from is likely corrupted.

2. Examining Partitions with `fastboot`

While `fastboot` doesn’t offer direct filesystem integrity checks, you can infer issues from flashing failures. Attempting to flash an image to a problematic slot can sometimes yield errors indicating a write failure or corrupt header, though often the primary symptom is simply the device failing to boot from that slot.

Prerequisites and Warnings

  • Unlocked Bootloader: This is absolutely mandatory. Without an unlocked bootloader, you cannot flash custom images or modify critical partitions.
  • Full Device Backup: Repairing partitions involves flashing low-level components, which carries a significant risk of data loss. BACK UP ALL IMPORTANT DATA before proceeding.
  • Official Factory Image: Obtain the correct factory image for your device model and region from the manufacturer’s website. This will be your primary tool for recovery.
  • ADB and Fastboot Setup: Ensure you have the latest platform-tools installed and working correctly.
  • Battery Charge: Ensure your device has at least 50% battery charge to prevent power loss during critical flashing operations.

Method 1: Re-flashing Factory Images (Recommended)

This is the safest and most comprehensive method for repairing A/B partition corruption, as it overwrites both slots with known good images. This method will likely wipe your user data.

  1. Download Factory Image: Go to your device manufacturer’s developer site (e.g., Google’s Pixel factory images page) and download the factory image corresponding to your device and desired Android version.
  2. Extract the Archive: Extract the downloaded `.zip` or `.tgz` archive to a well-known directory on your computer. Inside, you’ll typically find another `.zip` file containing the actual partition images (e.g., `image-walleye-opm1.171019.011.zip`), along with `flash-all.sh` (Linux/macOS) or `flash-all.bat` (Windows) scripts.
  3. Boot to Fastboot Mode: Power off your device. Hold Volume Down + Power button simultaneously until you see the Fastboot screen. Connect your device to your computer via USB.
  4. Run the Flash Script:Navigate to the extracted factory image directory in your terminal or command prompt.
  5. # For Windowsfastboot devicesflash-all.bat# For Linux/macOSfastboot devices./flash-all.sh
  6. Monitor the Process: The script will automatically flash all necessary partitions to both A and B slots, reset the active slot, and potentially wipe user data. This process can take several minutes.
  7. Reboot: Once the script completes and reports success, your device should automatically reboot into the newly flashed Android system.

Method 2: Manually Repairing a Corrupt A/B Slot

This method is more granular, allowing you to target a specific corrupt slot. It’s often used when one slot is still functional, and you want to repair the other without necessarily re-flashing the entire device from scratch or wiping user data on the working slot. However, it still involves flashing critical partitions, so proceed with caution.

Scenario: Slot B is corrupt, Slot A is working.

Assuming your device can still boot into Slot A, or you know Slot A is good and you want to fix Slot B:

  1. Identify Corrupt Slot: Confirm which slot is causing issues using `fastboot getvar current-slot` and observing boot behavior. Let’s assume Slot B is corrupt.
  2. Boot to Working Slot (Optional, but Recommended): If your device is stuck in a boot loop from Slot B, explicitly set Slot A as active and reboot to ensure you’re in a stable state.
  3. fastboot --set-active=a reboot
  4. Extract Images Manually: From your downloaded factory image (as in Method 1), extract the `image-DEVICE-VERSION.zip` file. This will reveal individual partition images like `boot.img`, `system.img`, `vendor.img`, `product.img`, `dtbo.img`, and `vbmeta.img`.
  5. Flash Specific Partitions to the Inactive (Corrupt) Slot: You will target the corrupt slot by appending `_a` or `_b` to the partition name. In our scenario, we target `_b` (the inactive, corrupt slot).
  6. # Example: Flashing to Slot B (assuming Slot A is active and working)fastboot flash boot_b boot.imgfastboot flash system_b system.imgfastboot flash vendor_b vendor.imgfastboot flash product_b product.imgfastboot flash dtbo_b dtbo.imgfastboot flash vbmeta_b vbmeta.img# Repeat for any other essential partitions like 'odm', 'system_ext', etc., if present.

    It’s crucial to flash all system-related images (boot, system, vendor, product, dtbo, vbmeta) to the target slot to ensure a consistent and bootable system.

  7. Set Active Slot and Reboot: After flashing, you can attempt to set the repaired slot as active and reboot to test.
  8. fastboot --set-active=b reboot

Verifying the Repair and Restoring Seamless Updates

After performing either repair method, follow these steps:

  • Successful Boot: Ensure your device boots cleanly into Android.
  • Verify Slot: Once booted, enable Developer Options and USB Debugging. Connect to ADB and run:
  • adb shell getprop ro.boot.slot_suffix

    This should confirm which slot (`_a` or `_b`) is currently active.

  • Perform an OTA Update: The ultimate test for A/B functionality is to perform an Over-The-Air update. If the update downloads, installs to the inactive slot, and reboots seamlessly to the new version, your A/B partitioning is fully restored. If you are on a custom ROM, ensure you can flash an update package without issues.

Conclusion

A/B partitioning is a cornerstone of modern Android’s reliability, enabling seamless and robust updates. While issues like slot corruption can be frustrating, they are often repairable with the right tools and knowledge. By understanding the causes, accurately diagnosing the problem, and carefully following the steps outlined using `fastboot` with official factory images, you can effectively rebuild corrupt A/B slots and restore your device’s ability to receive and apply seamless updates. Always remember the golden rules: back up your data, use manufacturer-approved images, and proceed with caution.

Android Mobile Specs & Compare Directory

Are you researching mobile hardware properties, processor SoCs, GPU chipsets, or RAM configurations? Access our complete specs catalog to compare up to 5 devices side-by-side!

Compare Devices Specs →
Google AdSense Inline Placement - Content Footer banner