Guide

How to patch a boot image with Magisk

Patching a stock image in the Magisk app and flashing it with fastboot is the main install method in Magisk's documentation. You don't need TWRP. This guide covers the whole process, plus the parts people get stuck on: finding the right image for your exact build, A/B slots, fastboot boot versus flash, and what fastboot's errors mean.

Last updated 16 sourcesHow we check pages

Before you start

  • Your phone's bootloader must be unlocked. Unlocking erases the phone. Brand-specific steps: Pixel, Samsung, Xiaomi, Redmi and POCO, OnePlus, Nothing and Motorola.
  • A computer with Android's adb and fastboot (Google's SDK Platform-Tools, latest version) and a good USB cable.
  • The stock firmware for the exact build your phone is running (Settings → About phone → Build number).
  • On a Samsung phone, follow the Samsung guide instead: you patch the firmware's whole AP file and flash it in Download mode, not with fastboot.

The process

Patching and flashing at a glance

  1. 1Pick the imageinit_boot, boot, vendor_boot or recovery
  2. 2Get it from your buildSame build number as the phone
  3. 3Patch in the appOn the phone you're rooting
  4. 4Flash with fastbootWrites the active slot
  5. 5Reboot, finish setupThe Magisk card shows a version
The sequence in Magisk's installation guide (v31.1), with the fastboot slot behaviour from AOSP's fastboot help text.

Not sure which method applies to your phone at all? Start at how to install Magisk or answer three questions in the root method checker.

Which image: init_boot, boot, vendor_boot or recovery?

Magisk patches the image that holds the phone's boot ramdisk. Where that ramdisk lives depends on how old the phone's design is:

Your phonePatchWhy
Firmware contains init_boot.img (normally phones that launched with Android 13 or later)init_boot.imgAOSP moved the generic ramdisk out of boot into init_boot for devices launching with Android 13; boot then holds only the kernel.
Firmware has init_boot.img, but the kernel is Android 12 GKI or olderboot.imgMagisk's installer only uses init_boot with a kernel newer than Android 12 GKI. Check with adb shell uname -r: a version containing android12-, or 5.4 and older, means boot.img.
No init_boot.img, Ramdisk: Yesboot.imgPhones that launched with Android 12 or earlier keep their layout after upgrading.
Ramdisk is in vendor_boot (a few devices)vendor_boot.imgSupported since Magisk v30.3; the first stable release with it was v30.6. The app doesn't detect these devices for you: your device's community will say so.
Ramdisk: Norecovery.imgNo ramdisk in boot, so Magisk takes over recovery. See Magisk in recovery.

The most common mistake is patching boot.img on a phone that uses init_boot: the flash succeeds, but Magisk never starts and the app shows Not Installed (v31.1) or Installed: N/A (v30.7). When in doubt, look inside your firmware package. If it only has a payload.bin, list its contents with payload-dumper-go -l payload.bin.

Getting the stock image for your exact build

The image has to come from the same build as the one installed on the phone. Compare Settings → About phone → Build number with the firmware's version before you download. Use a full package: an incremental (delta) OTA only contains changes, not complete images.

  • Google Pixel: Google's factory images or full OTA images, or let v31.1 fetch it. See the Pixel guide.
  • Samsung: the full firmware from Samsung's servers with samloader-rs; you patch the whole AP file. See the Samsung guide.
  • OnePlus, Nothing, Xiaomi, Motorola: the full update package or fastboot ROM for your build. Where each brand's comes from: device guides.
  • Custom ROMs: the image inside the ROM's own zip.

Packages that only contain payload.bin

Full OTA zips for A/B phones usually hold one payload.bin instead of separate images. You have three options:

  • Give the whole zip or payload.bin to the Magisk app. Both v30.7 and v31.1 extract init_boot.img (or boot.img if there is none) and patch it in one go.
  • Extract it on your computer with a payload dumper such as payload-dumper-go, then copy the image to the phone:
Extract from payload.bin
# list the partitions in the payload $payload-dumper-go -l payload.bin # extract only the one you need into ./extracted $payload-dumper-go -p init_boot -o extracted payload.bin
  • Use Magisk's own tool. magiskboot extract payload.bin pulls out init_boot or boot. Since v31.1, magiskboot can be built to run on Linux and macOS computers.

Our run: a Pixel 7 update

We downloaded Google's full update for the Pixel 7, Android 17 build CP3A.261005.002.A1 (October 2026), checked it against the SHA-256 Google lists, and let Magisk's own tool pick the image. With no partition named, magiskboot extract chose init_boot, the same choice the app makes on this phone. The update's own metadata names the exact build, which is how you check a package matches your phone (compare it with Settings → About phone → Build number):

Pixel 7 Android 17 update: which build it is, and init_boot.img out of payload.bin
$unzip -p panther-ota-cp3a.261005.002.a1-6edb8dc9.zip META-INF/com/android/metadata ota-property-files=payload_metadata.bin:4677:53617,payload.bin:4677:3111995623,payload_properties.txt:3112000352:155,apex_info.pb:2058:1747,care_map.pb:3846:790,metadata:63:672,metadata.pb:797:1219 ota-required-cache=0 ota-streaming-property-files=payload.bin:4677:3111995623,payload_properties.txt:3112000352:155,apex_info.pb:2058:1747,care_map.pb:3846:790,metadata:63:672,metadata.pb:797:1219 ota-type=AB post-build=google/panther/panther:17/CP3A.261005.002.A1/16269273:user/release-keys post-build-incremental=16269273 post-sdk-level=37 post-security-patch-level=2026-10-05 post-timestamp=1788575968 pre-device=panther $unzip -o panther-ota-cp3a.261005.002.a1-6edb8dc9.zip payload.bin Archive: panther-ota-cp3a.261005.002.a1-6edb8dc9.zip signed by SignApk extracting: payload.bin $./magiskboot extract payload.bin $ls -l *.img -rw-rw-rw- 1 root root 8388608 Oct 27 04:36 init_boot.img $sha256sum init_boot.img fa9bcf68d5659bbf0513e3838e2ba763b94c675017ba19e633bfce4873c3e5b5 init_boot.img

Lines 17 to 36 of the unedited output. Full log · how it was made

What the Magisk app can patch directly

Featurev30.7v31.1
Raw .img fileYesYes
payload.binYesYes
Full OTA or ROM .zipYesYes
Pixel factory image .zipNoNested zip not readYes
Samsung AP tarYesYes
HTTPS link to a packageNoYesEnter image URL
Fetch the Pixel image for youNoYesPixels only
Take vendor_boot or recovery from a packageNoExtract it yourselfNoExtract it yourself
From the app's source (MagiskInstaller.kt at v30.7; PatchFileClassifier.kt and OtaPayloadExtractor.kt at v31.1) and Magisk's changelog. From a package, both versions take init_boot.img if it is there, otherwise boot.img.

Can I just download a boot.img?

No. There is no universal boot.img, and no “boot img APK”. The image has to come from the exact firmware build installed on your phone, and Magisk's documentation is blunt about pre-patched files: never flash a patched image shared by someone else, or one patched on another device, even the same model. Treat any website offering a downloadable patched boot.img as a red flag. The only app you need is the Magisk app, which patches the image you give it.

Patch and flash, step by step

