FORUMS
Remove All Ads from XDA

MOD + Tutorial for Re-partitioning Storage of MTK6589 + Flash through CWM/TWRP

172 posts
Thanks Meter: 474
 
By keanu_ritz, Senior Member on 3rd June 2014, 12:26 PM
Post Reply Email Thread
Tutorial/Guide for Re-partitioning MTK6589 + Increase your System & Data Partitions + Flash through CWM/TWRP + no need to use SPFlashTool

Part 1 :- To Flash existing modified EBR files through CWM/TWRP

There are plenty of guides for re-partitioning mtk devices, so why this one?
Well almost all of them suggest to use SPFlashTool to flash the "EBR" Files.

But we can do that by using CWM/TWRP (Custom Recoveries) as well!!!!!
no need to use SPFlashTool!
no need to format the Internal SDCard through PC!!

Just take your modified "EBR" files and put them into a Flashable Zip.

Edit the "updater-script" file to include the following lines.


Code:
package_extract_file("EBR1", "/dev/ebr1"); 
#put the name of your EBR1 file in place of "EBR1"
package_extract_file("EBR2", "/dev/ebr2"); 
#put the name of your EBR2 file in place of "EBR2"

Note :-
If your device uses both the files then add both the lines and If your device uses only "EBR1" then add only the line of "EBR1".

Now add the following lines to format your "/system" , "/cache" and "/data" partitions.


Code:

format("ext4", "EMMC", "/[email protected]", "0", "/system");
format("ext4", "EMMC", "/[email protected]", "0", "/cache");
format("ext4", "EMMC", "/[email protected]", "0", "/data");
Note :- If you are going to increase your "/system" partition then you'll have to format the 3 partitions,
and if you just want to increase the "/data" partition then just include the lines for formatting "/cache" and "/data".


now save the "updater-script" file and replace it in the Flashable zip!!

Or , you can use this sample flashable zip file.
download it and put your EBR files in it!!!!
edit the "updater-script" file according to your need and replace it in the Flashable zip!!

copy the Flashable zip file to your external SDCard
reboot to recovery
select install from zip file and choose the flashable zip file
Flash it.

Remember after flashing the EBR files do not restore your previous CWM/TWRP Backup.
Just Flash any CWM/TWRP Flashable ROM available for your device!!
Wipe Dalvik Cache if you haven't done it already!!
reboot and see for yourself!!!

Disclaimer :-
I will not be in anyway responsible for any damage this might cause to your phone.
if you'll follow the instructions correctly, then everything will be fine.


The Following 18 Users Say Thank You to keanu_ritz For This Useful Post: [ View ] Gift keanu_ritz Ad-Free
 
 
3rd June 2014, 12:27 PM |#2  
keanu_ritz's Avatar
OP Senior Member
Flag SANGLI
Thanks Meter: 474
 
More
Red face
Part 2 :-

for understanding your MTK device's partitions, first read this excellent guide posted by @tirta.agung --> [Noob Guide] Understanding the Hex value of MTK's MBR/EBR1/EBR2


So How to Increase the system partition? or the data partition?
I'll tell you!!

I use MMX Canvas HD A116 (mt6589)
it has 4GB internal storage distributed as below:
/system = 650mb
/cache = 126mb
/data = 1gb
Internal SDcard = 1.77gb


