NO NETWORK · NO TELEMETRY · FAILS CLOSED · v0.3.0

android

Rooting an Android test deviceTest device you own.

A step-by-step, no-experience-needed walkthrough: root a Google Pixel you own with Magisk, check that it worked, and undo it. Then go further with KernelSU and APatch.

September 2026

00

Start here: what you're about to do

No prior experience needed. This walks you through rooting a Google Pixel with Magisk, one small action at a time. Every step says what you should see, so you always know whether it worked. If anything looks different, stop and check If something goes wrong further down before you continue.

Root means getting full administrator access to the phone, which normal apps and users never have. Security apps (including this library) try to detect it. You root a test phone so you can check that detection works.

Plan for about an hour the first time. The whole journey has six stages:

  1. 01Set up your computer — install two small command-line tools, adb and fastboot.
  2. 02Prepare the phone — back it up and switch on a few hidden developer settings.
  3. 03Unlock the bootloader — this erases the phone completely.
  4. 04Download the right system file — a copy of one part of the phone's software that exactly matches your phone.
  5. 05Patch it with Magisk — an app modifies that file to include root.
  6. 06Flash it back and test — copy the modified file onto the phone and confirm root works.

Note

You'll type commands into a terminal — a text window on your computer. On a Mac, open the Terminal app (press Cmd+Space, type Terminal, press Enter). On Windows, you'll open Command Prompt from a specific folder (Step 1 explains how). Type or paste each command exactly as shown and press Enter. Text after # is a comment explaining the command — you don't need to type it.

01

Words you'll see

Glossary

Root
Full administrator ("superuser") access to Android. Apps can ask for it; you approve each request.
Bootloader
The small program that starts the phone before Android loads. It's locked from the factory so only official software can run. You unlock it to install modified software.
adb
Android Debug Bridge. A computer tool that talks to the phone while Android is running normally. Used to install apps, copy files, and reboot.
fastboot
A computer tool that talks to the phone while it's sitting in the bootloader ("fastboot mode"). Used to unlock and to write ("flash") system files.
Platform tools
Google's free download that contains adb and fastboot.
Flash
Write a system file onto the phone, replacing what was there.
Factory image
The official, complete copy of your phone's software, published by Google for each Pixel model and each software update.
Build number
The exact software version on your phone, e.g. BP2A.250805.005. The file you flash must come from this exact build.
Codename
Google's internal name for your model, e.g. caiman for the Pixel 9 Pro. Factory images are listed by codename.
init_boot.img / boot.img
The small part of the software that starts Android. Magisk adds root by modifying this one file.
Magisk
The most common rooting app. It patches init_boot.img / boot.img and then manages which apps get root.
Bootloop
The phone restarts endlessly and never reaches the home screen. Almost always fixable — see Undo.
Brick
A phone that won't start at all. Rare on Pixels; the usual cause is flashing a file from the wrong model or build.

02

What you need

  1. 01A spare Android phone you own — ideally a Google Pixel (Pixel 7 or newer is easiest). Not your everyday phone: it will be erased.
  2. 02A USB cable that carries data, not just power. The cable that came with the phone is best. If the computer never sees the phone, the cable is the first suspect.
  3. 03A Mac or Windows computer with internet access and about 5 GB of free space.
  4. 04A backup of anything on the phone you care about (photos, files, two-factor authenticator codes). Unlocking erases everything.

Will my phone work?

Google Pixel
Yes — the easiest choice, and the one this guide is written for.
OnePlus / Nothing
Usually yes, with almost the same steps. Some models need an unlock token from the maker.
Xiaomi / POCO
Possible but slower: needs Xiaomi's Mi Unlock tool, a Xiaomi account, and a waiting period of days.
Samsung
International models: yes, but permanently disables Samsung Knox features. US/Canada models: usually impossible. Avoid for a first try.
Motorola
Yes, after requesting an unlock code from Motorola's website.
Carrier-locked phones
Often impossible. If the phone was bought from or through a mobile carrier, check that it can be unlocked first.

03

Step 1 — Install adb and fastboot on your computer

On a Mac: install Homebrew if you don't have it (copy the one-line command from its homepage into Terminal). Then run the install command below.

On Windows: download SDK Platform-Tools for Windows from Google's platform-tools page and unzip it to C:\platform-tools. Open that folder in File Explorer, click the address bar, type cmd and press Enter — a Command Prompt opens in that folder. Run every command in this guide from that window, and put any downloaded phone files in C:\platform-tools too. If the phone is never detected later, also install the Google USB Driver.

Then check it worked. You should see: a version number for each tool. If you see command not found (Mac) or is not recognized (Windows), the install didn't finish or you're in the wrong folder.

install (Mac) + check (both)
# Mac only:
brew install --cask android-platform-tools

# Mac and Windows — check both tools respond:
adb version
fastboot --version

04

Two modes, two tools

This trips up almost everyone, so it's worth two minutes. adb and fastboot both talk to the phone over the same USB cable, but they talk to two different programs on the phone, and only one of those programs is running at any moment. That's why one tool can see the phone while the other says no devices found — nothing is broken, the phone is just in the other mode.

adb talks to Android itself. When Android is running and USB debugging is switched on, a small background service on the phone listens for adb. That service is part of Android, so it only exists once Android has started. adb can therefore do anything that needs a running phone: install apps, copy files to and from storage, open a command line on the phone (adb shell), read settings like the build number, and tell the phone to restart into fastboot mode. Because it's this powerful, the phone asks you to approve each computer first (the "Allow USB debugging?" prompt).

fastboot talks to the bootloader. The bootloader runs *before* Android, and Android isn't running at all while you're in fastboot mode — so there's no adb service to answer. The bootloader understands only a short list of low-level commands: unlock or lock itself, write (flash) a system file onto a part of the phone's storage, report basic facts (fastboot getvar …), and restart. It can't see your apps or files, and it doesn't need USB debugging or the approval prompt.

So the rule is: anything about apps, files, or reading the phone's software → adb, with the phone switched on normally. Anything about unlocking or replacing system files → fastboot, with the phone in fastboot mode. Most of this guide is switching between the two: adb to get into fastboot mode, fastboot to flash, then back to Android and adb again.

tell which mode you're in
adb devices
# 1A2B3C4D5E6F	device      -> Android is running, adb works
# (empty list)                   -> not in Android, or USB debugging off / not allowed

fastboot devices
# 1A2B3C4D5E6F	fastboot    -> in fastboot mode, fastboot works
# (no output)                    -> not in fastboot mode

# Switch modes:
adb reboot bootloader    # Android  -> fastboot mode
fastboot reboot          # fastboot -> Android

Which tool works when

Normal Android
The phone is on and showing the home or lock screen. Use adb (needs USB debugging on). fastboot sees nothing here.
Fastboot mode
A screen saying "Fastboot Mode". Pixels show an Android robot and a menu (Start, Recovery mode…). Newer OnePlus, OPPO and Realme phones show just the maker logo, "Fastboot Mode" and an Android robot, with no menu. Use fastboot. adb sees nothing here.
Android → fastboot
Run: adb reboot bootloader. Or power the phone off, then hold Power + Volume Down until the fastboot screen appears.
Fastboot → Android
Run: fastboot reboot. Or, on Pixels, press Volume until "Start" is shown and press Power. On phones with no menu (newer OnePlus/OPPO/Realme), unplug and hold Power + Volume Up for 10–15 seconds until the screen goes black.
Check what's connected
adb devices (in Android) or fastboot devices (in fastboot mode). A serial number in the list means it's connected.

Commands in this guide, by tool

adb devices
adb · Android running. Lists connected phones; "device" means ready, "unauthorized" means accept the prompt on the phone.
adb shell getprop …
adb · Android running. Reads a setting, e.g. your build number or codename.
adb install …apk
adb · Android running. Installs an app (Magisk) from your computer.
adb push / adb pull
adb · Android running. Copies a file to the phone / back to the computer.
adb shell, then su
adb · Android running. Opens a command line on the phone; su asks Magisk for root.
adb reboot bootloader
adb · Android running. Restarts the phone into fastboot mode — the bridge from adb to fastboot.
fastboot devices
fastboot · fastboot mode. Lists phones waiting in the bootloader.
fastboot flashing unlock
fastboot · fastboot mode. Unlocks the bootloader (erases the phone).
fastboot getvar unlocked
fastboot · fastboot mode. Reports whether the bootloader is unlocked.
fastboot flash init_boot …
fastboot · fastboot mode. Writes a system file onto the phone.
fastboot reboot
fastboot · fastboot mode. Restarts into Android — the bridge back to adb.

Note

Two rarer modes you may run into. Recovery mode (a menu reached from the fastboot screen) is for wiping or installing official updates; adb only works there in a limited "sideload" form. fastbootd ("fastboot mode" shown by Android itself, reached with fastboot reboot fastboot) is a second fastboot used on newer phones for some large system partitions. You don't need either for this guide — if you end up in one by accident, choose Reboot system now or run fastboot reboot.

05

Your terminal is always "in" a folder

One more idea that saves a lot of confusion. A terminal window is always sitting in one folder on your computer — called the current folder. Commands that read or save files use that folder unless you say otherwise: adb pull saves the copied file there, adb push and adb install look for your file there, and payload-dumper-go reads the package from there and writes its extracted folder there.

So most "file not found" or "cannot create" errors aren't about the phone at all — the terminal is just looking in, or saving to, the wrong folder on your computer. The fix is always the same: move into the folder where your files are, or type the full location as part of the command.

In this guide: on a Mac, keep everything in Downloads and run cd ~/Downloads in each new Terminal window. On Windows, keep everything in C:\platform-tools and open Command Prompt from that folder (Step 1). The ~ on a Mac is short for your home folder, so ~/Downloads is your Downloads folder.

where am I? (Mac — Windows equivalents in comments)
pwd                 # show the current folder      (Windows: cd)
cd ~/Downloads      # move into Downloads           (Windows: cd C:\platform-tools)
ls                  # list the files in it          (Windows: dir)

