Hovatek Forum DEVELOPMENT Android [Development] How to use Magisk Manager & boot.img to root Android
Try our Online TWRP Builder..its free!
Can't login? Please, reset your password.


[Development] How to use Magisk Manager & boot.img to root Android

[Development] How to use Magisk Manager & boot.img to root Android

Pages (28): 1 2 3 4 528 Next
hovatek
hovatek
hovatek
Administrator
49,610
18-12-2017, 12:20 PM
#1



In this tutorial, we are going to show how one can root an Android device by patching the stock boot.img using Magisk Manager. This comes in particularly handy for those on Lollipop and above where one-click-root apks like Kingroot don't work and would therefore require a custom recovery to root.
With this method, you won't be needing a one-click-root apk or custom recovery  (e.g Philz, CWM, TWRP etc) to root your device.

Important Notice
  • For Android 13 and above, you'll be dealing with init_boot.img and init_boot partition instead of boot.img and boot partition. Everything else remains the same
  • For devices running Android 9, 10 & 11, ensure to disable dm_verity by flashing an empty vbmeta before flashing magisk patched boot. Some devices most especially those using Unisoc chipset require that you generate your custom signed vbmeta

Requirements


Steps on how to root an Android device using Magisk Manager and patched boot.img


See the Video tutorial below or at https://youtu.be/BF4_hnKgjFA


Step 1: Patching the stock boot.img


  1. Install MagiskManager apk on your android device
  2. Copy the stock boot.img of your device to your phone's internal storage or SD card
  3. Launch Magisk Manager app
  4. If you're not using the latest version, you'll have to update the app first before proceeding
  5. If you intend to patch recovery.img then manually tick "Recovery Mode" in Advanced Settings
  6. Select Install > Install > Select and Patch a File >
  7. Navigate to the location of the stock boot.img you copied earlier on, then Select it. Note that if you are using a samsung device then you should select the firmware of your device in .tar format instead of boot.img
  8. Magisk Manager should begin downloading the magisk zip file used for patching
  9. Once download is complete, MagiskManager will automatically patch the file and store it under SDcard/Download/magisk_patched.img[.tar]

Step 2: Flashing the patched boot.img


