Jump to content
Craig

Magisk Install - Step by Step [ROOT]

Recommended Posts

I found a script to extract OTA updates, and the most recent OTA seems to have modified boot.img. 

So we will want to use an updated boot.img with root. 

  • Like 2

Share this post


Link to post
Share on other sites

I imagine you found the same script as me.  The reason I think mine not have worked right right as I didn't use the procedure for incremental ota, which I think must be necessary.

For anyone else playing with this, here is direct link to OTA file from the source: http://hwfotadown.mayitek.com/ota/root_data02_2/idealte/idealte8998_9.0/QX1000/en-US/other/QX1000_EEA_20200106110245_20200106-1105/2020010614044563241.zip

And here is xda thread with tool to extract:  https://forum.xda-developers.com/android/development/extract-files-ota-payload-bin-diff-t3959161

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Yep, that's the one I found. I don't claim to understand much of what it's doing. I did use the differential mode, and for the files it is *modifying* it looks like it's doing something sane, but it also needed other files that didn't exist (e.g. hyp.img). I just "touch"ed them and then the script proceeded. It also needed all files named ".img" instead of the other extensions in our stock rom.

I ran it against all of the OTAs, and each one produced a modified boot.img.

I'm also not sure if the OTAs are each supposed to work against the stock rom, or if they should be applied one after the other...

  • Like 1

Share this post


Link to post
Share on other sites

I would think they have to applied one after the other, hence incremental....

  • Like 1

Share this post


Link to post
Share on other sites

Right. payload_dumper.py seems to have next to zero validation, so we really need additional validation before we try these in a phone.

Share this post


Link to post
Share on other sites

Have you tried to patch it with magisk?  If that doesn't work (like in my case) that's a sign it's not valid boot.img

Share this post


Link to post
Share on other sites

I tried using the tool from this post on the boot.img files from the various phases: https://unix.stackexchange.com/questions/64628/how-to-extract-boot-img

(links to a google tool)

ONLY the boot.img from the stock rom looks correct. The others... kinda extract, but the file types are all wrong and the command output only looks right for the stock rom. The others look like garbage.

So I'm thinking that payload_dumper.py is just broken/old/or for some other specific devices. 😞

Share this post


Link to post
Share on other sites