# Saving to a specific place, wherever you are:
adb pull /sdcard/some-file.zip ~/Downloads/some-file.zip

06

Step 2 — Prepare the phone

  1. 01Back up everything you want to keep. The next stage erases the phone.
  2. 02Turn on Developer options: Settings → About phone → tap Build number 7 times. Enter your PIN if asked. You should see: "You are now a developer!"
  3. 03Open Developer options: Settings → System → Developer options.
  4. 04Turn on OEM unlocking. If it's greyed out, connect to Wi-Fi and wait a few minutes. If it stays greyed out, the phone is carrier-locked and can't be unlocked.
  5. 05Turn on USB debugging in the same menu.
  6. 06Plug the phone into the computer and run adb devices.
  7. 07On the phone, a box asks "Allow USB debugging?" Tick "Always allow from this computer" and tap Allow.
  8. 08Run adb devices again. You should see: a serial number followed by device. If it says unauthorized, look for the prompt on the phone. If the list is empty, try another cable or USB port.
check connection
adb devices
# List of devices attached
# 1A2B3C4D5E6F	device      <- good

07

Step 3 — Unlock the bootloader

This erases everything on the phone. You only do it once. The terminal output below is what you'll really see — including some scary-looking lines that are fine. Phones differ after the confirmation step, so the steps say what Pixels and other brands (OnePlus, Nothing, …) do.

  1. 01Run adb reboot bootloader. You should see: the phone restart into the fastboot screen. The terminal prints nothing — that's fine.
  2. 02Run fastboot devices. You should see: your serial number followed by fastboot. On a Mac, if nothing appears, unplug and replug, or use a port directly on the computer.
  3. 03Run fastboot flashing unlock. On a Mac the terminal may first print two ERROR: could not clear … pipe lines — ignore them, they're harmless. Some phones then print (bootloader) Start unlock flow. Finally it prints OKAY and Finished. That only means the phone is now asking you — the unlock hasn't happened yet. If it prints FAILED, see the note below.
  4. 04On the phone: a warning screen asks whether to unlock. Use the Volume keys to highlight Unlock the bootloader (the wording varies), then press Power.
  5. 05What happens next depends on the phone. Pixel: it erases itself and returns to the fastboot screen showing Device state: unlocked — run fastboot reboot. OnePlus, Nothing and many others: it erases itself and restarts straight into Android on its own — no command needed. If the terminal is just sitting there, that's fine; you're done with it for now.
  6. 06Optional check, while still on the fastboot screen: fastboot getvar unlocked prints unlocked: yes on Pixels. Many other phones answer FAILED (remote: 'GetVar Variable Not found') or the command just hangs — because the phone is showing the confirmation screen or has already restarted to erase itself, so nothing answers. Press Ctrl+C; it's safe. Check after setup instead (Step 4: verifiedbootstate = orange).
  7. 07If the phone stays on the fastboot screen and fastboot reboot does nothing: on a Pixel, press Volume until Start shows and press Power. On a phone whose fastboot screen has no menu (newer OnePlus/OPPO/Realme), unplug and hold Power + Volume Up for 10–15 seconds.
  8. 08The first start takes 5–10 minutes, and from now on every start shows a warning that the bootloader is unlocked ("orange state" on OnePlus). That's normal — wait or press Power to continue.
  9. 09Set the phone up again (you can skip most options and accounts). Then repeat Step 2's developer settings: Developer options, USB debugging, and allow the computer again. The erase switched them off.
unlock — what the terminal shows
% adb reboot bootloader
% fastboot devices
1A2B3C4D5E6F	 fastboot

% fastboot flashing unlock          # older phones: fastboot oem unlock
ERROR: could not clear input pipe; result e0005000, ignoring...    <- harmless (Mac)
ERROR: could not clear output pipe; result e0005000, ignoring....  <- harmless (Mac)
(bootloader) Start unlock flow       <- some phones print this
OKAY [  4.408s]
Finished. Total time: 4.408s
# now LOOK AT THE PHONE and confirm there — nothing else happens until you do

% fastboot getvar unlocked          # optional; Pixel only, after confirming
unlocked: yes                       # may hang instead on other phones: Ctrl+C

% fastboot reboot                   # Pixel only — others restart by themselves
Rebooting
Finished. Total time: 0.050s

Note

FAILED (remote: 'unlock is not allowed') or Flashing Unlock is not allowed means OEM unlocking is off — run fastboot reboot (or hold Power + Volume Up), turn it on in Developer options, and try again. FAILED (remote: 'unknown command') means that phone uses the older command: try fastboot oem unlock. The $ / % at the start of a line is the terminal's prompt — don't type it.

08

Step 4 — Write down your phone's details

You're about to download a copy of your phone's software. It has to match your phone exactly — same model, same region, same version — or the phone may not start. These commands read the details you need. Run them with the phone switched on normally and connected (adb devices shows device).

Got a Pixel? You only need the first two lines. Any other brand (OnePlus, Nothing, Xiaomi, Motorola…)? Run the bottom four.

