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

Does patched boot.img Magisk work on MIUI V12.5.1.0? (Edit: Yes it does!)

Search This thread

droident

Senior Member
Dec 23, 2010
495
200
Redmi K20 Pro
Just curious if anyone has any insight as to whether I can use the Magisk app to patch the newest boot.img (12.5.1.0 global / Android 11 / mi9t pro) and whether it will go smoothly if I install it via fastboot flash boot patchedmagiskhere.img?

I just updated the device using the clean_all mode on MiFlash and everything looks to be working fine;
  • No TWRP or custom recovery installed
  • Bootloader in unlocked state
As the update is so new I just wanted to check if anyone had any experience before I go ahead. There's also the old method of flashing magisk as a .zip via TWRP which is now 'depreciated'. As the device says 'Ramdisk NO' it implies Magisk may need to be used in 'recovery mode' (i.e. patched recovery.img and vol+power on every boot) but it worked just fine in MIUI11 so I don't think that's right.

📲📍Update: If you've come here looking to find out how to do this then I added instructions in this post.
 
Last edited:

droident

Senior Member
Dec 23, 2010
495
200
Redmi K20 Pro
Can't find answers so I might try fastboot boot patched_magisk.img later today. In theory this'll let me test a patched boot.img instead of going in blind with fastboot flash boot patched_magisk.img so that the boot.img isn't flashed, just booted. If it works I assume I can probably just select Direct Install in Magisk.
 

shajman

Senior Member
Jul 29, 2012
103
14
Can't find answers so I might try fastboot boot patched_magisk.img later today. In theory this'll let me test a patched boot.img instead of going in blind with fastboot flash boot patched_magisk.img so that the boot.img isn't flashed, just booted. If it works I assume I can probably just select Direct Install in Magisk.

Hey let me know if you find a solution for this.

I upgarded to this version via TWRP last night. Tried flashing Magisk via TWRP and it kept boot looping into TWRP.

Had to re-flash the rom again in order to boot into the system.

I tried patching the stock recovery image but couldn't get the system to boot into Magisk mode. Tried the Volume Up + Power and let go on splash screen combo but it kept going to stock recovery.

Any help would be appreciated. I'll go crazy having to use the phone without root.

Update: I tried what you mentioned. Manually booting patched boot image. No luck. After showing the MIUI logo for a long time it goes back to recovery. I guess it's basically the same as flashing via TWRP.
 
Last edited:

zgfg

Senior Member
Oct 10, 2016
5,875
3,335
Hey let me know if you find a solution for this.

I upgarded to this version via TWRP last night. Tried flashing Magisk via TWRP and it kept boot looping into TWRP.

Had to re-flash the rom again in order to boot into the system.

I tried patching the stock recovery image but couldn't get the system to boot into Magisk mode. Tried the Volume Up + Power and let go on splash screen combo but it kept going to stock recovery.

Any help would be appreciated. I'll go crazy having to use the phone without root.
For Xiaomi, always patch BOOT img, not Recovery.
Do not tick Recovery option and flash to Boot partition.
Guides can be found elswhere

Important that you patch the boot img corresponding to your CURRENTLY using stock firmware (if you upgraded, you have to extract and patch its boot.img, not some older or from different Global vs Chinna or else)
 
Last edited:

shajman

Senior Member
Jul 29, 2012
103
14
For Xiaomi, always patch BOOT img, not Recovery.
Do not tick Recovery option and flash to Boot partition.
Guides can be found elswhere

Important that you patch the boot img corresponding to your CURRENTLY using stock formware (if you upgraded, you have to extract and patch its boot.img, not some older or from different Global vs Chinna or else)

This is what I have always done (patching boot). However it does not seem to be working with v12.5.1.0

I've just tried the Canary build of Magisk as well and no luck. The MIUI splash screen stays on for a while and then it goes to Recovery.

This never happened with any of the previous ROMS (Android 10)

Not sure if I'm doing something wrong.
 