You have a variety of options to flash the patched boot.img depending on your chipset (e.g Mediatek MTK, Spreadtrum SPD, Qualcomm QLM etc ), the resources you have and your skills. Note that some flashing methods might require you to rename the file to boot.img
  1. For those using MTK devices and have the specific scatter file for their device, you can flash the patched boot.img using SP flash tool or Miracle Box
  2. For those using SPD devices and have the PAC file for their device, you can flash the patched boot.img using Research download tool by replacing the stock boot.img with your patched boot.img
  3. For those using Qualcomm devices, you can flash patched boot.img using Miracle box custom flasher; see https://www.hovatek.com/forum/thread-26213.html
  4. For those using Samsung devices and wish to flash patched boot.img.tar using Odin; see https://www.hovatek.com/forum/thread-519.html
  5. Generally speaking, you could also use Fastboot  to flash the patched_boot.img or boot.img (if you've renamed then the command must reflect the file name) as outlined below

How to Flash patched_boot.img using Fastboot


  1. Setup adb and fastboot on your PC using the guide @ https://www.hovatek.com/forum/thread-588.html 
  2. Unlock the phone's Bootloader (if its not unlocked) using https://www.hovatek.com/forum/thread-19578.html
  3. Re-enable USB debugging on the phone using https://www.hovatek.com/forum/thread-10109.html
  4. Connect the phone to the PC via USB cord
  5. Boot into fastboot mode using the guide @ https://www.hovatek.com/forum/thread-19503.html
  6. Flash the patched_boot and reboot by typing in the commands below into adb CMD prompt window and hitting Enter after each line
Code:

fastboot devices
fastboot flash boot patched_boot.img
fastboot reboot

Your command history should look something like

[Image: How-to-flash-Magisk-manager-patched-boot...stboot.jpg]

Verify root using Root Checker

Credits goes to topjohnwu of XDA for Magisk

Important Notice
  • For models which have fastbootD, you need to first reboot into fastbootD then flash the magisk boot. To reboot from fastboot to fastbootD, run

    Code:

    fastboot reboot fastboot

  • If you encounter "a 'su' binary not from magisk has been detected" then run the following commands

    Code:

    adb remount
    adb shell
    mv /system/xbin/su /system/xbin/subk

  • For models without ramdisk in boot.img but have a recovery partition, simply patch the recovery.img in magisk manager (ensure to tick the recovery box) > flash the recovery image to the recovery partition > immediately boot into recovery mode (do not reboot the device normally before booting to recovery) > the device will boot up with root access > rename recovery-from-boot.p to recovery-from-boot.bak > do a factory reset. This should maintain root even if you reboot
Video Transcript
Quote:In this video tutorial, I'll be explaining how to root an Android device using magisk manager and a boot.img. Now you need to get the boot.img for your phone either from the firmware which you downloaded online or from a rom which you backed up or extracted from your phone. You can backup your phone using a variety of tools depending on your chipset but anyway you either get the boot.img from the firmware or extracted from your phone.

Now, once you have your boot.img, you need to copy to your phone storage because you're going to be working on that on the device. Now I have my magisk installed and I'm also going to check my root status to show that the phone is not rooted okay? so I'm starting from the very beginning, from scratch. So you can see I do not have root access on this phone so I will be rooting the phone using magisk and my boot.img. Now, its very important you get a boot.img for your variant. You know, when it comes to Android, there are number of variants so you just can't use any boot.img on your device. You need to get one that is for your variant or close to your build number even for your build number okay?

So once you have that in place, you're going to launch magisk manager. On this screen, you just select NO THANKS. Now, if you're using a Samsung device you might want to change your settings. You come under Patch Boot Output Format. Now, you'll want to change yours to .img.tar that is for Samsung users who want to flash their patched boot.img using Odin okay? but I want to use in .img format so I'll just leave it as it is ok? Samsung users just take note of that alright? So now at this screen, you're going to tap Install then you tap Install again.

Now you're going to select Patch Boot Image File. Now, I'm going to locate my stock boot.img, I saved that to the Hovatek folder on my internal storage. Okay, I have it here. I'm going to select it now so I'm going to allow. So now you'll notice that magisk is going to download the zip file and then begin patching alright? So I'll just wait a couple of seconds for okay it's almost done, I think I can just slide off so you can see. So now what is happening right now is that magisk is now patching the boot image which I just loaded and then it's going to produce the patched boot.img for me, its going to save it to the phone storage for me alright?

So once that is done, I'll just head over to flashing the patched boot.img to my device okay? packing boot image. You might be wondering why I have adb opened here. Its because I want to flash using fastboot. Alright! so it says patched boot image is placed here so I'm going to actually verify that by launching my file manager. Internal storage. I'm looking for Magisk Manager. As you can see, I have my patched boot.img, its 11.43 MB. So now, I'm going to copy this file to my PC from which I'm going to flash. Now, at this point, you now need to flash your boot.img .There's a lot of ways you can flash your boot image depending on your kind of chipset and what you have. You might decide to flash using a tool, maybe like Odin, SP Flash tool, Research Download tool, Miracle box, depending on what you have at the moment or for most devices, you can flash using fastboot.

Now, I'm going to be demonstrating how to flash using fastboot okay because that's quite general for devices alright? So first off, I need to copy this patched boot image to my device and that would take a couple of seconds so let me just do that quickly. Alright so I've copied the patched boot.img to my adb folder and that is what I have over here as you can see so now I'm going to be flashing this using fastboot. Don't forget, you can flash your boot image using a variety of methods, it depends on your chipset but I'm using fastboot because that's actually quite general alright? So now, before you can use fastboot on your device, you need to have unlocked your bootloader.

We have a guide on how to unlock your bootloader. Just check our forum, search for how to unlock the bootloader of an Android device, we have a guide on that. Follow the guide unlock your bootloader. Don't forget that unlocking your bootloader wipes your data so ensure you have your stuff backed up alright? Now, once your bootloader is unlocked , you're going to boot up the device again and setup your ADB. So I'm going to be testing ADB connection to my phone by typing adb devices .So you can see I have a detection. So now, I'm going to be booting my phone into fastboot which is bootloader so I'm going to type in adb reboot-bootloader .

Now, you're going to see that the screen is going to go off. The Android emulator is closed already since I don't have adb connection to my device anymore. so now you will be able to see my screen because it's no longer an ADB mood so I can't broadcast the screen to you but my phone is in fastboot mode so I'm going to test connection in fastboot by typing fastboot devices . Okay so I have a connection in fastboot. So now I'm going to be flashing the patched. Now, some tools require you to rename your patched boot, that's patched_boot to just boot like when you're flashing with SP flash tool, Research Download tool and some other tools, you need to actually rename your boot but I don't have to rename it in fastboot.

I just have to make sure I type the name correctly. So to flash the boot in fastboot, don't forget you need to have your bootloader unlocked so if your bootloader is not unlocked, make sure you unlock it. Now, just to verify my bootloader status, I will type fastboot getvar unlocked My bootloader is unlocked so now I'm going to flash the boot image by typing fastboot flash boot patched_boot.img which is the file name so whatever you name it, make sure you type that correctly. Alright! so that is done. Now, I'm going to reboot the device to the normal Android screen so fastboot reboot

Alright! so my phone is restarting. I'll just give it a couple of seconds to come up. Once it boots up now. I'm going to be testing root status using the root checker application Alright! booted up and should be coming up any moment Alright! So I'm going to come back to my root checker and check my root status so I'm going to be verifying root. Alright! so I can see I already have a sign of root access. By an app asking for root permission, that means I have root on my device

Alright! so my device is rooted That's how to root an Android device using magisk manager and stock boot.img
This post was last modified: 11-03-2024, 09:08 PM by hovatek.
ColinB
ColinB
ColinB
Enthusiastic Member
14
18-12-2017, 10:16 PM
#2
This is absolutely AMAZING

Thanks for letting us know.
kaew158
kaew158
kaew158
Techie Member
54
21-12-2017, 05:48 AM
#3
Have any software to flash patched boot.img for Qualcomm chipset ?
This post was last modified: 21-12-2017, 06:45 AM by kaew158.
hovatek
hovatek
hovatek
Administrator
49,610
21-12-2017, 01:04 PM
#4
(21-12-2017, 05:48 AM)kaew158 Have any software to flash patched boot.img for Qualcomm chipset ?

Odin, Fastboot or any tool specific for flashing your type of Qualcomm.
The guide mentioned that

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
Malisa
Malisa
Malisa
Newbie
2
01-01-2018, 07:23 PM
#5



Hello, there,
i have used  kingroot to root my android phone, and its working great since last 1 month.
In case you don't know how to use kingroot to root your device follow the below steps.
**Steps To Root Android Using KingoRoot Android App**
First go to settings and check for “Unknown Sources” in Security options
Download KingoRoot app from here
Install the KingoRoot app and open it
Click on Root option in the app and wait for few seconds, it will root your device without computer withing few seconds.
Once it processed, just restart the device.
Good luck :grinning:
noelstelrooy`
noelstelrooy`
noelstelrooy`
Newbie
3
06-01-2018, 02:56 AM
#6
Hi Hovatec
I tried your method to root my Vivo Y21

When i installed Magisk.apk in my vivo it says nothing but "Magisk Not Installed" so i can not patch my boot.img

So i installed magisk.apk in my other device Redmi 4X and it run just like in your video, i copy my Vivo boot.img to my Redmi 4X and patched it through Magisk

I flashed the boot.img to my vivo and it bootloop
What when wrong? Do i must patched my boot.img in my vivo??

Thanks
hovatek
hovatek
hovatek
Administrator
49,610
06-01-2018, 05:25 PM
#7
(06-01-2018, 02:56 AM)noelstelrooy` Hi Hovatec
I tried your method to root my Vivo Y21

When i installed Magisk.apk in my vivo it says nothing  but "Magisk Not Installed" so i can not patch my boot.img

So i installed magisk.apk in my other device Redmi 4X and it run just like in your video, i copy my Vivo boot.img to my Redmi 4X and patched it through Magisk

I flashed the boot.img to my vivo and it bootloop
What when wrong? Do i must patched my boot.img in my vivo??

Thanks

no its not compulsory to patch boot using the same device.
where did you get the boot.img you used from?
and have you flashed the device back to stock; ie can the device now boot into homescreen?
Waleboluwatife
Waleboluwatife
Waleboluwatife
Enthusiastic Member
8
07-01-2018, 12:18 AM
#8
Hello  Hovatek,
I tried to flash my patched_boot.img using the fastboot but i get an error telling me unable to load. What do i do? I'm using tecno W2
noelstelrooy`
noelstelrooy`
noelstelrooy`
Newbie
3
08-01-2018, 03:37 AM
#9
(06-01-2018, 05:25 PM)X3non
(06-01-2018, 02:56 AM)noelstelrooy` Hi Hovatec
I tried your method to root my Vivo Y21

When i installed Magisk.apk in my vivo it says nothing  but "Magisk Not Installed" so i can not patch my boot.img

So i installed magisk.apk in my other device Redmi 4X and it run just like in your video, i copy my Vivo boot.img to my Redmi 4X and patched it through Magisk

I flashed the boot.img to my vivo and it bootloop
What when wrong? Do i must patched my boot.img in my vivo??

Thanks

no its not compulsory to patch boot using the same device.
where did you get the boot.img you used from?
and have you flashed the device back to stock; ie can the device now boot into homescreen?

I got the boot.img from my Vivo Y21 stock firmware, which i flased into my Device
Actually no one rooted their Vivo Y21 or atleast not posted it yet anywhere
Can you help me is there other stratefy to root Vivo Y21
Thanks
hovatek
hovatek
hovatek
Administrator
49,610
08-01-2018, 01:25 PM
#10
(08-01-2018, 03:37 AM)noelstelrooy` I got the boot.img from my Vivo Y21 stock firmware, which i flased into my Device
Actually no one rooted their Vivo Y21 or atleast not posted it yet anywhere
Can you help me is there other stratefy to root Vivo Y21
Thanks

Did you patch the stock boot.img as instructed by the guide?

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
Pages (28): 1 2 3 4 528 Next
Users browsing this thread:
 2 Guest(s)
Users browsing this thread:
 2 Guest(s)
YtWhTl
live chat
whatsapp telegram