Introduction to Magisk and A/B Partitions
Magisk has revolutionized Android rooting by providing a ‘systemless’ interface that allows users to modify the system without actually altering the /system partition. This approach enables Magisk to hide root from integrity checks (like Google SafetyNet) and allows for easier over-the-air (OTA) updates. Complementing this is the A/B partition scheme, a design popularized by Google for Pixel devices and adopted by many other Android manufacturers. A/B partitions, also known as ‘seamless updates’, significantly improve the update experience by allowing updates to be installed in the background on an inactive partition while the user continues to use the device on the active partition. Upon reboot, the device simply switches to the newly updated partition. This guide will provide a comprehensive walkthrough on installing Magisk on devices utilizing A/B partitions, ensuring you can enjoy systemless root while retaining the benefits of seamless updates.
Prerequisites for Magisk Installation
Before you begin the installation process, ensure you have the following:
- Unlocked Bootloader: Your device’s bootloader must be unlocked. This process usually wipes your device data, so back up anything important beforehand.
- Android SDK Platform-Tools: Install ADB and Fastboot on your computer. These command-line tools are essential for communicating with your device.
- Magisk App: Download the latest Magisk APK from the official GitHub repository.
- Stock Firmware/Boot Image: You will need the exact stock boot image (or `init_boot.img` for newer devices) corresponding to your device’s current firmware version. This is critical for patching. Often found within your device’s full stock ROM zip.
- USB Cable: A reliable USB cable to connect your device to your computer.
- Basic ADB/Fastboot Knowledge: Familiarity with basic commands will be helpful.
Understanding A/B Partitioning
A/B partitioning is a dual-system setup. Instead of a single set of system partitions, A/B devices have two complete sets: `slot_a` and `slot_b`. For example, `system_a` and `system_b`, `boot_a` and `boot_b`, `vendor_a` and `vendor_b`, and so on. At any given time, one slot is active (e.g., `slot_a`) and the other is inactive (`slot_b`).
When an OTA update arrives, it’s downloaded and installed onto the *inactive* slot. While this happens, you can continue using your device normally on the *active* slot. Once the installation is complete, a simple reboot switches the active slot to the newly updated one. If something goes wrong, the device can potentially revert to the previous working slot, enhancing system stability.
Magisk leverages this system for seamless updates. Instead of directly modifying the active boot partition, we often patch the boot image on the *inactive* slot or use Magisk’s built-in OTA handling to re-root after an update.
Identifying Your Device’s Active Slot
It’s crucial to know which slot is currently active on your device. You can check this using ADB:
adb shell getprop ro.boot.slot_suffix
This command will typically return `_a` or `_b`, indicating your currently active slot.
Step-by-Step Magisk Installation Guide
Step 1: Download Required Files
First, download the latest Magisk APK from the official Magisk GitHub releases page. Install it on your device.
Next, you need to obtain the stock boot image for your specific device and firmware version. This is the most critical part. You can often find this within the official stock ROM zip file provided by your device manufacturer. Look for `boot.img` or `init_boot.img` inside the zip. If the ROM zip contains a `payload.bin` file (common for A/B devices), you’ll need a tool like `payload-dumper-go` to extract the `boot.img` from it.
# Example using payload-dumper-go (download from GitHub and compile/run)payload-dumper-go -p boot payload.bin
Place the extracted `boot.img` file on your device’s internal storage.
Step 2: Patch the Boot Image with Magisk
1. Open the Magisk app on your device.2. Tap the ‘Install’ button.3. Select ‘Select and Patch a File’.4. Navigate to and select the `boot.img` (or `init_boot.img`) file you placed on your internal storage.5. Tap ‘LET’S GO’.
Magisk will patch the boot image and save the output file, typically named `magisk_patched-XXXXX.img`, in your device’s `Download` folder. Transfer this patched image file to your computer’s ADB/Fastboot directory.
Step 3: Boot into Fastboot Mode
Connect your device to your computer via USB. Open a command prompt or terminal in your ADB/Fastboot directory.
Reboot your device into Fastboot mode using one of these methods:
- ADB command:
adb reboot bootloader - Manual method: Power off your device completely, then press and hold the Volume Down + Power buttons simultaneously until you see the Fastboot screen.
Step 4: Flash the Patched Boot Image
Once in Fastboot mode, you need to flash the `magisk_patched-XXXXX.img` file to the *currently active* boot slot. You can re-verify your active slot using `fastboot getvar current-slot` if you forgot the `adb shell` command output.
fastboot flash boot_a magisk_patched-XXXXX.img # If slot_a is activeORfastboot flash boot_b magisk_patched-XXXXX.img # If slot_b is active
Replace `magisk_patched-XXXXX.img` with the actual filename of your patched image. For devices running Android 12 or newer with a separate `init_boot` partition, you might need to flash to `init_boot_a` or `init_boot_b` instead of `boot_a`/`boot_b`.
fastboot flash init_boot_a magisk_patched-XXXXX.img # For Android 12+ with init_boot
After flashing, reboot your device:
fastboot reboot
Step 5: Verify Magisk Installation
Once your device reboots, open the Magisk app. If the installation was successful, it should show
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 →