Each step has a Done box so you can keep your place. Your progress is saved in this browser only.

  1. Install the Magisk app and check “Ramdisk”

    2 minutes

    Install the Magisk APK from the download page (it links to the official GitHub release) and open it. The home screen shows a Ramdisk value. Yes: patch init_boot.img, boot.img or vendor_boot.img (see which image). No: patch recovery.img (see Magisk in recovery).

  2. Get the image (or the whole package)

    10 to 30 minutes

    Get the stock image from the firmware for the exact build on your phone, as described in getting the stock image, and copy it to the phone. You can also copy the whole package: both v30.7 and v31.1 extract init_boot.img or boot.img from a payload.bin or a full OTA zip themselves. v31.1 also reads Pixel factory image zips and links. For vendor_boot or recovery, extract the raw image yourself.

  3. Patch it in the Magisk app

    2 minutes
    1. Tap Install in the Magisk card.
    2. If you are patching recovery.img, tick Recovery Mode.
    3. v30.7: choose Select and Patch a File and pick the file.
      v31.1: choose Patch firmware / image, then Select from storage, Enter image URL (a direct HTTPS link to a full OTA zip, factory image zip or .img), or on Pixels Download latest Pixel factory image, which Magisk's guide says fetches the image matching your current build. In the source it falls back to the newest build if yours isn't listed, so check that the build shown under the option matches yours.
    4. Start. The app writes magisk_patched-[version]_[random].img to the phone's Download folder, for example magisk_patched-30700_aB3dE.img from v30.7 (a .tar for Samsung).
    Patch on the same phone

    Magisk's documentation warns: never flash a patched image shared by someone else, or one patched on another phone, even the same model. You may need a full data wipe to recover.

  4. Flash the patched image

    5 minutes

    Copy the file to your computer with adb pull (Magisk's guide warns that MTP is known to corrupt large files). Reboot to the bootloader and flash it to the partition the original came from. Use the real file name.

    Copy and flash
    $adb pull /sdcard/Download/magisk_patched-30700_aB3dE.img $adb reboot bootloader $fastboot devices # flash ONE of these, matching the image you patched $fastboot flash init_boot magisk_patched-30700_aB3dE.img $fastboot flash boot magisk_patched-30700_aB3dE.img $fastboot flash vendor_boot magisk_patched-30700_aB3dE.img $fastboot flash recovery magisk_patched-30700_aB3dE.img $fastboot reboot

    On A/B phones this writes the active slot only, which is what you want. See A/B slots. If a command fails, look up the message in fastboot errors.

  5. Finish setup

    2 minutes

    Reboot and open the Magisk app. If your data was wiped, v30.7 shows a small "stub" app that downloads the full app; with v31.1, install the Magisk APK again yourself (the stub was removed). The app then shows an Additional setup prompt: accept it and it reboots once more. The Magisk card should show an installed version.

    If it shows Not Installed (v31.1) or Installed: N/A (v30.7), see Magisk installed but root not working. If the phone does not boot, see fixing a Magisk bootloop.

How a working install looks in v31.1

  1. A version under Magisk, here 31.1 (31100), means Magisk started from your patched image. That's the only line that proves it.
  2. Zygisk is off after a fresh install. Turn it on in Settings only if a module you want needs it, then reboot.
  3. This line is the app's own version and shows a number whether or not Magisk runs. If the Magisk card says Not Installed, see root not working.
Check this after the last reboot. Illustration drawn from the Magisk v31.1 app's source code: same labels and layout, simplified look. Not a screenshot; v30.7 looks different.

What patching actually changes: our runs

To show exactly what the Magisk app does to your image, we ran Magisk v31.1's own patch script (assets/boot_patch.sh, taken from the official APK) with the Magisk files from the same APK, on two of Google's real images: a Pixel 7's init_boot.img (the case for phones that launched with Android 13 or later) and a generic Android 12 boot.img. We did this on a computer with magiskboot built from the v31.1 source, because a computer can't run the phone's ARM build. Nothing was flashed or booted; this shows the files, not a phone. The flags are the ones the app uses on an encrypted A/B phone.

Pixel 7, Android 17: init_boot.img

Google's stock init_boot.imgAfter Magisk patched it
KernelNone (size 0): the kernel lives in bootNone; boot is never touched
Ramdisk (compressed, lz4_legacy)2,714,528 bytes2,396,273 bytes
initAndroid's own, 2.96 MBmagiskinit from the APK, 184 KB (same SHA-256)
Added by MagiskNothingoverlay.d/sbin/magisk.xz (146 KB) and init-ld.xz (1.54 KB)
Backup inside the imageNone.backup/init.xz (the original init, 955 KB), .backup/.rmlist, .backup/.magisk
Magisk's own status check0 (stock)1 (patched by Magisk)
Image size8 MiB8 MiB

The script's complete output. The lines starting with a dash are the progress messages the app also shows while it patches:

Magisk v31.1's boot_patch.sh on the Pixel 7's init_boot.img, October 27, 2026
$BOOTMODE=true KEEPVERITY=true KEEPFORCEENCRYPT=true PATCHVBMETAFLAG=false RECOVERYMODE=false LEGACYSAR=false bash ./boot_patch.sh init_boot.img - Unpacking boot image Parsing boot image: [init_boot.img] HEADER_VER [4] KERNEL_SZ [0] RAMDISK_SZ [2714528] OS_VERSION [17.0.0] OS_PATCH_LEVEL [2026-10] PAGESIZE [4096] CMDLINE [] RAMDISK_FMT [lz4_legacy] VBMETA - Checking ramdisk status Loading cpio: [ramdisk.cpio] - Stock boot image detected - Patching ramdisk ./boot_patch.sh: line 165: ./magisk: cannot execute binary file: Exec format error Loading cpio: [ramdisk.cpio] Add file [init] (100750) Create directory [overlay.d] (0750) Create directory [overlay.d/sbin] (0750) Add file [overlay.d/sbin/magisk.xz] (100644) Add file [overlay.d/sbin/init-ld.xz] (100644) Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true] Loading cpio: [ramdisk.cpio.orig] Backup [init] -> [.backup/init.xz] Record new entry: [overlay.d] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin/init-ld.xz] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin/magisk.xz] -> [.backup/.rmlist] Create directory [.backup] (0000) Add file [.backup/.magisk] (100000) Dumping cpio: [ramdisk.cpio] - Repacking boot image Parsing boot image: [init_boot.img] HEADER_VER [4] KERNEL_SZ [0] RAMDISK_SZ [2714528] OS_VERSION [17.0.0] OS_PATCH_LEVEL [2026-10] PAGESIZE [4096] CMDLINE [] RAMDISK_FMT [lz4_legacy] VBMETA Repack to boot image: [new-boot.img] HEADER_VER [4] KERNEL_SZ [0] RAMDISK_SZ [2396273] OS_VERSION [17.0.0] OS_PATCH_LEVEL [2026-10] PAGESIZE [4096] CMDLINE [] $ls -l new-boot.img -rw-r--r-- 1 root root 8388608 Oct 27 04:36 new-boot.img $sha256sum new-boot.img 61547ba16db5aaf30bab405a6bb6d2fd55b7d26a8a59e74ff398ce4c7f23bb70 new-boot.img

Lines 14 to 69 of the unedited output. Full log · how it was made

The one line that looks like an error, Exec format error, is the script asking the phone's ARM magisk binary for its pre-init partition, which a computer can't run; on a phone that name is saved in the image. There are no kernel patch attempts, because init_boot has no kernel. Opening the result confirms the swap, and that Magisk recorded the stock image's SHA1 so it can restore it later:

Checking the patched init_boot.img
$./magiskboot cpio ramdisk.cpio "extract .backup/.magisk magisk-config.txt" "extract init init-patched" Loading cpio: [ramdisk.cpio] Extracting entry [.backup/.magisk] to [magisk-config.txt] Extracting entry [init] to [init-patched] Dumping cpio: [ramdisk.cpio] $cat magisk-config.txt KEEPVERITY=true KEEPFORCEENCRYPT=true RECOVERYMODE=false VENDORBOOT=false SHA1=3c21f344a96fa156ea66adc85bd347648305da59 $sha256sum init-patched magiskinit c0c7cc1c8e1afb92bff602164f6aa1bb4103f5028d076216d8bef48496e2f4dc init-patched c0c7cc1c8e1afb92bff602164f6aa1bb4103f5028d076216d8bef48496e2f4dc magiskinit $sha1sum init_boot.img 3c21f344a96fa156ea66adc85bd347648305da59 init_boot.img

Lines 61 to 76 of the unedited output. Full log · how it was made

Restoring it with the uninstaller's command gave back Android's init byte for byte and the stock file list exactly: full log.

So a patched image is your own image with one swap: magiskinit runs first instead of Android's init, keeps the original next to it, and starts it after setting Magisk up (how that works). Magisk swaps init and adds its own files; everything else in the image is yours, unchanged. That is why only an image from your exact build works.

Generic Android 12 kernel: boot.img

Phones that launched with Android 12, such as the Pixel 6, keep the ramdisk in boot.img next to the kernel. We ran the same script on Google's generic boot image android12-5.10-2026-07_r2:

Google's stock imageAfter Magisk patched it
Kernel46,929,092 bytesByte-identical, untouched
Ramdisk (compressed, lz4_legacy)1,380,091 bytes1,118,008 bytes
initAndroid's own, 2.52 MBmagiskinit from the APK, 184 KB (same SHA-256)
Added by MagiskNothingoverlay.d/sbin/magisk.xz (146 KB) and init-ld.xz (1.54 KB)
Backup inside the imageNone.backup/init.xz (the original init, 842 KB), .backup/.rmlist and .backup/.magisk
Magisk's own status check0 (stock)1 (patched by Magisk)
Image size64 MiB64 MiB

