[Flashable zip] Magisk IMG Resizer

Search This thread

veez21

Senior Member
Feb 22, 2016
2,172
2,766
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:

ahrion

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

loserskater

Inactive Recognized Developer
Jun 6, 2008
2,160
4,434
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,766
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
 

ShapeShifter499

Senior Member
Sep 13, 2009
474
160
This zip no longer seems to work with magisk 13.1. It completes but when I reboot the Magisk image file is still the same size.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    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
    3
    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
    2
    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.
    1
    Z5 Premium, Magisk 11.6 (newest v12 doesn't work), works! Successfully resized to 256 MB :)
    1
    Doesn't magisk automatically resize the partition with the magisk template zips?

    It does. But this probably has something to do with his systemizer module and not being able to systemize large apps because there's not enough space in /magisk.