[Guide] Magisk Modules Disabler for booting into Magisk core-only Mode

Search This thread

Tulsadiver

Recognized Contributor
Jul 11, 2013
9,890
7,439
Google Pixel 7 Pro
Tools needed: boot.img extractor. I recommend the one created by osm0sis from this thread:
https://xdaforums.com/showthread.php?t=2073775

The first method was developed by osm0sis and removes magisk and all modules.
1. Unpack magisk_patched.img
2. Unzip overlay.dremove1.zip and place overlay.d folder in ramdisk folder.
3. Repack IMG
4. fastboot boot image-new.img created by repacking 8mg

This method is an offshoot of osm0sis version but boots core-only mode. Afterwards, remove the .disable-magisk file from the /cache folder for modules to work. Dot files are hidden files so if your root explorer can't see hidden files, run the "Remove disable_magisk" bat file in ADB.

1. Same as above but use the overlay.dcoreonly1.zip


For both methods you must be rooted for it to work. These are not cure all's for all bootloops.

Remove .disable_magisk bat file
https://www.androidfilehost.com/?fid=4349826312261684994

****************************************
Here is a fastboot bootable image to boot you into Magisk core-only mode, in case you bootloop due to flashing a bad module, in fastboot:

You will boot with root but modules disabled. After you remove the offending module you will need to go to /cache folder and delete the .disable_magisk file before your modules will work.
Once in fastboot:

fastboot boot image-newpixel3axl.img

You will boot with root but modules disabled. After you remove the offending module you will need to go to /cache folder and delete the .disable_magisk file before your modules will work.

fastboot boot image-newpixel3axlRemove.img

This one should remove magisk and all modules, then reboot and magisk should reinstall itself (ask to install necessary binaries). This is what osm0sis uses to recover from failed flashes. See this post:
https://xdaforums.com/pixel-3a-xl/themes/magisk-modules-disabler-booting-magisk-t3976625/page2

Images are in this common folder. Pick the appropriate image for your phone.

6-4-20
https://www.androidfilehost.com/?w=files&flid=313291
 

Attachments

  • overlay.dcoreonly1.zip
    953 bytes · Views: 331
  • overlay.dremove1.zip
    761 bytes · Views: 245
  • crosshatch-disabler.zip
    478 bytes · Views: 125
  • remove-disabler.zip
    406 bytes · Views: 113
Last edited:

Skittles9823

Inactive Recognized Contributor
Jan 9, 2015
1,821
2,116
25
Sydney
Google Pixel 3a XL
Ohboy this is helpful. Just out of curiosity, how does one create a magisk patched boot image with core-only mode enabled? I would like to be able to make my own every time a new security patch is out.

Sent from my Google Pixel 3a XL using XDA Labs
 

Tulsadiver

Recognized Contributor
Jul 11, 2013
9,890
7,439
Google Pixel 7 Pro
Ohboy this is helpful. Just out of curiosity, how does one create a magisk patched boot image with core-only mode enabled? I would like to be able to make my own every time a new security patch is out.

Sent from my Google Pixel 3a XL using XDA Labs

I had planned on keeping these updated but here are the instructions.

You have to build your own copy of magisk from GitHub.

Clone magisk
Go to native/jni/core folder and edit the boot stages.cpp file in notepad++ like this:

Approx line 667

If (access(DISABLEFILE, F_ok) ==0)

Change == to !=

Now build magisk as per instructions on GitHub
One you have built it and there were no errors go to native/out/armeb-v7a folder and get a copy of the magiskini64 file.

Unpack your magisk_patched.img
In the ramdisk folder replace the init file with the .magiskini64 file (rename to init)
Repack your magisk_patched.img
The results are a patched IMG that will boot core only mode.
 
Last edited:

Skittles9823

Inactive Recognized Contributor
Jan 9, 2015
1,821
2,116
25
Sydney
Google Pixel 3a XL
I had planned on keeping these updated but here are the instructions.

You have to build your own copy of magisk from GitHub.

