[Guide] Flash Magisk on Android 12

Search This thread

myhuky3

Member
Nov 30, 2018
21
29
Google Pixel 7 Pro
Trying to root the Pixel 5 running Android 12 by flashing a magisk-patched boot image results in the phone only booting to fastboot mode ("failed to load/verify boot images")
Some users have reported that booting (instead of flashing) the patched boot image works and makes root temporarily available but i didn't have any success with that.
The phone booted up but root didn't work.

I won't explain how to unlock the bootloader or set up adb here.

!Warning! This will wipe your phone so take a backup!

Also i do not take any responsibility if you break your device.
And if anything goes wrong just factory reset your device using the Android Flash Tool or by following this tutorial.

Here's what i did to get Magisk v22.0 working on the first developer preview of Android 12:


Install A12 with disabled AVB & dm-verity:
  1. Make sure USB-Debugging is enabled in developer-options and you have authorized the pc you're using on your phone.

  2. Boot your phone into fastboot mode.
    You can do this by turning it off and then starting it by holding Power + Volume Down
    until fastboot mode appears or just adb reboot bootloader

  3. Go here and click on the link for the Android Flash Tool.
    (I didn't copy the link directly so i don't have to update it everytime google releases a new update)

  4. It should ask you to allow the website to access ADB Keys. Click Ok.
    If the website somehow doesn't work, try using Google Chrome.

  5. Select your Pixel 5. If it's not showing up click add device.

  6. Click on the edit symbol (pen) in the box where the selected build is shown.

  7. Make sure Wipe Device, Disable Verity and Disable Verification are checked.

  8. Install and boot the phone when it's finished.

Patch & flash boot.img
  1. Download and install the Magisk Canary App from GitHub.

  2. Download the factory image from here and extract boot.img from it.
    (Inside the downloaded zip-file is another zip file containing the boot image)

  3. Copy the extracted boot.img to your phone and open the magisk app.

  4. Click on Install -> Select and Patch a File and let it do its magic.

  5. Copy the magisk-patched boot image that should be found in your phones download folder back to your PC.

  6. Reboot into fastboot mode as i explained earlier and flash the patched boot image.
    (fastboot flash boot magisk_patched.img)
    Then reboot the device.

Now root should be working. If it bootloops and says your phone has to be factory reset, do it.
If for some reason you still get an AVB-Error and end up stuck in fastboot mode just flash the stock image and try to patch it again.

This is my first post on here and i didn't have much time but i'm glad if it helped at least one person.
 

myhuky3

Member
Nov 30, 2018
21
29
Google Pixel 7 Pro

Attachments

  • Screenshot_20210424-110829.png
    Screenshot_20210424-110829.png
    72.2 KB · Views: 295

tauio111

Senior Member
Feb 27, 2011
613
419
Google Pixel 5
Dirty flashing newer factory images will restore the verity and verification state, so when you patch the kernel with magisk it will fail to boot again.
Installing a verity and verification disabled image without wiping from the web based flasher will also corrupt your data and not let the phone boot, forcing you to wipe.

Wonder what the flags are for flashing factory images with verity and verification state off and giving the ability to continue on without wiping and being able to boot the magisk patched kernel again.

fastboot update --disable-verity --disable-verification image-redfin-spp3210325.010.zip maybe?


Or prepatch the boot.img before flashing it with fastboot, and then flashing it back before rebooting from after flashing the factory image as an update?
 
Last edited:
  • Like
Reactions: V0latyle

myhuky3

Member
Nov 30, 2018
21
29
Google Pixel 7 Pro
Dirty flashing newer factory images will restore the verity and verification state, so when you patch the kernel with magisk it will fail to boot again.
Installing a verity and verification disabled image without wiping from the web based flasher will also corrupt your data and not let the phone boot, forcing you to wipe.

Wonder what the flags are for flashing factory images with verity and verification state off and giving the ability to continue on without wiping and being able to boot the magisk patched kernel again.

fastboot update --disable-verity --disable-verification image-redfin-spp3210325.010.zip maybe?


Or prepatch the boot.img before flashing it with fastboot, and then flashing it back before rebooting from after flashing the factory image as an update?
Don't know but sounds interesting. I just use
Code:
fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
after every update
 

THEVAN3D

Senior Member
May 31, 2014
249
61
OnePlus One
OnePlus 8
I just installed the newest Public Beta via OTA. Can I root? I was rooted on 11 before and just enrolled in the beta program and installed it via OTA. Without factory reset or reflash. Now I tried patching boot.img via Magisk Manager, but it wont boot. I mean it boots, but wont unlock phone to homescreen. I'm locked out of my phone. Reverted back to stock PB1 boot image. Any ideas without factory reset?
 

QuickInfo

