Resizing partitions (for Android)

This was shamelessly snatched from
originally posted by user:


@f0mey : This was done as preservation and out of respect for your work. If you disagree with my posting, please let me know and I will remove it immediately.

posting it here because it's shown as the following on xda-developers:


This is a lost art and absolutely crucial information if you're manually partitioning an eMMC instead of using Hekate.

Don't get me wrong, Hekate is absolutely fantastic for the vast majority,
but if you are like me and want to do it manually, you have to go sifting through code to find the partition sizes and there are a lot of them!
Don't believe me? Check it out here!

At any rate, this information helped me immensely while carving up my 256G eMMC.
The techniques are pertinent for SDCard partitioning as well.

You will want to reference the #Switchroot wiki for partition sizing:

EMMC Installation guide​

Pre requisite​

Backup the emmc with boot0/1 and rawnand.bin
Have a PC running linux for EMMC perparation.


EMMC preparation (for Android and Linux alongside HOS on a larger eMMC)​

  1. If you have a new emmc, install it and write back boot0/1 and the rawnand bin in hekate.
  2. Under Linux mount the emmc with hekate. Deactivate write protect!
  3. Check where linux has mounted the emmc (sdb, sdc ...)
  4. Open gparted and confirm the resize from the emmc gpt table.
  5. Close gparted.
  6. Open Terminal and sudo gdisk /dev/sdx (where x is your the device letter)
  7. Press x=>s=>20=>v=>w=>y to enlarge the gpt table to 20 entries. (If you also want to do linux on the emmc you have to enter 24.)
  8. Open gparted again.
  9. HOS has 11 partitions, Android need 9 partitions we have to create them.
  10. Add the 9 partitions and set the file system as deleted.

Linux KernelLNX32MiB
Recovery (TWRP)SOS64MiB
Device Tree ReferenceDTB1MiB
CacheCAC700 MiB

  1. If you want to add Linux, add a partition with the label of your choice (e.g.: SWR-UBU for Ubuntu Bionic) and 3 dummy partitions with 1mb unformated. In order to have 24 partitions. gdisk cannot create 21 partitions because the sector is filled automatically (multiple of 4) if there are only 21 partitions on the emmc and not 24 Horizon does not start. The bootloader checks that and Horizon brings up a pink screen.