zgfg

Senior Member
Oct 10, 2016
5,875
3,335
This is what I have always done (patching boot). However it does not seem to be working with v12.5.1.0

I've just tried the Canary build of Magisk as well and no luck. The MIUI splash screen stays on for a while and then it goes to Recovery.

This never happened with any of the previous ROMS (Android 10)

Not sure if I'm doing something wrong.
You may have modules installed and enabled, that do no more work with the new firmware

If you didn't wipe/format Data, modules are still in: /data/adb/modules
(updating firmware does not affect there)

Use TWRP, go to that folder and add an empty file named: disable
(exactly as that), to each subfolder (each subfolder corresponds to one module, you may recignize them by folder names)

Then reboot with the patched boot.img

Later, manage your modules (enable, uninstall, update) from Magisk app (once you successfully boot to Magisk)
 

shajman

Senior Member
Jul 29, 2012
103
14
You may have modules installed and enabled, that do no more work with the new firmware

If you didn't wipe/format Data, modules are still in: /data/adb/modules
(updating firmware does not affect there)

Use TWRP, go to that folder and add an empty file named: disable
(exactly as that), to each subfolder (each subfolder corresponds to one module, you may recignize them by folder names)

Then reboot with the patched boot.img

Later, manage your modules (enable, uninstall, update) from Magisk app (once you successfully boot to Magisk)

You Sir are an absolute LIFE SAVER!!!!!!!


Thank you!
 
  • Like
Reactions: zgfg

droident

Senior Member
Dec 23, 2010
495
200
Redmi K20 Pro
I also patched magisk just fine :D. Thanks guys for sharing your experiences; it kinda reassured me it'd probably work - I was thinking booting a patched magisk boot.img might be safer so I did that first and it booted as expected. So I just returned to fastboot and flashed it properly. Installed a few modules (the essentials; ACC, Energized, Busybox), rebooted, we're all good ^_^

Clipboardadb.png


I think it's already been explained above me but for anyone who hasn't figured it out yet:

