100% found this document useful (1 vote)
2K views37 pages

How To Edit EBR Files and Change Partition Size in MediaTek Phones

This document provides a guide to repartitioning internal storage on MediaTek Android phones to increase app storage space. It involves editing the EBR partition files and scatter file to increase the size of the app partition and decrease the size of the internal SD card partition. The guide walks through extracting and analyzing the EBR files, calculating new partition sizes, editing the hex values in the EBR files, and updating the scatter file before flashing the changes to take effect. Proper backups are recommended and the process requires some technical knowledge to avoid bricking the device.

Uploaded by

asiasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views37 pages

How To Edit EBR Files and Change Partition Size in MediaTek Phones

This document provides a guide to repartitioning internal storage on MediaTek Android phones to increase app storage space. It involves editing the EBR partition files and scatter file to increase the size of the app partition and decrease the size of the internal SD card partition. The guide walks through extracting and analyzing the EBR files, calculating new partition sizes, editing the hex values in the EBR files, and updating the scatter file before flashing the changes to take effect. Proper backups are recommended and the process requires some technical knowledge to avoid bricking the device.

Uploaded by

asiasi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Object 4

How to edit EBR files and change


partition size in MediaTek phones
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 doesnt 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
Object 5
1
3

card read/write life and it can also affect phone performance. Apps linked to SD card using
link2sd wont 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.

Im 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
doesnt require rooted phone.

This guide is for advanced users and may cause soft brick if not done properly. Do this
only if you know how to flash ROM using sp flash tool. Ill not be responsible for any
damage caused to your device.
I have seen many noobs getting trained by reading tutorials from different sources. They
create mods using others guide and give credits to themselves. If youre one of them then
stop reading now. Or if you want to create mod using this tutorial then give proper credits
to me (Qamrul Haque) with source link to this page.
Requirements:

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)

Recommended Backups:

ReadBack backup

Nandroid backup

NVRAM 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 theres no need of MBR but if your phone
have only one EBR then you might need to edit MBR. Here Im using EBR1 and EBR2
of Micromax A106 Unite 2.

Republishing any post from DroidGyan.com to any other blog or forum without authors
permission is strictly prohibited.
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 arent 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
dont 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 dont need to edit other sectors if were 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 Im 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 Im 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 Im going to increase app partition from default 924 MB to 2.5 GB. To do this
Ive 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 were 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. Weve 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. Im
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
Im 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:

Download Repartition_Mod_by_Qamrul_Haque(droidgyan.com).zip

Download from Android file host Download from Google Drive

Creating flashable zip:

1. Unzip downloaded file


2. delete EBR1 and EBR2 from unzipped folder

3. copy your edited EBRs/MBR in unzipped folder

4. Compress files to .zip using 7-Zip and keep zip file in sdcard

Flashing steps if you have edited data partition only:

1. Reboot to custom recovery

2. Flash repartition zip

3. Wipe /data, /cache and dalvik-cache (can be skipped if you dont face any force-close
or other storage problems after starting phone).

Flashing steps if you have edited system partition:

1. Reboot to custom recovery

2. Take nandroid backup

3. Flash repartition zip

4. Wipe /data, /cache, /system and dalvik-cache

5. Restore nandroid backup

Flashing EBRs from recovery may not work in some phones or ROMs. If it doesnt work
then try flashing from sp flash tool using firmware upgrade.
Credits:

Qamrul Haque

Special thanks to tirta.agung whose guide helped me to understand EBRs.

Read more https://www.droidgyan.com/edit-ebr-files-and-change-partition-size-in-


mediatek-phones/
Before flashing

Make nandroid backup


Make NVRAM backup
Backup all files from internal memory
Make titanium backup
Charge phone at least 60%

How to create Nandroid backup from custom recovery


Nandroid backup is full backup of current ROM. Nandroid backup is very useful in case of
soft brick. Nandroid backup must be created before flashing new rom, patch or repartition.
It is recommended to create NVRAM backup and nandroid backup in rooted phones
asap.Love
You need:

Custom recovery

To create nandroid backup follow these steps:

Step 1: Make sure at least 3-4 GB space is free in external sd card. The backup size can be
2 GB, 3 GB or even more depending on installed apps and data size.

Step 2: Reboot to recovery

Step 3: Go to backup and restore


Step 4: Select backup
Step 5: Wait for backup to complete. If shows error while backing up data then reboot
phone and delete unsuccessful backup from clockworkmod folder and delete some more
files to free space in sd card. Repeat from step 1.
Step 6: Youll see Backup Complete! after successful backup. Now you can use this
backup to restore system if you face any error in future like bootloop or soft brick. You can
also use this nandroid backup to revert back from new ROM. The backup is stored in
clockworkmod folder in external SD card.
Warning: Never try to edit nandroid backup files. Keep nandroid backup in SD card as it
is.

Tips: Dont forget to delete old nandroid backup after taking new backup. You can also
keep two or more nandroid backups for safety.

Read more https://www.droidgyan.com/nandroid-backup/