Or, another possibility, the OTA I'm starting with isn't the first? (and hence I'm not applying them in the right order)

I have three of them: 2019112919502366681, 2019121017300185739, and 2020010614044563241. Were there any others?

 

Share this post


Link to post
Share on other sites

I try, and on uninstall magisk says " backup is missing". Device is rooted by flashing patched boot.img with adb, following guide from first post in this topic.

 

UPD: had restored stock firmware to 20191028 from here - after all updates can't root.

UPD2: had restored stock 20191028 again, trying to start OTA with Magisk rooted from this version.

For doing "Restore images" you need patch stock boot.img by Magisk on your own phone, and not load already patched magisk_patched.img from anywhere, how i do by guide form first post.

Sucessfully install first OTA update with Magisk already rooted (by the guide https://www.thecustomdroid.com/install-ota-update-rooted-android-device-guide/#How_to_Install_OTA_Updates_on_Rooted_Android_Devices, reboot with rooted update device). Second update in progress - yes, this guide worked for me too! Thanks, McDinner!

 

UPD3: had install all OTA updates, all works.

Edited by Ilrilan
  • Thanks 2

Share this post


Link to post
Share on other sites
4 hours ago, Ilrilan said:

I try, and on uninstall magisk says " backup is missing". Device is rooted by flashing patched boot.img with adb, following guide from first post in this topic.

 

UPD: had restored stock firmware to 20191028 from here (

UPD2: had restored stock 20191028 again, trying to start OTA with Magisk rooted from this version.

For doing "Restore images" you need patch stock boot.img by Magisk on your own phone, and not load already patched magisk_patched.img from anywhere, how i do by guide form first post.

Sucessfully install first OTA update with Magisk already rooted (by the guide https://www.thecustomdroid.com/install-ota-update-rooted-android-device-guide/#How_to_Install_OTA_Updates_on_Rooted_Android_Devices, reboot with rooted update device). Second update in progress - yes, this guide worked for me too! Thanks, McDinner!

Oh, I did try it from scratch. But glad it worked for you.

1 hour ago, Ilrilan said:

If someone need - i upload to google drive stock versions of  boot.img, backuped by Magisk from all versions i had:

 - 20191028

- 20191111

- 20191129

- 20191210

- 20200106

 

https://drive.google.com/drive/folders/1EHlG9ZWNMimAN55yKDvMUUE_ow-FDznG?usp=sharing

Thank you 🙂

Share this post


Link to post
Share on other sites
9 hours ago, Ilrilan said:

If someone need - i upload to google drive stock versions of  boot.img, backuped by Magisk from all versions i had:

OMG this is awesome, thank you!

To be clear, these are the *non*-rooted images, right? So we'll need to patch these in Magisk Manager to get rooted images?

That is perfect, since we'll probably need to roll back to the correct version of these that match our patch level for the OTAs to apply correctly.

Share this post


Link to post
Share on other sites

Yes. All this files are clear stock images, not patched by Magisk. You need patch they in your own phone, then Magisk correctly create backups, and can after that restore stock boot.img for applying new OTA update - if you get magisk_patched.img from anywhere other source and flash by fastboot, "Restore images"  button will not work.

Edited by Ilrilan
  • Thanks 4

Share this post


Link to post
Share on other sites

Sorry, I'm a bit slow on some of these things.  If I want to proceed now to root my phone with (currently) the 06JAN2020 OTA, I would install Magisk Manager, reboot, go into Magisk Manager and install Magisk?  And what do I ask it to do when it installs to created the modified boot image?  Will it use the boot image  already have and create a backup?

The instructions for updating with new OTA and retaining root seem clear, but having previously used the instructions in the OP, I'm not clear on how to do the original rooting anymore.  Most instructions I find out on the webs seem to assume you are using TWRP.

Can some kind soul post instructions, like the OP, for us risk seeking dummies.  😉

Edited by Hook
  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

That's a good idea Hook.  Since I can't edit the first post myself, I'll start drafting it here then get Eske's help updating the first post.

Step three should be updated to not include my patched image.  Sounds like user will have to obtain the boot.img corresponding to their currently installed version, transfer it to phone, and patch it there, for magisk to be able to take OTAs, amiright?

I wonder if alternatively there's a simpler way to transfer the unmodified boot.img's to magisk after the fact, for those that already rooted with my file?

Additionally, maybe someone who has successfully done it  can cut/paste/edit from the linked article to make a simple step-by-step to take OTA when rooted?  I'd do it myself but currently running sfos and would want to have actually done the procedure myself to be sure to correctly document it... 

  • Like 2
  • Thanks 2

Share this post


Link to post
Share on other sites

For those getting their devices and wanting to root now, the recommended procedure has changed!    

This method should allow you to take future OTA updates keeping root using the A/B method linked earlier in thread.  Steps have been reordered and updated since first post.


1. Install Android Platform Tools on PC (adb & fastboot)

Ubuntu (and presumably debian): sudo apt install adb

Windows: https://dl.google.com/android/repository/platform-tools-latest-windows.zip

Windows/Mac/Linux:  https://developer.android.com/studio/releases/platform-tools

 2. Connect Phone to PC with USB Cable

After connecting, you'll see a notification on phone about usb charging mode.  Tap that and change it to file transfer, and give permission to the computer if prompted.

3. [New] Enable Developer Options, USB Debugging & Unlock Bootloader

Settings/About Phone - Click on Build number seven times to Enable Developer Mode

Settings/Developer Settings: Enable OEM unlock and USB debugging

NOTE: Unlocking bootloader will factory reset your device!  Backup anything you need first!  Proceed only if you understand this!

From PC command prompt, with adb & fastboot  in your path or present working directory, execute the following commands:

adb devices  //this command should return your internal serial number as device; if not, you cannot proceed

adb reboot bootloader  //then wait while your phone reboots to bootloader

fastboot flashing unlock

// Use vol +/- buttons on phone to select "Unlock Booloader", then press power button.

fastboot reboot

4. Install Magisk Manager App on Phone

Download from: https://magiskmanager.com/downloading-magisk-manager or github.

After download, install the apk, which will require you to allow the install from "unknown source".

5. [Updated]: Patch Stock Boot Image using Magisk Manager

Obtain the original boot.img corresponding to your current software version.  2020-01-06 and earlier can be found by extracting the archives found here (thanks to Ilirilan): https://drive.google.com/drive/folders/1EHlG9ZWNMimAN55yKDvMUUE_ow-FDznG?usp=sharing

Move the clean copy of boot.img to your phone (I used download folder).  Using the Magisk Manager app on your phone, select 'Install Magisk' and choose the boot.img you just transferred.  Finally, transfer the newly created magisk patched img to your PC.   

6. Flash Modified Boot image

From PC command prompt, with adb & fastboot  in your path or present working directory, execute the following four commands (example follows below):

adb devices  //this command should return your internal serial number as device; if not, you cannot proceed

adb reboot bootloader  //then wait while your phone reboots to bootloader

fastboot flash boot magisk_patched.img  //of course specify full path to magisk_patched.img if its not in pwd

fastboot reboot  //all done

example under ubuntu:

$ adb devices
List of devices attached
de3778ff    device

$ adb reboot bootloader
$ fastboot flash boot magisk_patched.img
target reported max download size of 536870912 bytes
sending 'boot_b' (22080 KB)...
OKAY [  0.870s]
writing 'boot_b'...
OKAY [  0.193s]
finished. total time: 1.063s
$ fastboot reboot
rebooting...
	finished. total time: 0.151s

7. Profit

What you do now is up to you.  Any app (including su from a shell) that requests root privileges will generate a popup asking you to permit/deny root.   I recommend using Magisk Manager to install the systemless hosts module (to support Adaway) and if you use Youtube, use Magisk Manger to to download Youtube Vanced (which requires uninstalling all Youtube updates and disabling further auto-updates to it in Google Play).  Then of course install Adaway from F-droid. 

Credit to LinkAndZelda for first applying and describing this method for Pro¹.

If anyone follows this step by step, let me know if I missed anything or should add more detail to anything not clear for newbies.

 

edit: thanks Eske, I see you already updated OP.  I've updated the new one above, I had just barely started drafting it and hoped to improve it a bit before I asked you to update OP... but you're too fast; will let you know when done.  Probably whenever it stops letting me edit as I often think of changes.

 

Edited by Craig
  • Thanks 10

Share this post


Link to post
Share on other sites
30 minutes ago, Craig said:

For those getting their devices and wanting to root now, the recommended procedure has changed!    

Tried to update,

  • Thanks 1

Share this post


Link to post
Share on other sites
On 1/24/2020 at 5:38 PM, Craig said:

Settings/Developer Settings: Enable OEM unlock and USB debugging

NOTE: Unlocking bootloader will factory reset your device!  Backup anything you need first!  Proceed only if you understand this!

 

I just spent most of the last 2 days setting my phone up, it's a bit of a blow to read that unlockling the bootloader will factory reset the phone!

(especially as I almost did unlock the bootloader about 10 minutes after getting the phone)

 

Is there any way round this, or any way to easily back up and restore everything I've installed and configured so far?

  • Like 1

Share this post


Link to post
Share on other sites
58 minutes ago, J_P said:

Is there any way round this, or any way to easily back up and restore everything I've installed and configured so far?

Unfortunately there is no way around. 😞
You could try to backup with adb backup after you enabled adb over usb. It may work for many apps but not all, because the apps can decide if their data gets backuped or not.
I fear that's the only option you have without root.

If you plan to re-lock your bootloader, beware that it will reset your device again.

Edited by mcdinner
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Unfortunately this is not working for me.

After flashing the patched boot img and rebooting, Magisk manager still shows Magisk is not installed, and Titanium backup still reports that it can't get root.

I noticed that in the example posted by Craig, fastboot flash boot magisk_patched.img wrote to boot_b by default, whereas for me it's always boot_a, so I explicity flashed boot_b for good measure. I've done this about 5 times now....

I started with the boot.img from GoogleDrive, the patching in Magisk Manager seemted to go fine, and I notice that my patched version is exactly the same size as in the example, so it should be good.

 

Any ideas what could be going wrong?

 

D:\Phone Stuff\ADB>adb devices
List of devices attached
8d139cce        device


D:\Phone Stuff\ADB>adb reboot bootloader

D:\Phone Stuff\ADB>fastboot flash boot magisk_patched.img
Sending 'boot_a' (22080 KB)                        OKAY [  0.490s]
Writing 'boot_a'                                   OKAY [  0.100s]
Finished. Total time: 0.590s

D:\Phone Stuff\ADB>fastboot flash boot_b magisk_patched.img
Sending 'boot_b' (22080 KB)                        OKAY [  0.480s]
Writing 'boot_b'                                   OKAY [  0.680s]
Finished. Total time: 1.170s

D:\Phone Stuff\ADB>fastboot reboot
Rebooting                                          OKAY [  0.000s]
Finished. Total time: 0.010s

D:\Phone Stuff\ADB>

 

  • Sad 1

Share this post


Link to post
Share on other sites
5 hours ago, J_P said:

Unfortunately this is not working for me.

After flashing the patched boot img and rebooting, Magisk manager still shows Magisk is not installed, and Titanium backup still reports that it can't get root.

I noticed that in the example posted by Craig, fastboot flash boot magisk_patched.img wrote to boot_b by default, whereas for me it's always boot_a, so I explicity flashed boot_b for good measure. I've done this about 5 times now....

I started with the boot.img from GoogleDrive, the patching in Magisk Manager seemted to go fine, and I notice that my patched version is exactly the same size as in the example, so it should be good.

 

Any ideas what could be going wrong?

 

D:\Phone Stuff\ADB>adb devices
List of devices attached
8d139cce        device


D:\Phone Stuff\ADB>adb reboot bootloader

D:\Phone Stuff\ADB>fastboot flash boot magisk_patched.img
Sending 'boot_a' (22080 KB)                        OKAY [  0.490s]
Writing 'boot_a'                                   OKAY [  0.100s]
Finished. Total time: 0.590s

D:\Phone Stuff\ADB>fastboot flash boot_b magisk_patched.img
Sending 'boot_b' (22080 KB)                        OKAY [  0.480s]
Writing 'boot_b'                                   OKAY [  0.680s]
Finished. Total time: 1.170s

D:\Phone Stuff\ADB>fastboot reboot
Rebooting                                          OKAY [  0.000s]
Finished. Total time: 0.010s

D:\Phone Stuff\ADB>

 

I would think you would get an error if you didn't do this, but did you unlock the bootloader first?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Terms