Find the recovery zip or fastboot files you updated with (if you don't have them still then go here but use the *exact* region and version - if your device isn't raphael then don't use these), open with 7zip/winrar/whatever and copy the boot.img from them to any folder on your phone. Open Magisk Manager, browse for where you copied it to and patch it; recovery mode box unticked. Then look for Magisk_patched_xxx.img (xxx part being whatever Magisk called it) in your /Downloads folder on your phone. Copy it back to your PC, fire up Tiny ADB & Fastboot.

Do a test-run with fastboot boot Magisk_patched_xxx.img first. If it boots up fine and Magisk shows as working, commit the changes by returning to fastboot with adb reboot fastboot and then the command fastboot flash boot Magisk_patched_xxx.img. Then power it up.

If the temporary boot test-run didn't work, obviously don't execute the flash boot command; power-cycling the phone will get it unstuck.

I should probably note I don't have TWRP (using stock recovery) and I don't know how that factors into this. This was done the day after a clean_all fastboot flash; read previous posts if you've used Magisk previously and updated with your data intact.
 
Last edited:
  • Like
Reactions: Rejerf

droident

Senior Member
Dec 23, 2010
495
200
Redmi K20 Pro
I would like to add here to use the boot.img patch method. Flashing magisk as a zip through the recovery will cause a bootloop.
Tested this on my Mi 9T Pro (12.5.1 global) with system encryption enabled.
I was tempted to do the same because it's the conventional way of installing Magisk and it's how it's always been installed.

That and mucking with something called boot.img sounds like a one-way trip to brick-street. I.e. boot.img makes me think bootloader or in other words, bad news. Although from what I've heard it turns out you can completely screw up the boot.img and you should still have access fastboot and recovery modes. But I didn't run into any problems flashing a new boot.img so I didn't find out 😅.
 

zgfg

Senior Member
Oct 10, 2016
5,875
3,335
I was tempted to do the same because it's the conventional way of installing Magisk and it's how it's always been installed.

That and mucking with something called boot.img sounds like a one-way trip to brick-street. I.e. boot.img makes me think bootloader or in other words, bad news. Although from what I've heard it turns out you can completely screw up the boot.img and you should still have access fastboot and recovery modes. But I didn't run into any problems flashing a new boot.img so I didn't find out 😅.
Men, patching the images is nothing new or exotic.
If you ever read Magisk guide from TJW (the aurhor of Magisk) you would well know that the method has been described there for many years (I personally used the method back since 2018 on other phones)

Besides, it has many practical advantages - if anything goes wrong you just flash the original (unpatched) image

Or, when Magisk updates (unfortunately, it does no more and who knows would it ever again, at least from the established channels like Stable or Canary), if there is a problem with the new Magisk - you just flash your previous version of img that was patched with the working version of Magisk and you are back in business

And there is also nothing impractical here - if you have proper TWRP (you do have for this phone) you don't need to flash the patched img from fastboot but simply from TWRP

You can also use TWRP backup boot.emmc.win instead of extracted boot.img - simply give boot.emmc.win to Magisk for patching (you don't need to rename it) and then flash it
 
Last edited:

zgfg

Senior Member
Oct 10, 2016
5,875
3,335
So, guys, did the patched boot image worked for you? for me it did not boot up... :/
Of course it does work. But read carefully above. If you just upgraded without Factory reset, and if you had Magisk before, some modules (that remained installed to /data) may cause you the bootloop

And/or, you have to patch exactly the boot.img corresponding to your current firmware, not some from an older A10, etc
 

zgfg

Senior Member
Oct 10, 2016
5,875
3,335
In such case, how do you remove the magisk modules after the update? Without root, there is no access to modules.
Why don't you read the previous messages in this thread - post #6

Or see:
Yes, it was asked/answered several times but let it be answered again 🤩

Besides adb, there are two other ways of disabling (or even uninstalling) the remained modules

You have to flash your patched boot.img, then

a) Reboott to Android Safe mode, then reboot again to 'normal' mode.
All modules will be disabled but also you will have to re-enable Magisk Hide again

b) Use TWRP (if appropriate for your device), Advanced, File Manager, go to /data/adb/modules and to each folder (foder = module, you can recognize modules by folder names or by reading the textual file module.prop you will find inside) put a file that must be named: disable (exactly as that)

Or simoly read the Magisk Wiki, available from Magisk Github (linked from Magisk app):
 
Last edited:
  • Like
Reactions: HValenti

Vanmanman

Senior Member
Sep 9, 2012
55
3
For Xiaomi, always patch BOOT img, not Recovery.
Do not tick Recovery option and flash to Boot partition.
Guides can be found elswhere

Important that you patch the boot img corresponding to your CURRENTLY using stock firmware (if you upgraded, you have to extract and patch its boot.img, not some older or from different Global vs Chinna or else)
My Ramdisk says "no" should I still patch boot.img?

not sure how to delete. It does work
 
Last edited:

spiou

