• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[Guide] Flash Magisk on Android 12

Search This thread

V0latyle

Forum Moderator
Staff member
I would like to recognize @ipdev for finding this:
To add to V0latyle's post.

Pixel 4a [sunfish] has no issue updating and installing Magisk on Android 12.

The issue starts with Pixel 4a (5G) [bramble].
This is also the first Pixel using Boot Header v3.
Boot image header, version 3 - source.android - Link
Vendor boot header - source.android - Link

The 3, 3a, and 4 series along with 4a are using header v2.

4a (5G), 5 and 5a are using header v3.

Just downloaded and checked.
6 and 6 Pro are using header v4.

I am not sure if that is the problem but, it is quite a distinguishing line between Pixels that have this issue with Magisk and those that do not on Android 12. 🙃

After a little more testing on my 5 [redfin], I will open an issue on GitHub.
Magisk - GitHub - Issues - Link

Cheers all. :cowboy:
We still don't know if this has something to do with our issue, but there's a huge chance it does.
 

elong7681

Senior Member
May 23, 2015
365
118
40
US
Moto X4
Google Pixel 2 XL
I would like to recognize @ipdev for finding this:

We still don't know if this has something to do with our issue, but there's a huge chance it does.
You had stated earlier that you can disable rollback protection, do you think it would be possible to go from stable a12 back to a12 beta 5, flash magisk_patched.img and then update via OTA sideload and keep root without a wipe?
 

V0latyle

Forum Moderator
Staff member
You had stated earlier that you can disable rollback protection, do you think it would be possible to go from stable a12 back to a12 beta 5, flash magisk_patched.img and then update via OTA sideload and keep root without a wipe?
I don't know the command to disable rollback protection. I don't know if it's actually the problem here.

Yes, you could dirty flash beta 5 over stable, then upgrade via OTA sideload and keep root.
 

elong7681

Senior Member
May 23, 2015
365
118
40
US
Moto X4
Google Pixel 2 XL
I don't know the command to disable rollback protection. I don't know if it's actually the problem here.

Yes, you could dirty flash beta 5 over stable, then upgrade via OTA sideload and keep root.
I found this https://android.googlesource.com/platform/external/avb/+/master/README.md about AVB 2.0 and rollback protection being included together. There might also be something in this link that may help us with the wipe data for permanent root.
 

V0latyle

Forum Moderator
Staff member
So, here's what we have been doing wrong, according to @Anonshe .

When we update, we must disable verity and verification prior to booting system. Update method shoould not matter.

If verity and verification are already disabled, you should be able to reflash /vbmeta as long as you don't boot into system.
 

Anonshe

Senior Member
Aug 11, 2016
161
110
@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.
 

V0latyle

Forum Moderator
Staff member
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.
I did the same, except I extracted the images from the factory zip.

I successfully did both OTA sideload and dirty factory flash with no issues.

Oddly, I'm still seeing a software update available...
 
Last edited:

prgopala

Senior Member
Jun 10, 2010
511
117
Sydney
Google Pixel 6 Pro
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.
Assume this only works where you have wiped and clean installed android 12 for the first time.
I had updated from Android 11 -> Android beta 12.5 -> Android 12 and had those 'data corrupt' warnings. I have not wiped my phone yet and was using temp root by booting the magisk boot image.

I followed the above steps with the Nov security update and alas the 'data corrupt' warnings still pop up.
So i think a wipe is required at some point.
 

Homeboy76

Senior Member
Aug 24, 2012
2,886
1,509
Google Pixel XL
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.
Nevermind, I found the answer I needed. :)
 
Last edited:

V0latyle

Forum Moderator
Staff member
Assume this only works where you have wiped and clean installed android 12 for the first time.
I had updated from Android 11 -> Android beta 12.5 -> Android 12 and had those 'data corrupt' warnings. I have not wiped my phone yet and was using temp root by booting the magisk boot image.

I followed the above steps with the Nov security update and alas the 'data corrupt' warnings still pop up.
So i think a wipe is required at some point.
Yes - if boot verification was not disabled the last time Android System was running, a data wipe is required.
 

V0latyle

Forum Moderator
Staff member
Thanks, and I'm assuming that older versions of Magisk are not compatible with Android 12
Not true, I'm using 23001 on my Pixel 5 with MagiskHide, Riru and Universal SafetyNet Fix 2.1.1 for Safetynet pass.

23010 is the first build that "officially" supports Android 12, though.

Also please refer to @topjohnwu 's State of Magisk. He details some of the changes that are happening and why. This includes the module repo.
 
  • Like
Reactions: State.of.mind

State.of.mind

Senior Member
Sep 2, 2011
436
74
Google Pixel 6 Pro
Not true, I'm using 23001 on my Pixel 5 with MagiskHide, Riru and Universal SafetyNet Fix 2.1.1 for Safetynet pass.

23010 is the first build that "officially" supports Android 12, though.

Also please refer to @topjohnwu 's State of Magisk. He details some of the changes that are happening and why. This includes the module repo.
Thanks this is great info. I'm on Magisk 23012. If I want to downgrade to 23001 is it as simple as flashing the patched boot image or would I have to uninstall Magisk?
 

V0latyle

Forum Moderator
Staff member
Thanks this is great info. I'm on Magisk 23012. If I want to downgrade to 23001 is it as simple as flashing the patched boot image or would I have to uninstall Magisk?
I would recommend restoring the boot image (do this in Magisk) then a complete uninstall (also do this in Magisk); only then should you install 23001. It's not as simple as the boot image and the app.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    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