phone details
# Pixel
adb shell getprop ro.build.id              # e.g. BP2A.250805.005
adb shell getprop ro.product.device        # e.g. caiman

# Every other brand
adb shell getprop ro.product.model             # e.g. CPH2581
adb shell getprop ro.build.display.id          # e.g. CPH2581_15.0.0.406(EX01)
adb shell getprop ro.product.first_api_level   # e.g. 34  -> init_boot.img
adb shell getprop ro.boot.verifiedbootstate    # orange = unlocked

What the answers mean (OnePlus examples)

ro.build.id
Pixel: your build number, e.g. BP2A.250805.005 — this is what you match against Google's list. Other brands: ignore it. It's Google's base Android version (e.g. AP3A.240617.008), shared by hundreds of phones, so it can't tell you which download is yours.
ro.product.device
Pixel: the codename, e.g. caiman. Other brands: also printed, but you'll mostly use the model code below.
ro.product.model
The model code, e.g. CPH2581 (OnePlus 12, global). Downloads are listed by this code or the marketing name.
ro.build.display.id
The maker's own software version, e.g. CPH2581_15.0.0.406(EX01). This is the one to match. The part in brackets is the region (EX01 Europe, IN India, NA North America, GLO global) — it must match too. Also shown in Settings → About device → Version.
ro.product.first_api_level
The Android version the phone was first sold with. 33 or higher (Android 13+) → you'll use init_boot.img. Lower → boot.img.
ro.boot.verifiedbootstate
orange = bootloader unlocked (good). green = still locked — go back to Step 3.

09

Step 5 (Pixel) — Download the factory image

Not a Pixel? Skip to Step 5 (other brands).

  1. 01Open Google's Pixel factory images page and click Acknowledge to accept the terms.
  2. 02Find the section for your codename (the page lists them like "caiman for Pixel 9 Pro").
  3. 03In that list, find the row whose name contains your exact build number, e.g. BP2A.250805.005. Some builds have carrier-specific variants — the build number must match character for character. Click Link to download (a large .zip, 2–4 GB).
  4. 04Unzip the download. Inside its folder is a second zip named like image-caiman-bp2a.250805.005.zip. Unzip that too.
  5. 05Look inside for init_boot.img. If it's there, that's your file (Pixel 7 and newer). If there's only `boot.img`, use that instead (Pixel 6 and older). Use this file name wherever the next steps say init_boot.img.
  6. 06Copy the file somewhere easy: Mac — your Downloads folder. Windows — C:\platform-tools. Also keep an untouched copy elsewhere: it's how you undo root later. Then go to Step 6.

10

Google's page vs. other brands

Google's factory images page is unusually tidy: one official page, every Pixel, every version, one download per row. Other makers have the same ingredients, just scattered and named differently. Use the first table to translate each thing you'd do on Google's page into what to look for at your brand. The second shows how to read a version string so you can tell whether a download matches your phone.

The rule never changes: same model, same region, same version, full package. If any of the four doesn't match, don't use the file.

Each part of Google's page, translated

The page itself
Pixel: one official Google page. Others: the maker's own download page if it has one (OnePlus for older models, Xiaomi via its servers), an updater app (Oxygen Updater for OnePlus), a PC tool (Motorola Software Fix, Samsung firmware tools), or a community archive that mirrors official files (Nothing Archive).
Codename section
Pixel: you find your codename (e.g. caiman). Others: you find your model code (ro.product.model, e.g. CPH2581) — the same marketing name can cover several model codes, so always go by the code.
Carrier / region rows
Pixel: some builds have carrier variants. Others: region matters much more. OnePlus uses EX01 (Europe), IN (India), NA (North America), GLO (global); Xiaomi has region letters inside the version (MI global, EU Europe, IN India, CN China); Samsung uses a CSC code (e.g. EUX, XAA). Wrong region = wrong file.
Build number in the row
Pixel: ro.build.id, e.g. BP2A.250805.005. Others: the maker's version, from ro.build.display.id or Settings → About phone. Ignore ro.build.id on non-Pixels — it's Google's shared base version.
"Link" (factory .zip)
Others: a "full" OTA zip (OnePlus, Nothing), a "Fastboot ROM" .tgz (Xiaomi), a firmware .zip (Motorola), or a set of .tar.md5 files (Samsung). Avoid "incremental" / "delta" updates — they only contain changes, not the file you need.
Inner image-*.zip
Pixel: unzip twice and init_boot.img is right there. OnePlus / Nothing: the files are packed inside payload.bin — extract with payload-dumper-go (Step 5b). Xiaomi / Motorola: the .img files are already loose in the package. Samsung: inside the AP .tar file.
flash-all script
Pixel's script reinstalls everything. Others use their own restore route: Xiaomi MiFlash, Motorola Software Fix, Samsung Odin, or for OnePlus installing the full zip via Settings → System update → Local upgrade. Know yours before you start.

Reading a version string