Senior Member
Jul 20, 2007
113
9
Paris
Please does someone upgraded succefully from 12.0.5.0 to 12.5.1.0 with root and without wiping data ?
If yes, how did you flashed the 12.5 ROM because TWRP recovery does no support MIUI 12.5 A11 encryption, so I guess flashing it from TWRP is not recomanded.
I am quite afraid to be forced to wipe everything and preserve root is mandatory for me so I did not tried to upgrade for now.
Thank you in advance.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    I was tempted to do the same because it's the conventional way of installing Magisk and it's how it's always been installed.

    That and mucking with something called boot.img sounds like a one-way trip to brick-street. I.e. boot.img makes me think bootloader or in other words, bad news. Although from what I've heard it turns out you can completely screw up the boot.img and you should still have access fastboot and recovery modes. But I didn't run into any problems flashing a new boot.img so I didn't find out 😅.
    Men, patching the images is nothing new or exotic.
    If you ever read Magisk guide from TJW (the aurhor of Magisk) you would well know that the method has been described there for many years (I personally used the method back since 2018 on other phones)

    Besides, it has many practical advantages - if anything goes wrong you just flash the original (unpatched) image

    Or, when Magisk updates (unfortunately, it does no more and who knows would it ever again, at least from the established channels like Stable or Canary), if there is a problem with the new Magisk - you just flash your previous version of img that was patched with the working version of Magisk and you are back in business

    And there is also nothing impractical here - if you have proper TWRP (you do have for this phone) you don't need to flash the patched img from fastboot but simply from TWRP

    You can also use TWRP backup boot.emmc.win instead of extracted boot.img - simply give boot.emmc.win to Magisk for patching (you don't need to rename it) and then flash it
    1
    You may have modules installed and enabled, that do no more work with the new firmware

    If you didn't wipe/format Data, modules are still in: /data/adb/modules
    (updating firmware does not affect there)

    Use TWRP, go to that folder and add an empty file named: disable
    (exactly as that), to each subfolder (each subfolder corresponds to one module, you may recignize them by folder names)

    Then reboot with the patched boot.img

    Later, manage your modules (enable, uninstall, update) from Magisk app (once you successfully boot to Magisk)

    You Sir are an absolute LIFE SAVER!!!!!!!


    Thank you!
    1
    I also patched magisk just fine :D. Thanks guys for sharing your experiences; it kinda reassured me it'd probably work - I was thinking booting a patched magisk boot.img might be safer so I did that first and it booted as expected. So I just returned to fastboot and flashed it properly. Installed a few modules (the essentials; ACC, Energized, Busybox), rebooted, we're all good ^_^

    Clipboardadb.png


    I think it's already been explained above me but for anyone who hasn't figured it out yet:

    Find the recovery zip or fastboot files you updated with (if you don't have them still then go here but use the *exact* region and version - if your device isn't raphael then don't use these), open with 7zip/winrar/whatever and copy the boot.img from them to any folder on your phone. Open Magisk Manager, browse for where you copied it to and patch it; recovery mode box unticked. Then look for Magisk_patched_xxx.img (xxx part being whatever Magisk called it) in your /Downloads folder on your phone. Copy it back to your PC, fire up Tiny ADB & Fastboot.

    Do a test-run with fastboot boot Magisk_patched_xxx.img first. If it boots up fine and Magisk shows as working, commit the changes by returning to fastboot with adb reboot fastboot and then the command fastboot flash boot Magisk_patched_xxx.img. Then power it up.

    If the temporary boot test-run didn't work, obviously don't execute the flash boot command; power-cycling the phone will get it unstuck.

    I should probably note I don't have TWRP (using stock recovery) and I don't know how that factors into this. This was done the day after a clean_all fastboot flash; read previous posts if you've used Magisk previously and updated with your data intact.
    1
    I would like to add here to use the boot.img patch method. Flashing magisk as a zip through the recovery will cause a bootloop.
    Tested this on my Mi 9T Pro (12.5.1 global) with system encryption enabled.
    1
    In such case, how do you remove the magisk modules after the update? Without root, there is no access to modules.
    Why don't you read the previous messages in this thread - post #6

    Or see:
    Yes, it was asked/answered several times but let it be answered again 🤩

    Besides adb, there are two other ways of disabling (or even uninstalling) the remained modules

    You have to flash your patched boot.img, then

    a) Reboott to Android Safe mode, then reboot again to 'normal' mode.
    All modules will be disabled but also you will have to re-enable Magisk Hide again

    b) Use TWRP (if appropriate for your device), Advanced, File Manager, go to /data/adb/modules and to each folder (foder = module, you can recognize modules by folder names or by reading the textual file module.prop you will find inside) put a file that must be named: disable (exactly as that)

    Or simoly read the Magisk Wiki, available from Magisk Github (linked from Magisk app):