Many android user faces low storage problem after installing few apps even if they have huge free space in internal SD card. Some people may recommend to move apps to external SD card but that too doesn’t solve the problem because only apk file can be moved to SD card and not the data. Moving apk with app data requires link2sd app and 2nd partition of SD card and can be done in rooted phones only. Using link2sd can decrease SD card read/write life and it can also affect phone performance. Apps linked to SD card using link2sd won’t work after removing SD card or if SD card stops functioning.
So, what is the permanent solution to low app storage?
The only answer is repartition i.e. defining new partition size for app storage. If your phone has 1 GB for app storage and 1 GB for file storage then we can create new partition by increasing app storage to 1.5 GB and decreasing file storage to 0.5 GB.
I’m going to show you how to do repartition in simple steps. This guide is for MediaTek phones only which have separate partition for app storage and internal SD card. This guide is for ROM partition and has no connection with RAM or external SD card. Repartition doesn’t require rooted phone.
- Cygwin (Download | Instructions)
- SP flash tool (Download)
- HxD Hex Editor (Download)
- Notepad++ (Download)
- Programmer & Scientific Calculator (Built-in with Windows OS)
- MBR, EBR1, EBR2 & Scatter file (Get these from ReadBack backup)
Some phones contain two EBRs i.e. EBR1 and EBR2. Some phones contain only 1 EBR i.e. EBR1. If your phone have two EBRs then there’s no need of MBR but if your phone have only one EBR then you might need to edit MBR. Here I’m using EBR1 and EBR2 of Micromax A106 Unite 2.
Steps for editing EBRs:
Step 1: Copy EBR files to the user directory or current working directory of cygwin
Step 2: Open cygwin terminal and type ls and hit enter key to make sure files are copied to correct location. If files aren’t showing then type pwd to see the current working directory path.
Step 3: Type file EBR1 and hit enter key. Again type file EBR2 and hit enter key. Now copy results to notepad++.
Step 4: Arrange each partition detail in a separate line as shown below
Step 5: Now copy partition_name and partition_size of ANDROID, CACHE and USRDATA from scatter file and paste in notepad++ below EBR1 and EBR2.
Copy values in red as shown in below screenshot:
Paste above values in notepad++ as shown below:
Step 6: Now lets find which partition in EBR1 and EBR2 is ANDROID, CACHE and USRDATA.
In EBR, partition size is given in sectors and in scatter file partition size is given in Bytes (hexadecimal). So we have to convert Bytes to sectors. To do this first convert hexadecimal value to decimal and then divide decimal value by 512.
a) Find ANDROID partition
size in hexadecimal = 0x38400000
size in decimal = 943718400
943718400 / 512 = 1843200 sectors
So, ANDROID is partition 1 in EBR1.
b) CACHE partition
258048 sectors i.e. partition 2 in EBR1.
c) USRDATA partition
1892352 sectors i.e. partition 3 in EBR1.
Step 7: Now we know that partition 1 is system partition, partition 2 is cache partition and partition 3 is app partition. We only want to increase app partition size by decreasing internal SD card. Internal SD partition is the last partition i.e. partition 1 in EBR2. If you don’t have EBR2 then next partition after USRDATA in EBR1 will be the internal SD.
Now write partition name right to all partitions to identify them.
Step 8: Lets understand the sectors in EBR1 and EBR2.
Partition 1 starts from sector 165888 and its total size is 1843200 sectors.
Partition 2 starts from sector 165888 + 1843200 = 2009088 and its total size is 258048 sectors.
Partition 3 starts from sector 2009088 + 258048 = 2267136 and its total size is 1892352 sectors.
Partition 4 is a link to EBR2 and its startsector is 144384.
Partition 1 of EBR2 starts from sector (2267136 + 1892352) – 144384 = 4015104
To increase app storage we need to increase total sectors of partition 3 in EBR1 and startsector of partition 1 in EBR2. We don’t need to edit other sectors if we’re not changing system and cache partitions.
Step 9: Now decide how much app storage you want in GB or MB and convert it to sectors. Here I’m showing how to convert GB to sectors:
1 GB = 1024 MB = 1048576 KB = 1073741824 Bytes = 2097152 sectors.
i.e. 1 GB = ((1 x 1024 x 1024 x 1024) / 512) sectors.
You can use scientific calculator for this. Here I’m giving some values from 1.5 GB to 6 GB.
1.5 GB = 3145728 sectors
2 GB = 4194304 sectors
2.5 GB = 5242880 sectors
3 GB = 6291456 sectors
3.5 GB = 7340032 sectors
4 GB = 8388608 sectors
4.5 GB = 9437184 sectors
5 GB = 10485760 sectors
5.5 GB = 11534336 sectors
6 GB = 12582912 sectors
Step 10: After deciding required app storage, write new partition in notepad++ in a separate line. Here I’m going to increase app partition from default 924 MB to 2.5 GB. To do this I’ve to replace 1892352 sectors with new 5242880 sectors.
Also replace default startsector of internal SD with new startsector using below formula:
(startsector of partition 3 + new size of partition 3) – startsector of partition 4 = new startsector of SD card
i.e. (2267136 +5242880) – 144384 = 7365632
Step 11: Open EBR1 and EBR2 in HxD Hex Editor.
Step 12: The last 4 rows are the partitions so we only need those rows. 4th last row is partition 1, 3rd last row is partition 2, 2nd last row is partition 3 and last row is partition 4.
As we’re changing only app and SD card partition so we only need partition 3 i.e. 2nd last row of EBR1 and partition 1 i.e. 4th last row of EBR2. Copy those two rows in notepad++. The rows to be copied are shown in red.
Step 13: Underline 11th to 14th hex bytes in EBR1 and 7th to 10th hex bytes in EBR2 as shown in below screenshot. We only need to edit these hex numbers. The underlined hex numbers in EBR1 is the total sectors of app partition and underlined hex numbers in EBR2 is the startsector of SD card partition.
Step 14: The bytes in hex editor are in little endian order so we have to reverse them to get the original number.
So, 00 E0 1C 00 = 00 1C E0 00
and, 00 44 3D 00 = 00 3D 44 00
Now, open notepad++ and convert new sectors (which we got from step 10) to hex using programmer calculator.
5242880 sectors (decimal) = 500000 sectors (hex)
7365632 sectors (decimal) = 706400 sectors (hex)
As I said earlier bytes in hex editor is in little endian order so we have to reverse the bytes.
So, 00 50 00 00 = 00 00 50 00
and, 00 70 64 00 = 00 64 70 00
This is the final value. We’ve to replace hex values which we underlined in step 13 with above hex values.
That is, replace 00 E0 1C 00 with 00 00 50 00
and, replace 00 44 3D 00 with 00 64 70 00
Step 15: Open hex editor, write new values in EBR1 and EBR2 and save file.
Here is the new EBR1 and EBR2:
Editing scatter file:
After you have completed EBR editing you have to edit scatter file to flash firmware with new partition. Flashing only EBRs using “Download only” option in sp flash tool may also work in some cases but it is always recommended to flash fresh ROM by replacing old EBRs and scatter file with new EBRs and scatter file. Follow below steps to edit scatter file for new partition size.
Step 16: Open scatter file in notepad++ and find partition_name: USRDATA. If you have changed size for system, cache or any other partition then start from that partition instead of USRDATA.
Step 17: Convert the new partition size from GB or MB to Bytes in hexadecimal. I’m showing how to convert GB to Bytes:
2.5 GB = 2.5 x 1024 x 1024 x 1024 = 2684354560 Bytes (decimal)
2684354560 Bytes (decimal) = A0000000 Bytes (hex)
Now add 0x in front of A0000000 i.e 0xA0000000 and write this value in partition_size of USRDATA (or whatever partition you have edited).
Step 18: Now change linear_start_addr and physical_start_addr of next partitions (except BMTPOOL). I have changed partition_size (total sectors) of USRDATA only so I’m not changing partition_size of other partitions. If you have changed total sectors in EBR/MBR then change partition_size as shown in step 17.
In my scatter file the next partitions after USRDATA are FAT and BMTPOOL. So, I have to change linear and physical start address of FAT only.
linear_start_addr + partition_size = linear_start_addr of next partition
physical_start_addr + partition_size = physical_start_addr of next partition
Step 19: Save your scatter file. Replace old EBR/MBR, scatter file with new EBR/MBR, scatter file and flash ROM through sp flash tool using “Firmware upgrade” option.
Flashing EBRs using sp flash tool:
Please follow this GUIDE to flash firmware with new EBRs and scatter file.
Flashing EBRs from custom recovery:
Creating flashable zip:
- Unzip downloaded file
- delete EBR1 and EBR2 from unzipped folder
- copy your edited EBRs/MBR in unzipped folder
- Compress files to .zip using 7-Zip and keep zip file in sdcard
Flashing steps if you have edited data partition only:
- Reboot to custom recovery
- Flash repartition zip
- Wipe /data, /cache and dalvik-cache (can be skipped if you don’t face any force-close or other storage problems after starting phone).
Flashing steps if you have edited system partition:
- Reboot to custom recovery
- Take nandroid backup
- Flash repartition zip
- Wipe /data, /cache, /system and dalvik-cache
- Restore nandroid backup
Special thanks to tirta.agung whose guide helped me to understand EBRs.