Pixel BP2A.250805.005
One build ID for the whole device. Match it exactly against the row on Google's page (plus carrier variant if listed).
OnePlus CPH2581_15.0.0.406(EX01)
CPH2581 = model code · 15.0.0 = OxygenOS 15 · 406 = build number within that version · (EX01) = region, Europe. All four parts must match the download.
Xiaomi OS2.0.x.0.VNCMIXM
OS2.0.x.0 = HyperOS version · V = Android version letter · NC = device code · MI = region (MI global, EU Europe, IN India, CN China…) · XM = Xiaomi. The download name contains the same string.
Nothing / Motorola / Samsung
Each has its own format. Copy the exact string from Settings → About phone and search for it character for character — the right download will contain it.

11

Step 5 (other brands) — Download the full update package

Other makers don't publish a simple list of images like Google does. Instead you download the same update package the phone uses to install a system update, and pull the one file you need out of it (next step).

Two things must be right: it must be the full package (often 4–7 GB), not a small "incremental" update, and it must be for your exact version from Step 4, including the region.

  1. 01Easiest way to get a match: update the phone first. Go to Settings → About device → check for updates, and install everything until it says it's up to date. Most download sources offer the newest version, so this makes them match. (If you just unlocked and the phone is freshly set up, do this now — it doesn't relock anything.)
  2. 02Run adb shell getprop ro.build.display.id again and write down the new version.
  3. 03Download the full package for that exact version from the source for your brand in the table below. Links: Oxygen Updater and OnePlus Software Upgrade · Nothing Archive · Xiaomi Firmware Updater · Motorola Software Fix. Not sure what you're looking at? Google's page vs. other brands above translates each part.
  4. 04Check the file name or the page you downloaded from: the version and region must match what you wrote down, character for character. If you can't find an exact match, stop here — a mismatched file is the main way phones get bricked.
  5. 05Put the .zip on your computer: Mac — Downloads. Windows — C:\platform-tools. If you downloaded it on the phone (e.g. with Oxygen Updater), find it with adb shell ls /sdcard/ /sdcard/Download/. Oxygen Updater saves it in /sdcard/ with a random-looking name like 7da5df3feec64d12ac1b07f28435a09f.zip. Copy it over and give it a readable name by saying where to save it: adb pull /sdcard/7da5df3feec64d12ac1b07f28435a09f.zip ~/Downloads/phone-full.zip (Windows: just phone-full.zip at the end, from C:\platform-tools). It takes a few minutes; the last line shows the size — several GB means full, a few hundred MB means you got an incremental one.
copy the package from the phone (Mac)
adb shell ls /sdcard/ /sdcard/Download/      # find the .zip (Oxygen Updater: random name in /sdcard/)
cd ~/Downloads                               # work in Downloads
adb pull /sdcard/7da5df3feec64d12ac1b07f28435a09f.zip ~/Downloads/phone-full.zip
# ... progress ...
# /sdcard/7da5df…zip: 1 file pulled, 0 skipped. ... (5432109876 bytes ...)   <- several GB = full

# Windows (from C:\platform-tools):
# adb pull /sdcard/7da5df3feec64d12ac1b07f28435a09f.zip phone-full.zip

Where each brand's full package comes from

OnePlus
Newer models: the Oxygen Updater app (third-party, but downloads only official files from OnePlus servers and checks them). In its settings pick your exact device and region, set Update method to Full (not Incremental). It usually offers only the newest version — update the phone first so they match. Older models: OnePlus's official Software Upgrade page lists full ROM zips. Gives you: a full OTA .zip with payload.bin → Step 5b.
Nothing / CMF
The Nothing Archive on GitHub lists official full and incremental OTA links per model and version, and also pre-extracted stock images (then you can skip Step 5b). Gives you: a full OTA .zip with payload.bin, or the .img directly.
Xiaomi / POCO / Redmi
Pick the "Fastboot ROM" (not "Recovery ROM") for your device and region on Xiaomi Firmware Updater, which links Xiaomi's official servers. Gives you: a .tgz; unpack it and the images folder already holds init_boot.img / boot.img — skip Step 5b.
Motorola
Motorola/Lenovo's Software Fix tool for Windows (formerly Rescue and Smart Assistant) downloads the official firmware for your connected phone. Gives you: a folder with boot.img / init_boot.img already loose — skip Step 5b.
Samsung
Works differently. Firmware tools (e.g. Frija, Bifrost) download it by model + CSC; you get AP, BL, CP and CSC .tar.md5 files. Older models: patch the whole AP file in Magisk. Newer (S23 and later): pull init_boot.img out of the AP file and patch that. You flash with Odin in Download mode, not fastboot. Not covered step by step here.

Note