Senior Member
Sep 1, 2012
266
57
I just installed the newest Public Beta via OTA. Can I root? I was rooted on 11 before and just enrolled in the beta program and installed it via OTA. Without factory reset or reflash. Now I tried patching boot.img via Magisk Manager, but it wont boot. I mean it boots, but wont unlock phone to homescreen. I'm locked out of my phone. Reverted back to stock PB1 boot image. Any ideas without factory reset?
I just tried it using the canary build and it won't boot either. It gets stuck at the Bootloader screen and shows "Failed to load/verify boot images". Maybe we need to wait for an update to for Magisk?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 21
    Trying to root the Pixel 5 running Android 12 by flashing a magisk-patched boot image results in the phone only booting to fastboot mode ("failed to load/verify boot images")
    Some users have reported that booting (instead of flashing) the patched boot image works and makes root temporarily available but i didn't have any success with that.
    The phone booted up but root didn't work.

    I won't explain how to unlock the bootloader or set up adb here.

    !Warning! This will wipe your phone so take a backup!

    Also i do not take any responsibility if you break your device.
    And if anything goes wrong just factory reset your device using the Android Flash Tool or by following this tutorial.

    Here's what i did to get Magisk v22.0 working on the first developer preview of Android 12:


    Install A12 with disabled AVB & dm-verity:
    1. Make sure USB-Debugging is enabled in developer-options and you have authorized the pc you're using on your phone.

    2. Boot your phone into fastboot mode.
      You can do this by turning it off and then starting it by holding Power + Volume Down
      until fastboot mode appears or just adb reboot bootloader

    3. Go here and click on the link for the Android Flash Tool.
      (I didn't copy the link directly so i don't have to update it everytime google releases a new update)

    4. It should ask you to allow the website to access ADB Keys. Click Ok.
      If the website somehow doesn't work, try using Google Chrome.

    5. Select your Pixel 5. If it's not showing up click add device.

    6. Click on the edit symbol (pen) in the box where the selected build is shown.

    7. Make sure Wipe Device, Disable Verity and Disable Verification are checked.

    8. Install and boot the phone when it's finished.

    Patch & flash boot.img
    1. Download and install the Magisk Canary App from GitHub.

    2. Download the factory image from here and extract boot.img from it.
      (Inside the downloaded zip-file is another zip file containing the boot image)

    3. Copy the extracted boot.img to your phone and open the magisk app.

    4. Click on Install -> Select and Patch a File and let it do its magic.

    5. Copy the magisk-patched boot image that should be found in your phones download folder back to your PC.

    6. Reboot into fastboot mode as i explained earlier and flash the patched boot image.
      (fastboot flash boot magisk_patched.img)
      Then reboot the device.

    Now root should be working. If it bootloops and says your phone has to be factory reset, do it.
    If for some reason you still get an AVB-Error and end up stuck in fastboot mode just flash the stock image and try to patch it again.

    This is my first post on here and i didn't have much time but i'm glad if it helped at least one person.
    6
    @Anonshe posted ths method in the Pixel 6 Pro thread. Does this work for the Pixel 4a 5(G), Pixel 5 or the Pixel 5a?
    Just updated my Pixel 5 to the November Sec Patch without any data loss. Since I'd disabled vbmeta before, steps were simple:
    - Used Payload Dumper to extract the boot and vbmeta images. Patched the former.
    - Rebooted to Recovery
    - Sideloaded the OTA package
    - Reboot to bootloader from the recovery menu
    Code:
    fastboot --disable-verification --disable-verity flash vbmeta vbmeta.img
    Code:
    fastboot boot magisk_patched.img

    After it booted up, opened Magisk Manager, installed via Direct Install. All works fine.
    5
    For those of you who don't have safetynet working, here.
    All credit goes to @kdrag0n, I just modified the shell scripts for B3

    Pull request done if you don't want my zip.
    4
    Has anyone sucefully rooted beta 3?
    Patched boot image with magisk canary if I only boot the image it starts
    Then tried to flash patched boot image and get stuck in bootloader
    For all the updates from beta 2 - 3 I've followed this process without fail:

    - extract boot.img and vbmeta.img from downloaded beta of your relevant device
    - add boot.img to phone (if downloaded, and extracted on another device)
    - patch boot.img in magisk (i like to rename it to patched_magisk.img)
    - move patched_magisk.img to desktop
    - download and install latest beta from the OTA provided
    - tap the reboot button on the OTA install screen once completed
    - once the reboot begins and your screen turns black hit the power and volume down button to get into fastboot
    - run
    fastboot --disable-verity --disable-verification flash vbmeta path/to/vbmeta.img (you can drag img from location)
    - then run
    fastboot flash boot path/to/patched_magisk.img (you can drag img from location)

    This has worked flawlessly, maintaining root while also keeping all my data.
    4
    Yeah I wouldn't do this unless you've started from the initial process op outlined. I did this moving from beta 2 to 2.1 and then beta 2.1 to beta 3. However beta 2 was my first android 12 install, which I used ops procedure to achieve.

    Do this:
    You don't need the Android flash tool. I have been manually flashing full images for a long time:
    I don't like things done behing my back.

    For beta 3:
    I flash both sides hence the skip secondary - it saves a few seconds.
    When flashing - watch what's scrolling by. The vbmeta.img is modified on the fly.
    No need to copy from another build or someone else's hack.
    Below is what I use. Successfully.

    Modify the last line in the flash-all.bat or.sh
    fastboot --skip-reboot --skip-secondary --disable-verity --disable-verification update image-redfin-spb3.210618.013.zip