Clone magisk
Go to native/jni/core folder and edit the boot stages.cpp file in notepad++ like this:

Approx line 667

If (access(DISABLEFILE, F_ok) ==0)

Change == to !=

Now build magisk as per instructions on GitHub
One you have built it and there were no errors go to native/out/armeb-v7a folder and get a copy of the magiskini64 file.

Unpack your magisk_patched.img
In the ramdisk folder replace the init file with the .magiskini64 file (rename to init)
Repack your magisk_patched.img
The results are a patched IMG that will boot core only mode.
Nice. Seems easy enough, if you ever disappear and stop updating images for some reason I'll give it a go ?

Sent from my Google Pixel 3a XL using XDA Labs
 
  • Like
Reactions: MrWilsonxD

b0li

Senior Member
Dec 2, 2011
102
22
Amazon Fire TV
Samsung Galaxy S7
Hello

I have regular 3a with Android 10 installed, no twrp. I was in bootloop due to some module and was looking for solution to disable modules with only fastboot.

Before I found this thread, I went and reflash to stock.

Now I know.

Thanks for sharing this.
 

gudenau

Senior Member
Apr 19, 2014
98
10
www.gudenau.net
I had planned on keeping these updated but here are the instructions.

You have to build your own copy of magisk from GitHub.

Clone magisk
Go to native/jni/core folder and edit the boot stages.cpp file in notepad++ like this:

Approx line 667

If (access(DISABLEFILE, F_ok) ==0)

Change == to !=

Now build magisk as per instructions on GitHub
One you have built it and there were no errors go to native/out/armeb-v7a folder and get a copy of the magiskini64 file.

Unpack your magisk_patched.img
In the ramdisk folder replace the init file with the .magiskini64 file (rename to init)
Repack your magisk_patched.img
The results are a patched IMG that will boot core only mode.

I tried to do this for a Pixel 4 XL but the resulting boot image errors with "error boot prepare"
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,775
40,457
Halifax
GT-i9250
Google Nexus 4
Ooft.

Wait, can you flash that through adb though?

Hmm.. true, non-working recovery is a definite problem. I'm in that boat right now on my OnePlus 7T, which is how I came across this thread. :eek:

Okay, better idea. Instead of mucking around with recompiling magiskinit for the above, just do it via boot script in overlay.d :D
 

Skittles9823

Inactive Recognized Contributor
Jan 9, 2015
1,821
2,116
25
Sydney
Google Pixel 3a XL
Hmm.. true, non-working recovery is a definite problem. I'm in that boat right now on my OnePlus 7T, which is how I came across this thread. :eek:

Okay, better idea. Instead of mucking around with recompiling magiskinit for the above, just do it via boot script in overlay.d :D
Tbh, a custom boot.img is the only way to recover in some situations. Like if you can't boot into an adb environment or if you've never granted adb she'll root access.

Sent from my Google Pixel 3a XL using XDA Labs
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,775
40,457
Halifax
GT-i9250
Google Nexus 4
How would one do that exactly without being able to use adb shell?

overlay.d is built into the boot.img, so you take your latest magisk_patched.img, patch it with the overlay.d scripts to have the desired effect, then repack and flash via fastboot.

Same as the OP likely did, but no need to build Magisk to get a modified magiskinit, since you can do it all via boot script, like I said.
 
  • Like
Reactions: Skittles9823

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,775
40,457
Halifax
GT-i9250
Google Nexus 4
If anyone wants to experiment with this idea, here's the basic setup I used for my boot.img to fully reset the /data/adb directory for the soft brick issue (related to a magisk.db failure) I was seeing in the last canary.

Unpack the current magisk_patched.img for your device using my Android Image Kitchen (AIK) project, then create:

ramdisk/overlay.d/init.resetmagisk.rc:
Code:
on post-fs-data
    exec u:r:magisk:s0 root root -- /sbin/init.resetmagisk.sh