adb: error: cannot create file/directory '.' — this comes from your computer, not the phone. adb pull saves into the folder your terminal is currently in (see Your terminal is always "in" a folder), and that folder no longer exists or can't be written to — for example it was deleted, or it's on a read-only drive. (If other commands also print getcwd: cannot access parent directories or $PWD must be set, it's the same thing: run cd ~/Downloads.) Fix it by naming where to save, as in the command above: ~/Downloads/phone-full.zip. That also gives the file a readable name instead of the random code Oxygen Updater uses.

12

Step 5b (other brands) — Pull the file out of the package

Inside the update .zip is one big file called payload.bin that holds every part of the phone's software. A small free tool, payload-dumper-go, copies out just the part you need. You don't even need to unzip the package first.

  1. 01Install the tool. Mac: run brew install payload-dumper-go. Windows: download the …_windows_amd64.tar.gz file from its releases page, then in your Command Prompt (in C:\platform-tools) run tar -xzf followed by that file name. That puts payload-dumper-go.exe next to adb.
  2. 02Mac only: run cd ~/Downloads. (Windows: you're already in C:\platform-tools.)
  3. 03See what's inside: run payload-dumper-go -l followed by your .zip's name. You should see: a list of parts such as boot, init_boot, system, vendor… If it prints Delta payload … pass -old, or the parts are marked delta, you downloaded an incremental update (only the changes between two versions) — extracting will fail with an error like not supported yet: boot (PUFFDIFF). Go back and get the Full one. A random-named .zip in the phone's storage is usually the phone's own incremental system update, not what you want.
  4. 04If the list contains `init_boot`, extract that. Otherwise extract boot. (This matches the first_api_level rule from Step 4.)
  5. 05Run the extraction (commands below). It takes under a minute. You should see: a new folder named extracted containing init_boot.img (or boot.img).
  6. 06Move that .img file out of the extracted folder into Downloads (Mac) or C:\platform-tools (Windows). Keep an untouched copy elsewhere — it's your undo. Then go to Step 6.
extract (Mac shown; on Windows use payload-dumper-go.exe)
cd ~/Downloads
payload-dumper-go -l your-update.zip          # list the parts (use your real file name)
payload-dumper-go -p init_boot -o extracted your-update.zip
# no init_boot in the list? use:  -p boot
ls extracted                                                           # init_boot.img

Note

On a Mac, if you downloaded the tool by hand instead of with brew and it says it "cannot be opened because the developer cannot be verified", run xattr -d com.apple.quarantine payload-dumper-go and chmod +x payload-dumper-go, then run it as ./payload-dumper-go.

13

Step 6 — Install Magisk and patch the file

  1. 01Download the newest Magisk-vXX.X.apk from the Assets list on Magisk's official releases page. This GitHub page is the only official source — Magisk on the Play Store or other websites is fake.
  2. 02Mac only: in Terminal, run cd ~/Downloads so the commands can find your files. (Windows: you're already in C:\platform-tools.)
  3. 03Install the app: run adb install Magisk-vXX.X.apk using the real file name. You should see: Success.
  4. 04Copy the system file to the phone: adb push init_boot.img /sdcard/Download/.
  5. 05On the phone: open Magisk. Next to Magisk, tap Install → choose Select and Patch a File → pick init_boot.img from Downloads → tap Let's Go.
  6. 06You should see: "All done!" and an output file name like magisk_patched-29000_aB1cD.img. It's saved in the phone's Download folder.

14

Step 7 — Flash the patched file

  1. 01Find the exact patched file name: run adb shell ls /sdcard/Download/.
  2. 02Copy it to the computer: adb pull /sdcard/Download/magisk_patched-29000_aB1cD.img (use your real name).
  3. 03Reboot into fastboot: adb reboot bootloader.
  4. 04Flash it: fastboot flash init_boot magisk_patched-29000_aB1cD.img. If your file was boot.img, type boot instead of init_boot. You should see: Sending…OKAY and Writing…OKAY.
  5. 05Restart: fastboot reboot. You should see: the phone start normally (after the unlock warning).
flash
adb shell ls /sdcard/Download/
adb pull /sdcard/Download/magisk_patched-XXXXX.img
adb reboot bootloader
fastboot flash init_boot magisk_patched-XXXXX.img   # 'boot' if you patched boot.img
fastboot reboot

Note

If the phone keeps restarting and never reaches the home screen, don't panic. Go to Undo: back to normal and flash the untouched file you kept.

15

Step 8 — Check that root works

  1. 01Open the Magisk app. You should see: a version number next to Installed (not "N/A"). If it asks for additional setup, tap OK and let it reboot.
  2. 02On the computer, run adb shell, then su.
  3. 03On the phone: Magisk asks whether to grant Shell superuser access. Tap Grant.
  4. 04Back in the terminal, run id. You should see: uid=0(root). Your phone is rooted. Type exit twice to leave.
  5. 05Now install your app (or this library's example app) and see whether it detects root. With library 0.3+ and no hiding, you should see: COMPROMISED with bootloader_unlocked, root_su_binary, root_management_apps and root_magisk_files. On a physical phone the example's debug build needs Metro: run adb reverse tcp:8081 tcp:8081 (again after every reconnect), or it shows Unable to load script.
test root
adb shell
su            # approve the prompt on the phone; the prompt changes to #
id            # uid=0(root) ...
exit
exit

16

If something goes wrong

Find the message you're seeing in the list below.

Messages and what they mean

adb: no devices/emulators found
adb can't see the phone. Most often the phone is in fastboot mode (run fastboot reboot first). Otherwise: USB debugging is off, the cable is charge-only, or the "Allow USB debugging?" prompt wasn't accepted.
fastboot devices shows nothing
The phone isn't in fastboot mode, or the cable/port isn't working. On Windows, install the Google USB Driver.
unauthorized
Unlock the phone screen and accept the "Allow USB debugging?" prompt. If it never appears: Developer options → Revoke USB debugging authorizations, unplug, plug back in.
command not found / is not recognized
adb/fastboot isn't installed, or (Windows) your Command Prompt isn't open in C:\platform-tools.
A fastboot command hangs
Any fastboot command (getvar, flash, reboot) should finish in seconds. If it sits after the "pipe" lines, the USB link stalled — common on Macs. Press Ctrl+C (safe for getvar/reboot), unplug and replug directly into the computer (no dock or adapter), and retry. If it keeps happening: try another cable — a USB-A to USB-C cable through a simple USB hub often works better on Macs — and update the tools (brew upgrade android-platform-tools).
Stuck after "Rebooting"
The terminal hangs, or the phone stays on the Fastboot Mode screen. Press Ctrl+C in the terminal (safe — the command was already sent). Unplug the cable, then on a Pixel press Volume until the top says Start and press Power. If the screen has no menu (just the logo, "Fastboot Mode" and a robot — newer OnePlus/OPPO/Realme), hold Power + Volume Up for 10–15 seconds instead. If commands often fail this way, plug directly into the computer (no hub or adapter) and try another cable. After an unlock, the first start can take 5–10 minutes — leave it alone.
Start goes back to Fastboot Mode
Android can't start. Read the small text at the bottom of the fastboot screen for an error. If you only unlocked: choose Recovery mode; at the "No command" robot, hold Power and tap Volume Up once; then Wipe data/factory reset → Reboot system now. If you flashed a file, flash the untouched one back (see Undo).
could not clear input pipe
Harmless macOS USB message. Ignore it.
FAILED (remote: 'unknown command')
That phone's bootloader doesn't support the command you typed (e.g. fastboot oem device-info). Not harmful. Use fastboot getvar unlocked instead.
unlock is not allowed
OEM unlocking is off, or the phone is carrier-locked. Turn on OEM unlocking in Developer options and try again.
Unable to load script
A debug build of the example app can't reach Metro, the JavaScript server on your computer. Start it (yarn example start) and connect the phone's port to it: adb reverse tcp:8081 tcp:8081. The tunnel resets whenever the phone disconnects or reboots — run it again.
partition does not exist
From fastboot flash init_boot: your phone has no init_boot partition, so nothing was written — no harm done. Use fastboot flash boot <your patched file> instead (and make sure you patched boot.img, not init_boot.img). The "skip copying init_boot image avb footer … partition size: 0" warning just before it means the same thing.
fastboot flash hangs
Look at the last line. Nothing after the "pipe" lines (no Sending): nothing reached the phone yet — wait a minute, then Ctrl+C is safe; replug directly into the computer and run the same flash again. Stuck on Sending: also safe to stop and retry. Stuck on Writing: wait several minutes and don't unplug. If you do have to stop, flash again before restarting the phone — or flash the untouched image (see Undo).
Delta payload … pass -old
From payload-dumper-go, often followed by "not supported yet: boot (PUFFDIFF)". You downloaded an incremental (delta) update: it only holds the changes from one version to the next, and partitions in the list are marked "delta". You can't get a usable boot.img from it. Delete it and download the Full package for your exact version (Step 5, other brands). In a full package, -l lists the partitions without "delta". Phones' own system-update downloads are almost always incremental.
getcwd: cannot access parent directories
Also shown as "$PWD must be set to run brew" or shell-init / job-working-directory errors. The folder your terminal was in has been deleted (or its drive unplugged), so every command fails before it starts. Run cd ~/Downloads and try again. If it keeps happening, close the Terminal window, open a new one, and cd ~/Downloads first.
cannot create file/directory '.'
Comes from your computer, not the phone. adb pull saves into the folder your terminal is currently in, and that folder no longer exists or can't be written to (deleted, or on a read-only drive). Name where to save instead: cd ~/Downloads, then adb pull /sdcard/<file>.zip ~/Downloads/phone-full.zip — which also gives it a readable name. Windows: run it from C:\platform-tools.
adb: cannot stat / No such file
The file name or folder is wrong. On Mac run cd ~/Downloads first; check spelling with ls (Mac) or dir (Windows).
Magisk shows Installed: N/A
The patched file wasn't flashed, or was flashed to the wrong place (boot vs init_boot). Redo Step 7.
Phone restarts endlessly
Bootloop. Usually the file came from the wrong build. Follow Undo below, then re-check your build number and download.

17

Undo: back to normal

  1. 01To remove root, flash the untouched file you kept from Step 5 / 5b the same way you flashed the patched one.
  2. 02Put the phone in fastboot mode: adb reboot bootloader, or power off and hold Power + Volume Down.
  3. 03Run fastboot flash init_boot init_boot.img (or boot boot.img), then fastboot reboot.
  4. 04To restore the whole phone to factory software, run the flash-all.sh (Mac) or flash-all.bat (Windows) script inside the factory image folder while in fastboot mode — or use Google's browser-based Android Flash Tool.
  5. 05Only re-lock the bootloader (fastboot flashing lock) after the phone is fully back to factory software. Locking with root still installed leaves a phone that won't start.
restore
adb reboot bootloader
fastboot flash init_boot init_boot.img   # the untouched one; or: boot boot.img
fastboot reboot

18

Going further: other root methods

Magisk is the right first test. Once it works, two other methods hide root more deeply and are worth testing your detection against. They differ in where the root hook lives, which drives how detectable and how portable they are. These assume you're comfortable with the steps above.

19

KernelSU / KernelSU-Next — kernel-based root

Root implemented inside the kernel. More powerful isolation and harder to detect from userspace, but requires a GKI-compatible kernel (generic kernel image, Android 12+) or a device-specific kernel build. KernelSU-Next is the community fork most people run in 2026 because it tracks fixes and pairs with SUSFS for hiding. Best for stronger root isolation, kernel-level testing, and better hiding when combined with SUSFS. Requires exact kernel matching — more fragile than Magisk.

  1. 01Determine your kernel version: adb shell uname -r (e.g. 5.10.x, 5.15.x, 6.1.x).
  2. 02Match it to a prebuilt KernelSU / KernelSU-Next AnyKernel3 zip or boot image for your exact kernel from KernelSU or KernelSU-Next releases (WildKernels GKI+SUSFS builds bundle SUSFS).
  3. 03Flash the patched kernel/boot image (see command below).
  4. 04Install the KernelSU Manager app; it should report Working with the kernel version.
flash-kernelsu
fastboot flash boot kernelsu-boot.img
fastboot reboot

20

APatch — kernel patching, no source needed

A middle ground: patches the kernel binary directly (like KernelSU's power) but works without a matching prebuilt kernel by patching your own boot.img — closer to Magisk's convenience. Provides KPM (kernel patch modules) and APM (Magisk-style modules). Newer and smaller community than the other two. Best for kernel-level root when no prebuilt KernelSU kernel exists for your device.

  1. 01Extract boot.img from your factory image.
  2. 02Install the APatch app (bmax/APatch on F-Droid or GitHub releases).
  3. 03In the app, patch boot.img with a superkey you set, then flash the output the same fastboot flash boot way.
  4. 04Verify in the app.

21

Quick comparison

Magisk

Hook location
Userspace (boot ramdisk)
Needs matching kernel build
No
Module ecosystem
Largest
Detection resistance (raw)
Moderate
Fragility / brick risk
Lowest
Best first test
Yes

KernelSU / -Next

Hook location
Kernel
Needs matching kernel build
Yes (GKI or custom)
Module ecosystem
Growing (+ KernelSU modules)
Detection resistance (raw)
High
Fragility / brick risk
Higher (kernel match)
Best first test
For kernel-level work

APatch

Hook location
Kernel (patched binary)
Needs matching kernel build
No
Module ecosystem
KPM + APM
Detection resistance (raw)
High
Fragility / brick risk
Medium
Best first test
Fallback for non-GKI

22

Hiding root & Play Integrity

For app QA this is usually the point — you want to see whether your app (or a third-party one) detects root, and whether standard hiding defeats it.

Magisk: DenyList to hide root from selected apps; the built-in Zygisk. Pair with Play Integrity Fix / PIF modules to spoof a passing device fingerprint for BASIC/DEVICE verdicts. STRONG integrity (hardware-backed) generally cannot be passed on an unlocked bootloader — that is expected and is itself a useful test result.

KernelSU-Next + SUSFS: hides root at the kernel/filesystem layer (mounts, props), which defeats more aggressive detectors than DenyList alone.

APatch: similar hiding via its module system.

For app-resilience testing, run each config against tools like Play Integrity API checkers, RootBeer-based detectors, and your own root checks, and record which verdicts each method yields.

Note

The fingerprint/PIF cat-and-mouse changes constantly. Expect to update PIF modules and fingerprints periodically; treat “does hiding still work this month” as part of the test, not a one-time setup.

23

A repeatable test matrix

To test multiple root methods systematically, root the device, capture results, restore to stock, and repeat with the next method. Keep a simple results sheet: method × (su works / DenyList hides / PIF BASIC / PIF DEVICE / your-app detects Y-N).

  1. 01Flash stock boot/init_boot to return to an unrooted baseline.
  2. 02Install method A → run your full detection/integrity test suite → log results.
  3. 03Restore stock → install method B → repeat.
  4. 04Restore stock → method C → repeat.

24

Reality checks

  1. 01Match every image to your exact build. Wrong boot.img = bootloop or brick.
  2. 02Samsung Knox and hard-locked carrier devices are the ones that punish rooting permanently — avoid for testing unless that is specifically what you are testing.
  3. 03STRONG Play Integrity on an unlocked bootloader is meant to fail — do not chase it.
  4. 04Prefer a Pixel or other GKI device so all three methods are testable on one phone.