How to create NVRAM / IMEI backup with MTK Droid tools
NVRAM backup is the backup of NVRAM partition which contains the IMEI number and
other network info. Sometimes flashing ROMs, recoveries or formatting phone may corrupt
NVRAM partition which results into invalid IMEI. Without IMEI phone cant connect to
network.
If your phone doesnt connect to network or wifi then you have to restore the NVRAM
backup. IMEI can be restored even if you dont have backup by using apps like
chamelephon, mobileuncle tools, etc. But these apps will write IMEI temporarily. Keeping
backup is always a good idea. IMEI can be restored permanently by restoring the backup
from MTK droid tools.

Requirements:

MediaTek Drivers (Download | How to install Drivers)


ADB Drivers for Lollipop (Guide)
MTKDroidTools (Download)
Busybox (install from play store)
Rooted MediaTek phone
Steps to create NVRAM backup:

Step 1: In your phone go to Settings -> Developer Options and select USB debugging. If
there is no Developer Options in Settings then go to About phone and tap Build number 7
times to enable Developer Options.
Step 2: Open MTKdroidTools and connect your phone to PC via USB cable.

Step 3: In MTKdroidTools click ROOT button and grant root permission if asked in phone.
Step 4: Click IMEI/NVRAM button in MTK droid tools.
Step 5: Click Backup button in MTK droid tools to start backup.

After completion you can find your backup files in


the MtkDroidToolsBackupNVRAM folder.
Also check: How to restore NVRAM / IMEI backup using MTK Droid tools

Read more https://www.droidgyan.com/nvram-backup/

[Titanium Backup] How to make backup of all apps and system data

Titanium backup is the most powerful backup tool on Android. Titanium backup is very
useful app to take backup of your apps and data. You can backup and restore apps + data,
SMS, MMS, call logs, bookmarks, Wi-Fi access points, accounts, etc. Titanium backup is
very useful in case you flash new rom and want to restore all user apps with data. You can
also restore individual apps. Titanium backup is one of the most useful app for advanced
android users specially for custom rom users who change their roms regularly. Titanium
backup can be used to restore apps+data in new roms.You need:
1. Titanium backup pro (Play store)
2. Rooted Android phone

Follow these steps to make titanium backup of all user apps and system data:

Step 1: Make sure at least 3 GB space is free in your external SD card. The backup size can
be 1 GB, 2 GB or even more depending on how many apps you have installed.
Step 2: Go to Settings -> Security and disable App permissions or open App permissions
and select Always allow for all permissions of Titanium Backup

OR
Step 3: Open Titanium Backup and tap the tick mark icon in top right corner next to
search icon or press menu key and select Batch actions

Step 4: Tap RUN in Backup all user apps + system data option
Step 5: You can unselect any app which you dont want to backup. Tap the tick mark icon
in top right corner to start backup
Step 6: Wait for backup to complete. You will see a notification Batch backup
finished when titanium backup finishes successfully

Read more https://www.droidgyan.com/titanium-backup/

And what does each image do ?


Boot.img : boot.img contains the kernel and ramdisk, critical files necessary to load the device
before the filesystem can be mounted. Having a wrong Boot.img on your phone can refuse it to
boot !

cache.img Contains the cache data where Android stores frequently accessed data and app
components. not really needed and should be unticked when trying to flash a device.

Checksum.ini verifies md5 checksum , if you get a checksum error before flashing, just delete it
Wink

EBR1, EBR2 Are your partitions. 1+2 Means 2 Partitions. You can also edit the size of them.

UBOOT (LK.BIN) U-Boot is an universal boot loader for embedded systems, targeting different
platforms including ARM. Uboot and BootIMG are important files on your phone. If your device is
not booting or your display is not working ( black or stripes ) , you should reflash and check those
files.

Logo.bin As the name suggests, this is your bootlogo Happy It can be changed using this tutorial
MBR Stands for Master-Boot-Record. MBR is generally referred to as first sector (size : 512 bytes)
of any partitioned drive whereas volume or partition boot record holds code to initiate booting and
is invoked by MBR. So in short words, it defines your partitions.

Scatter File : Scatter is a file which is used to describe the loads of regions in a specific android
device running MediaTeks ARM architecture. Bascially it tells the flash tool where to flash each
image.

Preloader : this is really important. The preloader communicates with your PC. Its needed when
you want to flash your device. Due to the preloader your phone should be detected as a port on
your pc and should be flashable. Downloading a wrong pre-loader can brick your phone , so be
careful ! Never flash the preloader if not needed. There are different states of the pre-loader (like
META Mode). Even when you think your phone is bricked, mostly you can revive it.

Recovery.img Thats you recovery. It must be "tailored" to each device. You cant flash a recovery
image from a different device, but you can create your own CWM recovery using MTK droid tools.

Secro.img Is an important file for the baseband and the IMEI. You need to reflash it to rebuild
the structure. But anyway you have to restore your IMEI too.

System.img As the name suggests, this partition contains the entire Android OS. You can try
different system.img from other phones without a problem. just be sure to have a backup when
you try them Happy

User Data : Contains your personal data (do not share it with a backup) So this partition contains
the users data like your contacts, sms, settings and all android applications that you have
installed. While you are doing factory reset on your device, this partition will wipe out, Then your
device will be in the state, when you use for he first time, or the way it was after the last official
or custom ROM installation.

I hope this helps you to understand the rom structure

Br
Umesh Gaba

You might also like