ramdisk/overlay.d/sbin/init.resetmagisk.sh:
Code:
#!/system/bin/sh
rm -rf /data/adb/* && reboot

So, pretty simple stuff, and I'm sure it could be applied to some sort of Core Only workaround until @topjohnwu decides what he wants to do with all those Core Only boot.img Pull Requests. :cowboy:
 

Tulsadiver

Recognized Contributor
Jul 11, 2013
9,890
7,439
Google Pixel 7 Pro
overlay.d is built into the boot.img, so you take your latest magisk_patched.img, patch it with the overlay.d scripts to have the desired effect, then repack and flash via fastboot.

Same as the OP likely did, but no need to build Magisk to get a modified magiskinit, since you can do it all via boot script, like I said.

Cool. What I did was modify the magisk native/jini/core/bootstages.cpp

Edit: yes sir, your method works great to remove magisk and all modules. The method I had gives you the option to just remove the offending module, though sometimes you have to remove everything anyway. Thank you for your awsome input. If it is okay with you, I'd like to offer both methods in my posts on the pixel forums.
 
Last edited:
  • Like
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,775
40,457
Halifax
GT-i9250
Google Nexus 4
Cool. What I did was modify the magisk native/jini/core/bootstages.cpp

Edit: yes sir, your method works great to remove magisk and all modules. The method I had gives you the option to just remove the offending module, though sometimes you have to remove everything anyway. Thank you for your awsome input. If it is okay with you, I'd like to offer both methods in my posts on the pixel forums.

Sure! You could modify my method to remove all modules by running `magisk --remove-modules` instead of my `rm -rf` command (or just changing the `rm -rf` target), or even try to force Core Only mode by changing the setting directly in magisk.db then rebooting. It's a root shell so pretty much sky's the limit. ;)
 
Last edited:

paplo

Member
Oct 12, 2010
22
2
Løsning
Sure! You could modify my method to remove all modules by running `magisk --remove-modules` instead of my `rm -rf` command (or just changing the `rm -rf` target), or even try to force Core Only mode by changing the setting directly in magisk.db then rebooting. It's a root shell so pretty much sky's the limit. ;)

I have tried multiple methods from this thread but with no success.. Could you maybe help me by altering this boot.img to disable/remove all Magisk modules? Or maybe make it boot core only? It's for my OP 7T. Thanks!
https://mega.nz/#F!rxYDyQia!ziPLPvRsu3kxNBGt694OEQ
 

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
16,775
40,457
Halifax
GT-i9250
Google Nexus 4
I have tried multiple methods from this thread but with no success.. Could you maybe help me by altering this boot.img to disable/remove all Magisk modules? Or maybe make it boot core only? It's for my OP 7T. Thanks!
https://mega.nz/#F!rxYDyQia!ziPLPvRsu3kxNBGt694OEQ

If `adb shell magisk --remove-modules` didn't fix the issue for you then you might be in the same boat I was and need to nuke all of Magisk's files in /data/adb.

Getting off topic for a Pixel thread, but here's the OnePlus 7T (hotdogb) image I made following my own instructions.

It's with an older Canary of Magisk so once you get it booting you should update to the latest Canary immediately.
 

Attachments

  • magisk_reset.img.zip
    12.9 MB · Views: 82

paplo

Member
Oct 12, 2010
22
2
Løsning
If `adb shell magisk --remove-modules` didn't fix the issue for you then you might be in the same boat I was and need to nuke all of Magisk's files in /data/adb.

Getting off topic for a Pixel thread, but here's the OnePlus 7T (hotdogb) image I made following my own instructions.

It's with an older Canary of Magisk so once you get it booting you should update to the latest Canary immediately.

Yeah off topic I know.. Just spotted you had been in the same pickle with the same phone as me. I worked like a charm! Thanks!
 
  • Like
Reactions: osm0sis

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    Tools needed: boot.img extractor. I recommend the one created by osm0sis from this thread:
    https://xdaforums.com/showthread.php?t=2073775

    The first method was developed by osm0sis and removes magisk and all modules.
    1. Unpack magisk_patched.img
    2. Unzip overlay.dremove1.zip and place overlay.d folder in ramdisk folder.
    3. Repack IMG
    4. fastboot boot image-new.img created by repacking 8mg

    This method is an offshoot of osm0sis version but boots core-only mode. Afterwards, remove the .disable-magisk file from the /cache folder for modules to work. Dot files are hidden files so if your root explorer can't see hidden files, run the "Remove disable_magisk" bat file in ADB.

    1. Same as above but use the overlay.dcoreonly1.zip


    For both methods you must be rooted for it to work. These are not cure all's for all bootloops.

    Remove .disable_magisk bat file
    https://www.androidfilehost.com/?fid=4349826312261684994

    ****************************************
    Here is a fastboot bootable image to boot you into Magisk core-only mode, in case you bootloop due to flashing a bad module, in fastboot:

    You will boot with root but modules disabled. After you remove the offending module you will need to go to /cache folder and delete the .disable_magisk file before your modules will work.
    Once in fastboot:

    fastboot boot image-newpixel3axl.img

    You will boot with root but modules disabled. After you remove the offending module you will need to go to /cache folder and delete the .disable_magisk file before your modules will work.

    fastboot boot image-newpixel3axlRemove.img

    This one should remove magisk and all modules, then reboot and magisk should reinstall itself (ask to install necessary binaries). This is what osm0sis uses to recover from failed flashes. See this post:
    https://xdaforums.com/pixel-3a-xl/themes/magisk-modules-disabler-booting-magisk-t3976625/page2

    Images are in this common folder. Pick the appropriate image for your phone.

    6-4-20
    https://www.androidfilehost.com/?w=files&flid=313291
    6
    Ohboy this is helpful. Just out of curiosity, how does one create a magisk patched boot image with core-only mode enabled? I would like to be able to make my own every time a new security patch is out.

    Sent from my Google Pixel 3a XL using XDA Labs

    I had planned on keeping these updated but here are the instructions.

    You have to build your own copy of magisk from GitHub.

    Clone magisk
    Go to native/jni/core folder and edit the boot stages.cpp file in notepad++ like this:

    Approx line 667

    If (access(DISABLEFILE, F_ok) ==0)

    Change == to !=

    Now build magisk as per instructions on GitHub
    One you have built it and there were no errors go to native/out/armeb-v7a folder and get a copy of the magiskini64 file.

    Unpack your magisk_patched.img
    In the ramdisk folder replace the init file with the .magiskini64 file (rename to init)
    Repack your magisk_patched.img
    The results are a patched IMG that will boot core only mode.
    3
    If anyone wants to experiment with this idea, here's the basic setup I used for my boot.img to fully reset the /data/adb directory for the soft brick issue (related to a magisk.db failure) I was seeing in the last canary.

    Unpack the current magisk_patched.img for your device using my Android Image Kitchen (AIK) project, then create:

    ramdisk/overlay.d/init.resetmagisk.rc:
    Code:
    on post-fs-data
        exec u:r:magisk:s0 root root -- /sbin/init.resetmagisk.sh

    ramdisk/overlay.d/sbin/init.resetmagisk.sh:
    Code:
    #!/system/bin/sh
    rm -rf /data/adb/* && reboot

    So, pretty simple stuff, and I'm sure it could be applied to some sort of Core Only workaround until @topjohnwu decides what he wants to do with all those Core Only boot.img Pull Requests. :cowboy:
    3
    Follow my instructions and make your own. I will not be making images for every single person that hijacks this thread. :rolleyes:

    Edit: In fact I'm unsubscribing, good luck to all!
    2
    I would like to thank you as this has saved me multiple times now. Haven't had a phone I could root for many years now and how I've missed it. Not having twrp makes things interesting and this saved the day many many times. Thank you

    Yes, without TWRP, a person needs to be creative at times and, like you said, it can make things interesting. Thus the occasional need for a recovery boot.img :)