Flashing the EMMC​

  1. Using dd in terminal flash the following (replacing hekate's Flash Android step)


  1. For linux merge the install image with cat l4t.0* > ubuntu.img and dd it to SWR-UBU (replacing hekate's Flash Linux step)
  2. Add the release files (bootfiles, ini, lineage zip, any extra zips)
  3. Boot hekate go to advanced boot entries click on android while you press vol -
  4. In twrp starts flash the lineage zip and any extra zips.

WARNING: When setting up android, under no circumstances use the sd card as a memory extension, otherwise it will be formatted.

Without further ado, here's f0mey!


This seems to be a popular question on the release thread, so I thought I would share the method I used to resize the partitions included in the stock switchroot android image.

You can do this a number of ways, I'm lazy tho.. so I went the fastest route I could think of.

All of the following steps were done on a linux virtual machine running the gparted live ISO.. this is not a tutorial how to setup a virtual machine or linux, I'm going to assume you're competent enough to do that as all the steps will require one or the other!

What tools are we going to be using?
  • gparted (GUI interface)
  • gdisk (terminal)

The only steps taken prior to what I'm going to share here is that I flashed the 16gb image to my microsd.

So what is the end goal?
  • Expand the general storage (fat32) partition.
  • Expand the android user data partition.
  • Allocate a partition for emummc (optional).
  • Repair the MBR which we destroy by resizing the partitions.

First thing I did was capture some data of the default partition layout for reference:


Great now that we have that, lets get stuck into it.

  1. Fire up gparted and you'll be presented with the following popup:

    We want to hit the "Fix" button.. this will allow us to utilise all the remaining space on the microsd card.
    As soon as we do this tho, there is no turning back.. you'll need to complete the tutorial.

  2. What we're looking at here is the default layout, note the unallocated space highlighted below:

  3. The first thing we're going to do is expand the android user data partition (sdd7 in the screenshot above).. Right click "userdata" -> "Resize/move".

    I decided to go with 32GB which should be plenty, how large you want to make this partition is entirely up to you.

  4. The next thing we're going to do is move the partition down the stack, we do this by entering "0" into the "free space following" field.

    You'll notice the white box surrounded by the dark purple border has moved position to the far right to reflect your changes.. hit the "resize/move" button and confirm the warning window.

  5. You can now see the "userdata" partition has moved down the stack, will be resized to 32GB and our unallocated space has moved up.

  6. We're now going to repeat this process for the remaining android partitions (without resizing tho).. starting from the "dtb" partition and working our way up to "vendor".
    1. Right click partition -> "Resize/move".
    2. Modify "free space following" to "0".
    3. Hit the "Resize/move" button.
    4. Confirm the warning.
  7. You get the idea.. repeat this process until you reach the "hos_data" partition.

  8. Eventually you'll be left with something like this, note the unallocated space is now directly under our "hos_data" partition.

  9. It's time to expand our fat32 partition, you can drag the black arrow on the right hand side all the way to the end to set the maximum size.

  10. [EMUMMC USERS ONLY] If you intend on using emummc we can allocate some space for the partition by entering "29856" in the "free space following field", this will automatically reduce the partition size to accommodate the required free space.. this step is completely optional.

  11. [EMUMMC USERS ONLY] We need to create a new partition (right click "unallocated" -> "new").. the only option we're going to change here is the "file system" field to "unformatted".

  12. Now is the time to verify all our settings are correct before finally hitting the apply button.. confirm the warning and let it do its thing.

  13. Before closing gparted, we want to take note of the drive identifier located on the top right of the screen.. mine is "/dev/sdd", we're going to be using the next steps.

  1. All the remaining steps will be executed using gdisk in a terminal window.. first of which will be the following command:

    sudo gdisk /dev/sdd
    Replace "/dev/sdd" with your drive identifier.

  2. Input "r" as a command, this will enter us into the "recovery/transformation" submenu.

  3. You can output the MBR & partition table by inputting "o" & "p" as commands, since we used gparted the MBR has been modified.. we need to revert this back to ensure everything plays nice.

  4. Input "h" as a command, this will create a new hybrid MBR to replace the one we destroyed with gparted. If you intend on using emummc we need to add both the hos_data partition (#1) & the emummc partition (#8)..
    1. You would do this by entering:

      1 8
      Otherwise if you're not planning to use emummc, we just add the hos_data partition (#1):

    2. Place EFI GPT parition first in MBR?

    3. Creating entry for GPT partition #1 (MBR partition #1)
      Enter an MBR hex code:

    4. Set bootable flag?

    5. [EMUMMC USERS ONLY] Creating entry for GPT partition #8 (MBR partition #2)
      Enter an MBR hex code:

    6. [EMUMMC USERS ONLY] Set bootable flag?

    7. Unused partition space found. Use one to protect more partitions?

  5. EkIPSaT.png

  6. Great, now lets output the MBR & partition table by inputting the "o" & "p" commands once again to confirm our changes.

    Looking good! :good:

  7. The last thing to do is write our changes, we do this by entering the "w" command.
    1. Do you want to proceed?


That's it folks, we're done! I know this was a little lengthy... hopefully this helps some of you out!

If you're interested in knowing more in-depth info about hybrid MBR's I came across the following website that contains invaluable information: HERE.
Post automatically merged:

@evil_santa is everywhere…


Jan 3, 2021
Please use This script and This Android image.
The Android image is ready to use don't boot into Twrp. All additional files are included.
Last edited by binkinator,
  • Like
Reactions: evil_santa


Hoist the Colours!
Feb 9, 2017
United Kingdom
Apologies for the Necrobump...

I'm looking to resize my Android partition without causing catastrophe to my existing partitions (namely emuMMC). Your guide states this method is outdated, but where is the updated guide?

Is this even possible?

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: @light27, it's actually tommorrow but thx