The script's output for this image:

Magisk v31.1's boot_patch.sh on Google's GKI boot image, October 27, 2026
$BOOTMODE=true KEEPVERITY=true KEEPFORCEENCRYPT=true PATCHVBMETAFLAG=false RECOVERYMODE=false LEGACYSAR=false bash ./boot_patch.sh boot-5.10.img - Unpacking boot image Parsing boot image: [boot-5.10.img] HEADER_VER [4] KERNEL_SZ [46929092] RAMDISK_SZ [1380091] OS_VERSION [12.0.0] OS_PATCH_LEVEL [2026-11] PAGESIZE [4096] CMDLINE [] KERNEL_FMT [raw] RAMDISK_FMT [lz4_legacy] VBMETA - Checking ramdisk status Loading cpio: [ramdisk.cpio] - Stock boot image detected - Patching ramdisk ./boot_patch.sh: line 165: ./magisk: cannot execute binary file: Exec format error Loading cpio: [ramdisk.cpio] Add file [init] (100750) Create directory [overlay.d] (0750) Create directory [overlay.d/sbin] (0750) Add file [overlay.d/sbin/magisk.xz] (100644) Add file [overlay.d/sbin/init-ld.xz] (100644) Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true] Loading cpio: [ramdisk.cpio.orig] Backup [init] -> [.backup/init.xz] Record new entry: [overlay.d] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin/init-ld.xz] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin/magisk.xz] -> [.backup/.rmlist] Create directory [.backup] (0000) Add file [.backup/.magisk] (100000) Dumping cpio: [ramdisk.cpio] Failed to patch Failed to patch Failed to patch - Repacking boot image Parsing boot image: [boot-5.10.img] HEADER_VER [4] KERNEL_SZ [46929092] RAMDISK_SZ [1380091] OS_VERSION [12.0.0] OS_PATCH_LEVEL [2026-11] PAGESIZE [4096] CMDLINE [] KERNEL_FMT [raw] RAMDISK_FMT [lz4_legacy] VBMETA Repack to boot image: [new-boot.img] HEADER_VER [4] KERNEL_SZ [46929092] RAMDISK_SZ [1118008] OS_VERSION [12.0.0] OS_PATCH_LEVEL [2026-11] PAGESIZE [4096] CMDLINE [] $sha256sum new-boot.img 2345a3f9aae407a4bf0ab1c93a3a516fd6a96a8f13a06e2c34c9a7fcffbffb5a new-boot.img

Lines 11 to 69 of the unedited output. Full log · how it was made

The same harmless Exec format error appears. This time the image has a kernel, so the script also tries its optional kernel patches. Failed to patch, three times, is the script trying three optional kernel patches that its comments say are for Samsung kernels only (RKP, defex and PROCA). Google's kernel doesn't contain them, so it stays unchanged.

We then opened the patched image with the same tool:

Inside the patched image
$./magiskboot cpio ramdisk.cpio test; echo "exit code $?" Loading cpio: [ramdisk.cpio] exit code 1 $./magiskboot cpio ramdisk.cpio "ls -r" Loading cpio: [ramdisk.cpio] d--------- 0 0 0 B 0:0 .backup ---------- 0 0 120 B 0:0 .backup/.magisk ---------- 0 0 76 B 0:0 .backup/.rmlist -rwxr-x--- 0 0 842 KB 0:0 .backup/init.xz drwxr-xr-x 0 0 0 B 0:0 debug_ramdisk drwxr-xr-x 0 0 0 B 0:0 dev drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk/debug_ramdisk drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk/dev drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk/metadata drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk/mnt drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk/proc drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk/second_stage_resources drwxr-xr-x 0 0 0 B 0:0 first_stage_ramdisk/sys -rwxr-x--- 0 0 184 KB 0:0 init drwxr-xr-x 0 0 0 B 0:0 metadata drwxr-xr-x 0 0 0 B 0:0 mnt drwxr-x--- 0 0 0 B 0:0 overlay.d drwxr-x--- 0 0 0 B 0:0 overlay.d/sbin -rw-r--r-- 0 0 1.54 KB 0:0 overlay.d/sbin/init-ld.xz -rw-r--r-- 0 0 146 KB 0:0 overlay.d/sbin/magisk.xz drwxr-xr-x 0 0 0 B 0:0 proc drwxr-xr-x 0 0 0 B 0:0 second_stage_resources drwxr-xr-x 0 0 0 B 0:0 sys drwxr-xr-x 0 0 0 B 0:0 system drwxr-xr-x 0 0 0 B 0:0 system/etc drwxr-xr-x 0 0 0 B 0:0 system/etc/ramdisk -rw-r--r-- 0 0 916 B 0:0 system/etc/ramdisk/build.prop $./magiskboot cpio ramdisk.cpio "extract .backup/.magisk magisk-config.txt" "extract init init-patched" Loading cpio: [ramdisk.cpio] Extracting entry [.backup/.magisk] to [magisk-config.txt] Extracting entry [init] to [init-patched] Dumping cpio: [ramdisk.cpio] $cat magisk-config.txt KEEPVERITY=true KEEPFORCEENCRYPT=true RECOVERYMODE=false VENDORBOOT=false SHA1=00f8258649e76c8952e92180a9ea24f0308e9924 $sha256sum init-patched magiskinit c0c7cc1c8e1afb92bff602164f6aa1bb4103f5028d076216d8bef48496e2f4dc init-patched c0c7cc1c8e1afb92bff602164f6aa1bb4103f5028d076216d8bef48496e2f4dc magiskinit $sha1sum boot-5.10.img 00f8258649e76c8952e92180a9ea24f0308e9924 boot-5.10.img

Lines 13 to 61 of the unedited output. Full log · how it was made

.backup/.magisk records the patch settings and the SHA1 of the stock image, which is how the app knows what Restore Images must put back. The same run shows that restoring returns Android's init byte for byte: see what uninstalling restores.

A/B slots: which one gets flashed?

Most recent phones have two copies of each system partition, called slots A and B (boot_a, boot_b, init_boot_a and so on). Updates are written to the slot you are not using, and the phone switches slots on the next reboot (AOSP). For patching this means:

  • fastboot flash init_boot file.img writes the active slot only. fastboot adds the current slot's suffix for you; its help text says the default is the "current active slot". That is the slot the phone boots, so it is the right one.
  • Don't flash both slots with --slot all unless you know both hold the same build. After an update, the other slot holds the previous build, and a patched image must match the build it boots.
  • Check which slot is active with fastboot getvar current-slot. fastboot getvar slot-count answers 2 on A/B phones.
  • Get the image from the build in the active slot. Settings shows the running build, which is the active slot's.
Check slots in fastboot mode
$fastboot getvar current-slot $fastboot getvar slot-count

Keeping root through later system updates uses the inactive slot on purpose: see keeping root after an OTA.

fastboot boot or fastboot flash?

fastboot flash boot file.imgfastboot boot file.img
What it doesWrites the image to the partitionLoads it into RAM and boots it once ("Download and boot kernel from RAM")
After a rebootStill rootedBack to whatever is on the partition
Works with init_boot.imgYesNo: it has no kernel to boot
Supported by every bootloaderYes, once unlockedNo: some refuse it

Magisk's guide uses fastboot flash. fastboot boot can be a way to test a patched boot.img first on phones that allow it: if the phone starts and the app shows Magisk as installed, Install → Direct Install writes Magisk to the boot partition, the same way an upgrade does. On init_boot phones there is no test boot; flash, and keep the stock image ready to flash back.

Do I need to flash vbmeta?

Usually not. Magisk's guide lists disabling verification on a separate vbmeta partition as optional (fastboot flash vbmeta --disable-verity --disable-verification vbmeta.img, using the stock vbmeta.img) and warns it may wipe your data. For phones without a separate vbmeta partition, the app handles the flags inside the image itself.

Fastboot and patching errors

Search for the message you see. fastboot's own messages are the same everywhere; messages from the phone (shown after FAILED (remote: ...)) depend on the manufacturer, so yours may be worded differently.

< waiting for any device >

Meaning: fastboot on your computer can't see a phone in bootloader mode. It waits until one appears.

