[Flashable zip] Magisk IMG Resizer

veez21

Senior Member
Feb 22, 2016
2,172
2,704
183
Guess Where
Magisk IMG Resizer​

By default, magisk.img is 64M in size, so the space in /magisk is approximately 64M too (thanks captain obvious ?). If you flash a Magisk Module whose size is bigger than the current free space in /magisk, the update-binary automatically resizes magisk.img for the module to fit in /magisk. This is flashable zip (atm...) does the same thing, kinda ?. It resizes magisk.img, which will also change the space available in /magisk so you can add more stuff into it.

This can be useful to some modules that occupies space if it's function is used (like @stangri's App Systemizer and my Terminal App Systemizer).

HOW TO USE:
  1. You can add your custom size in /data/.imgsize or /cache/.imgsize in MB. You can create and edit the file or do this command in TWRP's Terminal or ADB Shell.
    Code:
    echo '87' > /data/.imgsize
  2. Flash Magisk IMG Resizer zip

* To the guys who've read the update-binary, shut up! (jk ?). I haven't touch anything that much and only made patches in the magisk module template's update-binary. I barely have time to do this thing this time of the year... so shut up! (just kidding.... ??)
** Resizing will not be the same as the size you gave. Example, if you enter 87 in /data/.imgsize, the update-binary will calculate the size to be more than what you gave, in this case it'll resize it to 128M so more other stuff can snuck into the extra free space.
** The first thing you need to do after flashing/resizing is to occupy some space in /magisk. But don't make it full! Just add what you want to add so that magic_mask.sh doesn't do anything to magisk.img's current size.

Download
 
Last edited:

veez21

Senior Member
Feb 22, 2016
2,172
2,704
183
Guess Where
Z5 Premium, Magisk 11.6 (newest v12 doesn't work), works! Successfully resized to 256 MB :)
I have v12 and it works. Strange that it doesn't work for you. The first thing you have to do after flashing is to occupy the space, but don't make it full (I should add this to the OP ?).
 

the_brad

Senior Member
Feb 3, 2008
334
103
63
No, i can't use v12 at all (depends on something in the kernel, I use). Stock kernel works! Resizing should work on v12, too (if I used it)

Gesendet von meinem E6853 mit Tapatalk
 

ahrion

Retired Forum Moderator / Recognized Developer
Jul 19, 2013
3,102
5,107
0
Doesn't magisk automatically resize the partition with the magisk template zips?
 

loserskater

Inactive Recognized Developer
Jun 6, 2008
2,160
4,433
0
Palmdale, CA
Doesn't magisk automatically resize the partition with the magisk template zips?
To clarify a little bit, when installing a standard module zip the script gets the size of that zip and adds it to the magisk image size. This module basically tells magisk to not use the zip size but rather whatever size is in /data/.imgsize. So most zips work perfectly fine and you won't need to adjust the image size. There are a few small use cases where you need to adjust the image size after installing a zip. Like adding apps to be systemized that weren't included in the zip.
 
  • Like
Reactions: veez21 and MoHuToP

veez21

Senior Member
Feb 22, 2016
2,172
2,704
183
Guess Where
It seems that this script in increases the size of magisk.img by the value in /data/.imgsize

I stoopidly assumed it would change the size of magisk.img to be the actual value in megabytes!

Do you have a version of the script that will allow me to shrink the file to an absolute size?

Thanks

Sent from my SM-N910F using XDA Labs
I haven't updated this, yet. Anyways, you can go to twrp, mount /data and then to the terminal and do this command
Code:
resize2fs /data/magisk.img 32M
You can change 32 to any size you want in mb, do not remove M