[Miscellaneous Android Development] keanu_ritz:
Part 2 :-

for understanding your MTK device's partitions, first read this excellent guide posted by [MENTION=2338155]tirta.agung[/MENTION] --> [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

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 //?

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.