Fix: Make sure the phone shows its bootloader screen (adb reboot bootloader), not Android or recovery. Run fastboot devices: an empty list means a USB problem. Try another cable and a port directly on the computer. On Windows, the phone needs a USB driver for fastboot mode (Google's USB driver for Pixels, the maker's driver otherwise).

"Flashing is not allowed in Lock State" or similar

Meaning: the bootloader is still locked, so it refuses to write partitions. The exact wording depends on the manufacturer.

Fix: Unlock first. AOSP's command is fastboot flashing unlock, which only works once OEM unlocking is on in Developer options, and wipes the phone. Brand steps: device guides.

"partition not found", "No such partition" or "partition does not exist"

Meaning: the phone has no partition with that name. The common case is fastboot flash init_boot on a phone that launched before Android 13 and has no init_boot.

Fix: Patch and flash boot.img instead. Check what your firmware contains (see which image).

"Flashing is not allowed for partition" or a request to use fastbootd

Meaning: on phones with dynamic partitions, the bootloader's fastboot only writes some partitions (AOSP lists bootloader, radio, boot and recovery) and leaves the rest to fastbootd, a fastboot mode that runs in Android's recovery.

Fix: Run fastboot reboot fastboot, wait for the fastbootd screen, and flash again. fastboot getvar is-userspace answers yes when you are in fastbootd.

"Write to device failed", "Status read failed" or "Read from device failed"

Meaning: the USB connection dropped in the middle of a transfer.

Fix: Use another cable and a port directly on the computer (not a hub or front-panel port), and update to the latest Platform-Tools. Then flash again: an interrupted write leaves the partition incomplete.

cannot load 'magisk_patched...img': No such file or directory

Meaning: fastboot can't find the file on your computer.

Fix: Run the command in the folder that holds the file, or give its full path. Copy the real file name: it contains a version number and random letters.

fastboot boot fails with "unknown command" or "not supported"

Meaning: this bootloader doesn't allow booting an image from RAM, or the image has no kernel (an init_boot.img never does).

Fix: Use fastboot flash instead. See fastboot boot or flash.

Magisk app: "! No boot image found" or "! Process error"

Meaning: the app couldn't find init_boot.img or boot.img in the file you picked. Typical causes: an incremental OTA, a zip that isn't a firmware package, or (on v30.7) a Pixel factory image zip, whose images sit in a second zip inside.

Fix: Use a full OTA or extract the raw image yourself (see getting the stock image).

Magisk app: "! Boot image patched by unsupported programs"

Meaning: the image was already modified by another root tool, so it isn't stock.

Fix: Magisk's script asks you to "restore back to stock boot image": take a clean image from the original firmware.

Magisk app: "! Unable to unpack boot image"

Meaning: the file isn't a boot image format Magisk's magiskboot understands: often a corrupted copy, a sparse image or the wrong file.

Fix: Copy the image again (with adb push, not MTP) and check you picked the right file.

Flash succeeded but the phone won't boot, or the app shows Not Installed or N/A

See bootloop after flashing and root not detected. The usual cause is an image from a different build, or boot.img patched on an init_boot phone.

Magisk in recovery (phones with no boot ramdisk)

If your boot partition has no ramdisk, Magisk takes over the recovery partition. Patch recovery.img with Recovery Mode ticked and flash it with fastboot flash recovery. You then boot "through recovery" every time you want root. From power off:

  • Power on normally: Android starts without Magisk.
  • Recovery key combination, then release all buttons at the splash screen: Android starts with Magisk.
  • Recovery key combination, then hold Volume Up: the real recovery mode.

The key combination depends on the model (Magisk's guide gives Power + Bixby + Volume Up for the Galaxy S10). In this setup you cannot use a custom recovery to install or upgrade Magisk. A/B phones never need this method: Magisk always treats them as having a boot ramdisk.

What about TWRP or other custom recoveries?

Magisk's documentation describes installing through a custom recovery (renaming the APK to .zip and flashing it) as deprecated and "maintained with minimum effort", and not recommended on modern devices. The patching method above works without one. More on the other routes: install methods.

Sources

This page is written from the sources below. If anything here disagrees with them, the upstream source is correct.

Found a mistake or something out of date? Tell us and we will check it against the source and fix the page. Confirmed corrections are listed in the corrections log.

Report a problem with this page