i wanted to change it to this:- (and i've done it!!!)
/system = 900mb
/cache = 126mb
/data = 2gb
Internal SDCard = remaining space i.e around 536mb



Note :- First please read the above mentioned guide, otherwise you won't understand this!!


let me try to make it simple to you
this is the hex format of "EBR1" & "EBR2"

EBR1 of MMX A116 (mt6589) :-
00 00 00 00 83 00 00 00 00 08 02 00 00 50 14 00 --> Partition 5 /system 650MB
00 00 00 00 83 00 00 00 00 58 16 00 00 f0 03 00 --> Partition 6 /cache 126MB
00 00 00 00 83 00 00 00 00 48 1a 00 00 00 20 00 --> Partition 7 /data 1GB
00 00 00 00 05 00 00 00 00 b4 01 00 ff ff ff ff --> points to ebr2

EBR2 of MMX A116 (mt6589) :-
00 00 00 00 83 00 00 00 00 94 38 00 ff b7 c5 ff --> partition 8 Internal SDCard
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


Quote:


Note :-
numbers in red --> Offset of partition

numbers in DarkOrange --> Size of Partition



Now if you notice carefully these partitions are continuous/contiguous.

133120 + 1331200 = 1464320
1464320 + 258048 = 1722368


i.e no.of sectors before partition + the length of the partition = no.of sectors before the next partition

// 133120 = no.of sectors before "/system" partition i.e "/system" starts from sector no. 133121
// 1331200 = the length of "/system" i.e "/system" is of 1331200 sectors.
// 1464320 = no.of sectors before "/cache" partition i.e "/cache" starts from sector no. 1464321
// and so on



The last line in EBR1 points to EBR2.
(This one --> 00 00 00 00 05 00 00 00 00 b4 01 00 ff ff ff ff )

and the First line in EBR2 is the one for the partition of Internal SDCard.
(This one --> 00 00 00 00 83 00 00 00 00 94 38 00 ff b7 c5 ff )

Even after reading many guides, I haven't found a proper explanation of this anywhere.
in one of them it states that,



D = (A + B) - C
where,
A = no.of sectors before "/data"
B = size of "/data"
C = offset of EBR2
D = offset part in EBR2

E = MaxValue - (A + B)
where,
MaxValue = FFFFFFFF (Hex) = 4294967295 (in decimal)
A = no.of sectors before "/data"
B = size of "/data"
E = Size part in EBR2

A = 00 48 1a 00 --> 001a4800 --> 1722368 //offset of "/data"
B = 00 00 20 00 --> 00200000 --> 2097152 //size of "/data"
C = 00 b4 01 00 --> 0001b400 --> 111616 //offset of ebr2
Max Value = FF FF FF FF --> ffffffff --> 4294967295 //?

Quote:

Note :-
in Red --> Hex values in little endian
in Orange --> Hex values in big endian
in Blue --> Decimal values


D = (A+B) - C = (1722368 + 2097152) - 111616 = 3707904

E = MaxValue - (A+B) = 4294967295 - (1722368 + 2097152) = 4291147775

D = 3707904 = 00389400 = 00 94 38 00

E = 4291147775 = ffc5b7ff = ff b7 c5 ff




so now you've got a good idea of what the values in "EBR" files mean, haven't you!!
Now here comes the Important part i.e how to modify the partition sizes.


I wanted "/system" = 900mb , so





So we get "00 20 1C 00" as the value for 900mb
(note-down these new values as we'll need to use them later)

now as we've increased the size of system we need to change the offset of the next partition so that there won't be any overlapping/corruption of partitions.

and how do we do that --> "no.of sectors before partition + the length of the partition = no.of sectors before the next partition"
i.e 133120 + 1843200 = 1976320 //new offset of "/cache"



decimal value --> 1976320
Hex value in big endian --> 001E2800
Hex value in little endian --> 00 28 1E 00


So we get "00 28 1E 00" as the value for sectors before "/cache"
i don't want to change size of "/cache" so it remains same i.e "00 f0 03 00"

now we need to offset the "/data" partition
("no.of sectors before partition + the length of the partition = no.of sectors before the next partition")
1976320 + 258048 = 2234368 // the number of sectors before "/data" partition



decimal value --> 2234368
Hex value in big endian --> 00221800
Hex value in little endian --> 00 18 22 00


So we get "00 18 22 00" as the value for sectors before "/data"

now i want to make my "/data" to 2gb i.e 2048mb





So we get "00 00 40 00" as the value for 2048mb

The last line in EBR1 Points to EBR2 so don't make any changes to it!!!

So now our modified EBR1 Becomes like this:-
00 00 00 00 83 00 00 00 00 08 02 00 00 20 1c 00 --> Partition 5 /system 900MB
00 00 00 00 83 00 00 00 00 28 1E 00 00 f0 03 00 --> Partition 6 /cache 126MB
00 00 00 00 83 00 00 00 00 18 22 00 00 00 40 00 --> Partition 7 /data 2GB
00 00 00 00 05 00 00 00 00 b4 01 00 ff ff ff ff --> Link to ebr2


now we need to offset the Internal SDCard's partition which is in EBR2





calculate new D & E :-

D = (A+B) - C
where,
A = no.of sectors before "/data"
B = size of "/data"
C = offset of EBR2


E = MaxValue - (A+B)
where,
MaxValue = FFFFFFFF (Hex) = 4294967295 (Decimal)
A = no.of sectors before "/data"
B = size of "/data"


A = 00 18 22 00 --> 00221800 --> 2234368 //offset of "/data"
B = 00 00 40 00 --> 00400000 --> 4194304 //size of "/data"
C = 00 b4 01 00 --> 0001b400 --> 111616 //offset of ebr2
Max Value = FF FF FF FF --> ffffffff --> 4294967295 //?


D = (A+B) - C = (2234368 + 4194304) - 111616 = 6317056

E = MaxValue - (A+B) = 4294967295 - (2234368 + 4194304) = 4288538623


D = 6317056 = 00606400 = 00 64 60 00

E = 4288538623 = FF9DE7FF = ff e7 9d ff






That's it, now we've got all the values ,it's time to put them into the EBR Files.
So this is the result of our modification:-
Modified EBR1 :-
00 00 00 00 83 00 00 00 00 08 02 00 00 20 1c 00 --> Partition 5 /system 900MB
00 00 00 00 83 00 00 00 00 28 1E 00 00 f0 03 00 --> Partition 6 /cache 126MB
00 00 00 00 83 00 00 00 00 18 22 00 00 00 40 00 --> Partition 7 /data 2GB
00 00 00 00 05 00 00 00 00 b4 01 00 ff ff ff ff --> Link to ebr2


Modified EBR2 :-
00 00 00 00 83 00 00 00 00 64 60 00 ff e7 9d ff --> internal sdcard


To edit "EBR" files :-
Open your ERB1 & EBR2 files in hex editor and replace the respective values with our modified values.
save the files and put them into a flashable zip and flash through CWM/TWRP or whatever custom recovery that you use!!!!

Remember after flashing the EBR files do not restore your previous CWM/TWRP Backup.
Just Flash any CWM/TWRP Flashable ROM available for your device!!
Wipe Dalvik Cache if you haven't done it already!!
reboot and see for yourself!!!




Screenshots :-












Disclaimer :-
I will not be in anyway responsible for any damage this might cause to your phone.
if you'll follow the instructions correctly, then everything will be fine.
The Following 20 Users Say Thank You to keanu_ritz For This Useful Post: [ View ] Gift keanu_ritz Ad-Free
3rd June 2014, 12:28 PM |#3  
keanu_ritz's Avatar
OP Senior Member
Flag SANGLI
Thanks Meter: 474
 
More
Red face
Mods :-

Mod 1 :- RiTz_partition_mod_a116.zip
/system = 900mb
/data = 2gb
Internal SDCard = 536mb


Revert to stock/Original partition sizes :-
RiTz_partition_mod_Revert_a116.zip

If you want them resized according to your need then you can request it here or use this tutorial to do it yourself!!!
The Following 10 Users Say Thank You to keanu_ritz For This Useful Post: [ View ] Gift keanu_ritz Ad-Free
3rd June 2014, 03:27 PM |#4  
daksh143's Avatar
Senior Member
Flag Mumbai
Thanks Meter: 56
 
More
Post
it sounds amazing but please u can provide screenshots please....
The Following User Says Thank You to daksh143 For This Useful Post: [ View ] Gift daksh143 Ad-Free
3rd June 2014, 04:33 PM |#5  
keanu_ritz's Avatar
OP Senior Member
Flag SANGLI
Thanks Meter: 474
 
More
Wink
Quote:
Originally Posted by daksh143

it sounds amazing but please u can provide screenshots please....

Screenshots are already provided , plz check post no.2
The Following User Says Thank You to keanu_ritz For This Useful Post: [ View ] Gift keanu_ritz Ad-Free
3rd June 2014, 05:21 PM |#6  
Senior Member
Pune
Thanks Meter: 54
 
More
Great detailed guide, Thank you. One question, is that also possible to increase Ram too?

Sent from my Micromax A116i using XDA Premium 4 mobile app
4th June 2014, 03:39 PM |#7  
keanu_ritz's Avatar
OP Senior Member
Flag SANGLI
Thanks Meter: 474
 
More
Red face
Quote:
Originally Posted by j_svas

Great detailed guide, Thank you. One question, is that also possible to increase Ram too?

Sent from my Micromax A116i using XDA Premium 4 mobile app

don't think so!!
The Following User Says Thank You to keanu_ritz For This Useful Post: [ View ] Gift keanu_ritz Ad-Free
6th June 2014, 11:40 AM |#8  
Senior Member
Flag Mumbai
Thanks Meter: 137
 
More
Thanks for this guide... It will definitely be good...

One question - I presume this remains permanent till you modify partitions again, or till you flash a rom that allows you to modify the partitions as well right ??

I had modified my partition to /data being 2.5gb from one of the earlier methods and never looked back since... It really helps when you dont have to bother about moving apps around to fit into the given space....

Good work dude.... cheers

Greg
6th June 2014, 05:24 PM |#9  
keanu_ritz's Avatar
OP Senior Member
Flag SANGLI
Thanks Meter: 474
 
More
Thumbs up
Quote:
Originally Posted by gregferns

One question - I presume this remains permanent till you modify partitions again, or till you flash a rom that allows you to modify the partitions as well right ??

Greg

Yes , you are right!
the partitions will remain permanent as long as you don't flash the "EBR" files!!
18th June 2014, 07:04 PM |#10  
Senior Member
Flag Mumbai
Thanks Meter: 137
 
More
@keanu_ritz

Hi.

Original sizes are
/system = 650mb
/cache = 126mb
/data = 1gb
Internal SDcard = 1.77gb

I want it changed to below
/system = 700mb
/cache = 126mb
/data = 2gb
Internal SDCard = remaining space i.e around 536mb

Basically you had made /system= 900mb i want 200mb of that moved to Internal SDCard...

Can you please do that for me ??

ALso i have a 64GB card with around 1.5gb or 2gb sd-ext.... just for your info.

regards
Greg
19th June 2014, 11:45 AM |#11  
keanu_ritz's Avatar
OP Senior Member
Flag SANGLI
Thanks Meter: 474
 
More
Thumbs up
Quote:
Originally Posted by gregferns

@keanu_ritz

Hi.

Original sizes are
/system = 650mb
/cache = 126mb
/data = 1gb
Internal SDcard = 1.77gb

I want it changed to below
/system = 700mb
/cache = 126mb
/data = 2gb
Internal SDCard = remaining space i.e around 536mb

Basically you had made /system= 900mb i want 200mb of that moved to Internal SDCard...

Can you please do that for me ??

ALso i have a 64GB card with around 1.5gb or 2gb sd-ext.... just for your info.

regards
Greg

take complete backup of your phone before you try this.
you will have to flash a new ROM after you flash this and you can't/shouldn't restore your old CWM/TWRP backup.

attaching your requested file.
Attached Files
File Type: zip RiTz_Mod_4_gregferns.zip - [Click for QR Code] (237.9 KB, 453 views)
The Following 3 Users Say Thank You to keanu_ritz For This Useful Post: [ View ] Gift keanu_ritz Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes