[ HOW-TO ] - Resizing partitions (Universal Mode)

Search This thread

tuxafgmur

Inactive Recognized Developer
Feb 10, 2013
1,097
3,249
Spain
I wrote this How-To several months ago and published in a spanish forum.
Now I've recovered to share here as it may interest someone.

This was originally written in spanish and now, our friendly companion @nachordez
has been kind enough to translate it to english. Thank you very much for your help. :good:

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I'll try to explain here how to change the size of our device partitions.

Though the presented data are referred to a 16 GB, a p5110 in this case, they are easy to adapt to a 8 GB one, and/or any other model, with some light corrections.

There can be other ways, but this one has the advantage that depends only on not writing wrong data, and that's easily achieved with a little extra concentration during our work.
Anyway, it's needed to follow very strictly this how-to.
In case of total failure, we should restore the tab through the flashing of a Stock version using the pit file.
ALL the data not saved in the external MicroSD card WILL BE LOST, 'cause we'll delete the /system, /data and /cache partitions.


What is needed:

  • A computer.
  • A properly running adb program.
  • Recovery installed.
  • External MicroSD card installed and with available space.
  • Connection cable.
  • Full Battery.
  • For 3G (GSM) models, the original “modem.bin” file, obtained from a stock ROM.

The modem.bin file is not really needed as we can get it from our tablet with next command
dd count=40960 bs=512 if=/dev/block/mmcblk0p8 of=/external_sd/modem.bin​

All process is done from computer, except a short intervention at end, done from tablet.

This how-to is planned for a AOSP-like ROM, such as CyanogenMod (for example).
In the case of a Stock ROM, the partition sizes we are adjusting will be too short for it.


Before starting:

We have to check that there is enough free space in the MicroSD card, and we have to do a backup through recovery, choosing EXTERNAL SDcard.
If the internal one is used, IT WILL BE LOST DURING PROCESS.

This step is very important, to recover the ROM without re-install from zero.
So, let me say it again: EVERY USER DATA that has being not COPIED to the EXTERNAL SDcard, WILL BE LOST.
After next steps, ONLY the external MicroSD will be conserved without erasing.

So, we check once again that everything is saved, and copy to the external MicroSD (if our tab is a 3G model) the “modem.bin” file that will be needed afterwards.



So... Let's start hacking!:

We always wrote in our PC.

We reboot our tab in recovery mode, and connect the cable.
To enter the tab from our computer:
> adb shell

Once entered correctly on the tablet, we like more clear ls command:
> alias ls='ls -an'

Now we access the partition table:
> parted /dev/block/mmcblk0

We'll get something like:
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

The command line for parted is (parted), so, every time a line starts so, that what follows this is a command.

We ask for information about current partitions:
(parted) p
Model: MMC MAG2GA (sd/mmc)
Disk /dev/block/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt


Number... Start... ....End......... Size...........File system...... Name.... Flags
1............4194kB.... 25.2MB.... 21.0MB...... ext4................ EFS
2........... 25.2MB.... 27.3MB....2097kB............................... SBL1
3........... 27.3MB.....29.4MB....2097kB............................... SBL2
4........... 29.4MB.... 37.7MB....8389kB............................... PARAM
5........... 37.7MB.... 46.1MB... 8389kB............................... KERNEL
6........... 46.1MB.... 54.5MB... 8389kB............................... RECOVERY
7............54.5MB...789.0MB.. 734.0MB....... ext4................CACHE
8......... 789.0MB.. 810.0MB.... 21.0MB.............................. MODEM
9......... 810.0MB.., 2278MB... 1468MB....... ext4............... FACTORYFS
10........ 2278MB.... 15.2GB.... 12.9GB........ext4............... DATAFS
11......... 15.2GB..... 15.8GB.... 537MB....... ext4............... HIDDEN


Comments:

  • Analizing the current partitions we can see this tablet is a 16 GB one:
  • /cache (CACHE) has 734 MB assigned
  • /system (FACTORYFS) has 1468 MB assigned
  • /data (DATAFS) has 12,9 GB assigned
  • There's also a funny 537 MB partition called HIDDEN: that's where the Samsung video, musical theme and demo pictures are stored.
  • If I don't mistake, I think I extracted them time ago, and they were just about 14 MB. In our case, we'll opt for destroying that! :)

In this how-to we'll assign:
  • /cache (CACHE) 400 MB
  • /system (FACTORYFS) 600 MB
  • /data (DATAFS) the sum of: its current size + 394 MB from CACHE + 868 MB from FACTORYFS + 536 MB from HIDDEN.
So, we'll grow our /DATAFS space in 1798 MB, which will mean more than 14 GB free space.
I use in this example 600 MB for /system was what I did in my tab.
In real world, 240 MB /cache and 500 MB /system are more than enough.

As we'll see later, all this numbers are just aproximations, not completely exact, and probably you're thinking: “My maths do not agree with this numbers”. Mine do not, also, as a fact.


Let's see all that more slowly:

  • 21+2+2+8+8+8+21+1 (for the 'hidden' partitions) give us 71 MB.
  • If we add 71 + 400 +600 we'll get 1071 MB.
  • If we have 16 GB and we use 1 GB, more than 15 GB should rest.

  • On one hand: 1 GB are 1048 MB. So, 16 GB should be 16768 MB, but we have just 15709.
  • That has a easy explanation: The hard disk makers started to measure 1 GB as 1000 MB (kind of a commercial trick). So, just beginning with that, 768 MB have disappeared in thin air.
  • On the other hand, we have 34 initial sectors to sustain the partition table, alternative sectors for errors recovering, rounding of numbers in sectors to partitions assignations, etc.
We have 11 partitions just now:.............................................. And they should get like that:

01 00021 MB...........................................................................01 00021 MB
02 00002 MB...........................................................................02 00002 MB
03 00002 MB...........................................................................03 00002 MB
04 00008 MB...........................................................................04 00008 MB
05 00008 MB...........................................................................05 00008 MB
06 00008 MB...........................................................................06 00008 MB
07 00734 MB...........................................................................07 00400 MB *
08 00021 MB...........................................................................08 00021 MB
09 01468 MB...........................................................................09 00600 MB *
10 12900 MB...........................................................................10 14638 MB *
11 00537 MB...........................................................................11 00537 MB
.....15709 MB................................................................................15709 MB



  • The difference can seem small compared to the original partitioning, nevertheless will allow us to get all our usual apps installed and, even so, preserve a free space higher than we had previously, even before than start to install anything. That's saying: even more than with a pure CM just installed and not even configured.
  • Obviously, if we translate all that to a 8 GB model, the proportional gain is much higher.
  • Also, consider that an AOSP rom like CM is not bigger than 460 MB in /system, and that cache will need just 60 MB for dalvik and what we can download from google-play at a certain time. 170 MB should be enough, unless we want to download an app bigger than 100 MB. The bigger ones I've saw are around 90-105 MB.


In this moment, we'll have to decide if we want to follow on or not.
Till now, I was just fun, but nothing has being 'broken'.

Disclaimer: If you continue reading next post, and you do what's there exposed, it will be ONLY under YOUR RESPONSIBILITY. You've being warned... ;)

CopyRight Tuxafgmur - Dhollmen 2013-2014. You can copy and distribute this post only if you mentions Author and references this XDA theread.
 
Last edited:

tuxafgmur

Inactive Recognized Developer
Feb 10, 2013
1,097
3,249
Spain
:
You have chosen to continue (you're a risky guy...)

We change the info into number of sectors (512 byts each one)
(parted) u s
(parted) p
Model: MMC MAG2GA (sd/mmc)
Disk /dev/block/mmcblk0: 30777344s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Num... Start................ End............ Size........ Fs....... Name
1............ 8192s.......... 49151s....... 40960s... ext4....EFS
2.......... 49152s.......... 53247s......... 4096s............... SBL1
3.......... 53248s.......... 57343s......... 4096s............... SBL2
4.......... 57344s.......... 73727s....... 16384s............... PARAM
5.......... 73728s.......... 90111s....... 16384s............... KERNEL
6.......... 90112s........ 106495s....... 16384s............... RECOVERY
7........ 106496s...... 1540095s... 1433600s.... ext4... CACHE
8...... 1540096s...... 1581055s....... 40960s................MODEM
9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
11...29728734s.... 30777309s... 1048576s.... ext4... HIDDEN


(From here onwards, I'll omit the heading, so that it's always the same)

  • We can see easily the ratio between MB and sectors: 4096 sectors equal 2 MB, so 1 MB are 2048 sectors.

Now, we'll delete the last partition, 'cause starting with it will make work easier at end.
(parted) rm 11
Now, we create it again, but with different data, specifying the sector where it begins (30775263) and sector where it finishes (30777310)
(parted) mkpart 11 30775263 30777310
(parted) p

Num...... Start................ End............ Size..... Fs....... Name
1............ 8192s.......... 49151s....... 40960s... ext4......EFS
2.......... 49152s.......... 53247s......... 4096s............... SBL1
3.......... 53248s.......... 57343s......... 4096s............... SBL2
4.......... 57344s.......... 73727s....... 16384s............... PARAM
5.......... 73728s.......... 90111s....... 16384s............... KERNEL
6.......... 90112s........ 106495s....... 16384s............... RECOVERY
7........ 106496s...... 1540095s... 1433600s.... ext4...CACHE
8...... 1540096s...... 1581055s....... 40960s................MODEM
9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
11... 30775263s... 30777310s......... 2048s

  • So, we have a 1 MB partition that previously was a 537 MB one :)
  • Yes, you're right. I've changed last sector from 30777309 into 30777310. I haven't added one new sector to disk, it was yet there, but unassigned.
  • This is so 'cause I want the total to be an even number of sectors, and also this partition sectors number has to be even.

Previously, this partition had a name. So, let's be polite with it:
(parted) name 11 HIDDEN
(parted) p

Num...... Start................ End............ Size..... Fs....... Name
1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
2.......... 49152s.......... 53247s......... 4096s............... SBL1
3.......... 53248s.......... 57343s......... 4096s............... SBL2
4.......... 57344s.......... 73727s....... 16384s............... PARAM
5.......... 73728s.......... 90111s....... 16384s............... KERNEL
6.......... 90112s........ 106495s....... 16384s............... RECOVERY
7........ 106496s...... 1540095s... 1433600s.... ext4....CACHE
8...... 1540096s...... 1581055s....... 40960s................MODEM
9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
11... 30775263s... 30777310s......... 2048s............... HIDDEN

  • Done. Now, we can forget it, and not even format it.
  • So that it is the last partition, and will not be used, all this work was really unnecessary, but, preventing the case that any process could count partitions, we keep home tidy.
OK. By now we have:
  • Deleted partition
  • Created partition
  • Named partition
If we have a previously calculated chart, we'll just have to do next steps for each partition and we don't need even to look at it, just to check at end if the obtained result was the one expected.

Anyway, in this How-To we'll do things one by one.

  • We shrink the CACHE partition
  • We calculate: 400 x 2048 = 819200 (400 MB x 2048 sectors = 819200 sectors)
  • 106496 + 819200 = 925696 -1 = 925695
Our new partition starts in sector 106496 and finishes in sector 925695
(parted) rm 7
(parted) mkpart 7 106496 925695
(parted) name 7 CACHE
(parted) p

Num...... Start................ End............ Size..... Fs....... Name
1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
2.......... 49152s.......... 53247s......... 4096s............... SBL1
3.......... 53248s.......... 57343s......... 4096s............... SBL2
4.......... 57344s.......... 73727s....... 16384s............... PARAM
5.......... 73728s.......... 90111s....... 16384s............... KERNEL
6.......... 90112s........ 106495s....... 16384s............... RECOVERY
7........ 106496s........ 925695s..... 819200s.... ext4... CACHE
8...... 1540096s...... 1581055s....... 40960s................MODEM
9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
11... 30775263s... 30777310s......... 2048s............... HIDDEN

We just move the MODEM partition : 925696 + 40960 -1 = 966655

(parted) rm 8
(parted) mkpart 8 925696 966655
(parted) name 8 MODEM

Now, let's go for the FACTORYFS one

(parted) rm 9
(parted) mkpart 9 966656 2195455
(parted) name 9 FACTORYFS
(parted) p

Num...... Start................ End............ Size..... Fs....... Name
1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
2.......... 49152s.......... 53247s......... 4096s............... SBL1
3.......... 53248s.......... 57343s......... 4096s............... SBL2
4.......... 57344s.......... 73727s....... 16384s............... PARAM
5.......... 73728s.......... 90111s....... 16384s............... KERNEL
6.......... 90112s........ 106495s....... 16384s............... RECOVERY
7........ 106496s........ 925695s..... 819200s.... ext4... CACHE
8........ 925696s...... . 966655s....... 40960s................MODEM
9........ 966656s.......2195455s....1228800s................FACTORYFS
10.... 4448256s.... 29728733s..25280478s.....ext4....DATAFS
11.. 30775263s.... 30777310s..........2048s................HIDDEN

There only rest DATAFS.
For it, no calculations are needed: it starts in the sector following FACTORYFS and ends in the previous to HIDDEN.
(parted) rm 10
(parted) mkpart 10 2195456 30775262
(parted) name 10 DATAFS
(parted) p

Num...... Start................ End............ Size..... Fs....... Name
1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
2.......... 49152s.......... 53247s......... 4096s............... SBL1
3.......... 53248s.......... 57343s......... 4096s............... SBL2
4.......... 57344s.......... 73727s....... 16384s............... PARAM
5.......... 73728s.......... 90111s....... 16384s............... KERNEL
6.......... 90112s........ 106495s....... 16384s............... RECOVERY
7........ 106496s........ 925695s..... 819200s.... ext4... CACHE
8........ 925696s...... . 966655s....... 40960s................MODEM
9........ 966656s...... 2195455s....1228800s................FACTORYFS
10.... 2195456s.... 30775262s..28579807s................DATAFS
11.. 30775263s.... 30777310s......... 2048s............... HIDDEN


So, that's what we got. It seemed difficult, but it's done! :cool:


Finishing:

We exit parted, for the end of feast using quit command
(parted) q

In this moment, we've returned to recovery.


Now, and only if our tab is a 3G/GSM one, we have to recover the modem:

dd count=40960 bs=512 if=/external_sd/modem.bin of=/dev/block/mmcblk0p8


Format:

Remember that we are in recovery. So, let's go to tablet and we select:
- mounts and storage

Search for and click on:
- format system
- format cache
- format /data and /data/media (/sdcard)
Just and only this options.

To check, now click on:
- mount /system
- mount /cache
- mount /data
If everything is OK, each one of the 3 options will change into unmount

If you are an expert user, surely you know how to format from shell, without using recovery options.


WE HAVE FINISHED. HURRAY!

Now, we have two options to reinitialize:

  • We install our favourite Rom, boot, configure, restore data, etc.
  • Or we restore the backup we did with the recovery in the external MicroSD card and we remain as if nothing had happened (but with lot more free space).

NOTE: I've wrote this how-to using CWM recovery, On others recovery, mount options can be slightly different

Disclaimer: If you have read this post, and did what is told in it, it will be ONLY under YOUR RESPONSIBILITY. You've being warned... ;)

CopyRight Tuxafgmur - Dhollmen 2013-2014. You can copy and distribute this post only if you mentions Author and references this XDA theread.
 
Last edited:

tuxafgmur

Inactive Recognized Developer
Feb 10, 2013
1,097
3,249
Spain
I insert below partitions data from a p3110 tablet.

This data was attached by the user Saitoh00 from spanish HTCmania forum. This user resized partitions following this How-To.


Model: MMC M8G2FB (sd/mmc)
Disk /dev/block/mmcblk0: 7818MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1.........4194kB..........25.2MB............21.0MB.......ext4.......EFS
2........ 25.2MB..........27.3MB...........2097kB......................SBL1
3.........27.3MB..........29.4MB...........2097kB..................... SBL2
4.........29.4MB..........37.7MB...........8389kB......................PARAM
5.........37.7MB..........46.1MB...........8389kB......................KERNEL
6.........46.1MB..........54.5MB...........8389kB......................RECOVERY
7.........54.5MB...........474MB............419MB.......ext4........CACHE
8..........474MB...........495MB...........21.0MB......................MODEM
9..........495MB...........914MB............419MB.......ext4........FACTORYFS
10........914MB.........7817MB..........6903MB.......ext4........DATAFS
11......7817MB.........7818MB...........1049kB......................HIDDEN


Model: MMC M8G2FB (sd/mmc)
Disk /dev/block/mmcblk0: 15269888s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1............8192s..........49151s.........40960s.........ext4......EFS
2..........49152s..........53247s...........4096s......................SBL1
3..........53248s..........57343s...........4096s......................SBL2
4..........57344s..........73727s.........16384s......................PARAM
5..........73728s..........90111s.........16384s......................KERNEL
6..........90112s........106495s.........16384s......................RECOVERY
7........106496s........925695s.......819200s.........ext4......CACHE
8........925696s........966655s.........40960s......................MODEM
9........966656s........785855s.......819200s.........ext4......FACTORYFS
10....1785856s....15267806s...13481951s.........ext4......DATAFS
11..15267807s....15269854s...........2048s......................HIDDE
 
Last edited:

prav3955

Senior Member
Sep 10, 2013
274
85
I have cyanogenmod installed over tab 2 7 inches 16 gb which I want to change but flashing stock firmware is not possible as it gives error....I feel something is wrong at partition table. I want to repartition for stock rom. ...can u guide

Sent from my SM-A500H using XDA Free mobile app
 

cogbytes

Member
Sep 27, 2014
33
7
Chandigarh
Did you ever edit partition table of your tab? If you haven't, then nothing is wrong with partition table and no need to repartition it. Installing custom roms don't change partition structure.

You should start a new thread and post exact problem there only.
 

bangdes

Senior Member
Jun 16, 2013
550
61
If we resized the partitions, maybe all custom rom would not boots?

Sent from my GT-I9300 using XDA Premium 4 mobile app
 

prav3955

Senior Member
Sep 10, 2013
274
85
Deleted
 

Attachments

  • 1428120634726.jpg
    1428120634726.jpg
    37.1 KB · Views: 1,045
Last edited:

prav3955

Senior Member
Sep 10, 2013
274
85
I request moderator to remove this post plz....

Sent from my SM-A500H using XDA Free mobile app
 

bangdes

Senior Member
Jun 16, 2013
550
61
Not exactly, just move to 'hardware hacking' thread. This is a bleeding edge and too highrisk for newbie like me :p

Sent from my GT-I9300 using XDA Premium 4 mobile app
 

iks8

Senior Member
Nov 18, 2012
1,105
352
hooray! I've made it on my 8gb p3110 :D Here is my table if you want:
Number Start End Size File system Name Flags
1 8192s 49151s 40960s ext4 EFS
2 49152s 53247s 4096s SBL1
3 53248s 57343s 4096s SBL2
4 57344s 73727s 16384s PARAM
5 73728s 90111s 16384s KERNEL
6 90112s 106495s 16384s RECOVERY
7 106496s 925695s 819200s ext4 CACHE
8 925696s 966655s 40960s MODEM
9 966656s 2195455s 1228800s FACTORYFS
10 2195456s 15267806s 13072351s DATAFS
11 15267807s 15269854s 2048s HIDDEN
but it's nothing special, it uses OP's values adapted to 8gb model. I'm very happy with results: https://www.dropbox.com/s/haq4j16shfcdf9q/Screenshot_2015-04-27-21-46-12.png?dl=0

btw I had strage issue. After whole process I couldn't format my cache partition. I tried to remove it and add again but it didn't help. Hopefully solution was easy: I had to reboot my recovery. Now everything is fine :D
Thanks for great guide

p.s.
repartitionig is preatty easy but i've spent more than hour trying to fix adb drivers :p
 
Last edited:

iks8

Senior Member
Nov 18, 2012
1,105
352
btw some ot
If you repartitioned your galaxy tab it doesn't mean that you can repartition every other android device. I made that mistake and I've just hardbricked my xperia phone trying to repartition it :D (I belive it's somehow protected). My bootloader died so it's impossible to fix it at home. Keep it in mind before you try to repartition your other device.
 

Android-Andi

Inactive Recognized Contributor
Mar 3, 2013
10,856
29,295
andi34.github.io
So, how to revert. I want to flash your rom and I cannot.
Do I have to revert to stock? Or is someone having the original partition?
Omni 5.1 and AOSP 5.1 should work i think. Or stay on KK.

Theres a different way too, let me see if i find it.

---------- Post added at 03:26 PM ---------- Previous post was at 03:19 PM ----------

So, how to revert. I want to flash your rom and I cannot.
Do I have to revert to stock? Or is someone having the original partition?
Start Reading here on page 69 (and the following Pages) http://xdaforums.com/showthread.php?t=3060319

They had same issue on ZMod rom and solved it.
 

cantabro

Member
Feb 10, 2013
27
5
Omni 5.1 and AOSP 5.1 should work i think. Or stay on KK.

Theres a different way too, let me see if i find it.

---------- Post added at 03:26 PM ---------- Previous post was at 03:19 PM ----------


Start Reading here on page 69 (and the following Pages) http://xdaforums.com/showthread.php?t=3060319

They had same issue on ZMod rom and solved it.

Thanks. But where can I find the system.tar for this?
And the last Omni founds no mirrors for download on your AndroidFileHost

I do like Lollipop
 

iks8

Senior Member
Nov 18, 2012
1,105
352
I flased omni 5.1 on my repartitoned tab and it works but 600 mb system partiton is too small for heavy lp rom and some of my favourite gapps so I decided to change partition layout again. I think that 400mb for cache it too much, my new moto e has 8 gb of storage too and only 256 mb of cache. So I changed my layout to: 256mb cache, 800mb system and rest for data. So I lost only 56mb of my data partiton while boosted by system by 200 mb so I think it is worth. Here are my commands (I think that they looks more clear than table):
I have 7'' 8 gb model
Code:
(parted) rm 7
(parted) mkpart 7 106496 630783
(parted) name 7 CACHE

(parted) rm 8 
(parted) mkpart 8 630784 671743 
(parted) name 8 MODEM

(parted) rm 9 
(parted) mkpart 9 671744 2310143 
(parted) name 9 FACTORYFS

(parted) rm 10 
(parted) mkpart 10 2310144 15267806 
(parted) name 10 DATAFS

It looks like that: https://dl.dropboxusercontent.com/u/37270614/Screenshot_2015-07-11-13-16-54.png
 
Last edited:
  • Like
Reactions: the_naturat_com

Top Liked Posts

  • There are no posts matching your filters.
  • 13
    I wrote this How-To several months ago and published in a spanish forum.
    Now I've recovered to share here as it may interest someone.

    This was originally written in spanish and now, our friendly companion @nachordez
    has been kind enough to translate it to english. Thank you very much for your help. :good:

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    I'll try to explain here how to change the size of our device partitions.

    Though the presented data are referred to a 16 GB, a p5110 in this case, they are easy to adapt to a 8 GB one, and/or any other model, with some light corrections.

    There can be other ways, but this one has the advantage that depends only on not writing wrong data, and that's easily achieved with a little extra concentration during our work.
    Anyway, it's needed to follow very strictly this how-to.
    In case of total failure, we should restore the tab through the flashing of a Stock version using the pit file.
    ALL the data not saved in the external MicroSD card WILL BE LOST, 'cause we'll delete the /system, /data and /cache partitions.


    What is needed:

    • A computer.
    • A properly running adb program.
    • Recovery installed.
    • External MicroSD card installed and with available space.
    • Connection cable.
    • Full Battery.
    • For 3G (GSM) models, the original “modem.bin” file, obtained from a stock ROM.

    The modem.bin file is not really needed as we can get it from our tablet with next command
    dd count=40960 bs=512 if=/dev/block/mmcblk0p8 of=/external_sd/modem.bin​

    All process is done from computer, except a short intervention at end, done from tablet.

    This how-to is planned for a AOSP-like ROM, such as CyanogenMod (for example).
    In the case of a Stock ROM, the partition sizes we are adjusting will be too short for it.


    Before starting:

    We have to check that there is enough free space in the MicroSD card, and we have to do a backup through recovery, choosing EXTERNAL SDcard.
    If the internal one is used, IT WILL BE LOST DURING PROCESS.

    This step is very important, to recover the ROM without re-install from zero.
    So, let me say it again: EVERY USER DATA that has being not COPIED to the EXTERNAL SDcard, WILL BE LOST.
    After next steps, ONLY the external MicroSD will be conserved without erasing.

    So, we check once again that everything is saved, and copy to the external MicroSD (if our tab is a 3G model) the “modem.bin” file that will be needed afterwards.



    So... Let's start hacking!:

    We always wrote in our PC.

    We reboot our tab in recovery mode, and connect the cable.
    To enter the tab from our computer:
    > adb shell

    Once entered correctly on the tablet, we like more clear ls command:
    > alias ls='ls -an'

    Now we access the partition table:
    > parted /dev/block/mmcblk0

    We'll get something like:
    GNU Parted 1.8.8.1.179-aef3
    Using /dev/block/mmcblk0
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted)

    The command line for parted is (parted), so, every time a line starts so, that what follows this is a command.

    We ask for information about current partitions:
    (parted) p
    Model: MMC MAG2GA (sd/mmc)
    Disk /dev/block/mmcblk0: 15.8GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt


    Number... Start... ....End......... Size...........File system...... Name.... Flags
    1............4194kB.... 25.2MB.... 21.0MB...... ext4................ EFS
    2........... 25.2MB.... 27.3MB....2097kB............................... SBL1
    3........... 27.3MB.....29.4MB....2097kB............................... SBL2
    4........... 29.4MB.... 37.7MB....8389kB............................... PARAM
    5........... 37.7MB.... 46.1MB... 8389kB............................... KERNEL
    6........... 46.1MB.... 54.5MB... 8389kB............................... RECOVERY
    7............54.5MB...789.0MB.. 734.0MB....... ext4................CACHE
    8......... 789.0MB.. 810.0MB.... 21.0MB.............................. MODEM
    9......... 810.0MB.., 2278MB... 1468MB....... ext4............... FACTORYFS
    10........ 2278MB.... 15.2GB.... 12.9GB........ext4............... DATAFS
    11......... 15.2GB..... 15.8GB.... 537MB....... ext4............... HIDDEN


    Comments:

    • Analizing the current partitions we can see this tablet is a 16 GB one:
    • /cache (CACHE) has 734 MB assigned
    • /system (FACTORYFS) has 1468 MB assigned
    • /data (DATAFS) has 12,9 GB assigned
    • There's also a funny 537 MB partition called HIDDEN: that's where the Samsung video, musical theme and demo pictures are stored.
    • If I don't mistake, I think I extracted them time ago, and they were just about 14 MB. In our case, we'll opt for destroying that! :)

    In this how-to we'll assign:
    • /cache (CACHE) 400 MB
    • /system (FACTORYFS) 600 MB
    • /data (DATAFS) the sum of: its current size + 394 MB from CACHE + 868 MB from FACTORYFS + 536 MB from HIDDEN.
    So, we'll grow our /DATAFS space in 1798 MB, which will mean more than 14 GB free space.
    I use in this example 600 MB for /system was what I did in my tab.
    In real world, 240 MB /cache and 500 MB /system are more than enough.

    As we'll see later, all this numbers are just aproximations, not completely exact, and probably you're thinking: “My maths do not agree with this numbers”. Mine do not, also, as a fact.


    Let's see all that more slowly:

    • 21+2+2+8+8+8+21+1 (for the 'hidden' partitions) give us 71 MB.
    • If we add 71 + 400 +600 we'll get 1071 MB.
    • If we have 16 GB and we use 1 GB, more than 15 GB should rest.

    • On one hand: 1 GB are 1048 MB. So, 16 GB should be 16768 MB, but we have just 15709.
    • That has a easy explanation: The hard disk makers started to measure 1 GB as 1000 MB (kind of a commercial trick). So, just beginning with that, 768 MB have disappeared in thin air.
    • On the other hand, we have 34 initial sectors to sustain the partition table, alternative sectors for errors recovering, rounding of numbers in sectors to partitions assignations, etc.
    We have 11 partitions just now:.............................................. And they should get like that:

    01 00021 MB...........................................................................01 00021 MB
    02 00002 MB...........................................................................02 00002 MB
    03 00002 MB...........................................................................03 00002 MB
    04 00008 MB...........................................................................04 00008 MB
    05 00008 MB...........................................................................05 00008 MB
    06 00008 MB...........................................................................06 00008 MB
    07 00734 MB...........................................................................07 00400 MB *
    08 00021 MB...........................................................................08 00021 MB
    09 01468 MB...........................................................................09 00600 MB *
    10 12900 MB...........................................................................10 14638 MB *
    11 00537 MB...........................................................................11 00537 MB
    .....15709 MB................................................................................15709 MB



    • The difference can seem small compared to the original partitioning, nevertheless will allow us to get all our usual apps installed and, even so, preserve a free space higher than we had previously, even before than start to install anything. That's saying: even more than with a pure CM just installed and not even configured.
    • Obviously, if we translate all that to a 8 GB model, the proportional gain is much higher.
    • Also, consider that an AOSP rom like CM is not bigger than 460 MB in /system, and that cache will need just 60 MB for dalvik and what we can download from google-play at a certain time. 170 MB should be enough, unless we want to download an app bigger than 100 MB. The bigger ones I've saw are around 90-105 MB.


    In this moment, we'll have to decide if we want to follow on or not.
    Till now, I was just fun, but nothing has being 'broken'.

    Disclaimer: If you continue reading next post, and you do what's there exposed, it will be ONLY under YOUR RESPONSIBILITY. You've being warned... ;)

    CopyRight Tuxafgmur - Dhollmen 2013-2014. You can copy and distribute this post only if you mentions Author and references this XDA theread.
    11
    :
    You have chosen to continue (you're a risky guy...)

    We change the info into number of sectors (512 byts each one)
    (parted) u s
    (parted) p
    Model: MMC MAG2GA (sd/mmc)
    Disk /dev/block/mmcblk0: 30777344s
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Num... Start................ End............ Size........ Fs....... Name
    1............ 8192s.......... 49151s....... 40960s... ext4....EFS
    2.......... 49152s.......... 53247s......... 4096s............... SBL1
    3.......... 53248s.......... 57343s......... 4096s............... SBL2
    4.......... 57344s.......... 73727s....... 16384s............... PARAM
    5.......... 73728s.......... 90111s....... 16384s............... KERNEL
    6.......... 90112s........ 106495s....... 16384s............... RECOVERY
    7........ 106496s...... 1540095s... 1433600s.... ext4... CACHE
    8...... 1540096s...... 1581055s....... 40960s................MODEM
    9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
    10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
    11...29728734s.... 30777309s... 1048576s.... ext4... HIDDEN


    (From here onwards, I'll omit the heading, so that it's always the same)

    • We can see easily the ratio between MB and sectors: 4096 sectors equal 2 MB, so 1 MB are 2048 sectors.

    Now, we'll delete the last partition, 'cause starting with it will make work easier at end.
    (parted) rm 11
    Now, we create it again, but with different data, specifying the sector where it begins (30775263) and sector where it finishes (30777310)
    (parted) mkpart 11 30775263 30777310
    (parted) p

    Num...... Start................ End............ Size..... Fs....... Name
    1............ 8192s.......... 49151s....... 40960s... ext4......EFS
    2.......... 49152s.......... 53247s......... 4096s............... SBL1
    3.......... 53248s.......... 57343s......... 4096s............... SBL2
    4.......... 57344s.......... 73727s....... 16384s............... PARAM
    5.......... 73728s.......... 90111s....... 16384s............... KERNEL
    6.......... 90112s........ 106495s....... 16384s............... RECOVERY
    7........ 106496s...... 1540095s... 1433600s.... ext4...CACHE
    8...... 1540096s...... 1581055s....... 40960s................MODEM
    9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
    10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
    11... 30775263s... 30777310s......... 2048s

    • So, we have a 1 MB partition that previously was a 537 MB one :)
    • Yes, you're right. I've changed last sector from 30777309 into 30777310. I haven't added one new sector to disk, it was yet there, but unassigned.
    • This is so 'cause I want the total to be an even number of sectors, and also this partition sectors number has to be even.

    Previously, this partition had a name. So, let's be polite with it:
    (parted) name 11 HIDDEN
    (parted) p

    Num...... Start................ End............ Size..... Fs....... Name
    1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
    2.......... 49152s.......... 53247s......... 4096s............... SBL1
    3.......... 53248s.......... 57343s......... 4096s............... SBL2
    4.......... 57344s.......... 73727s....... 16384s............... PARAM
    5.......... 73728s.......... 90111s....... 16384s............... KERNEL
    6.......... 90112s........ 106495s....... 16384s............... RECOVERY
    7........ 106496s...... 1540095s... 1433600s.... ext4....CACHE
    8...... 1540096s...... 1581055s....... 40960s................MODEM
    9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
    10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
    11... 30775263s... 30777310s......... 2048s............... HIDDEN

    • Done. Now, we can forget it, and not even format it.
    • So that it is the last partition, and will not be used, all this work was really unnecessary, but, preventing the case that any process could count partitions, we keep home tidy.
    OK. By now we have:
    • Deleted partition
    • Created partition
    • Named partition
    If we have a previously calculated chart, we'll just have to do next steps for each partition and we don't need even to look at it, just to check at end if the obtained result was the one expected.

    Anyway, in this How-To we'll do things one by one.

    • We shrink the CACHE partition
    • We calculate: 400 x 2048 = 819200 (400 MB x 2048 sectors = 819200 sectors)
    • 106496 + 819200 = 925696 -1 = 925695
    Our new partition starts in sector 106496 and finishes in sector 925695
    (parted) rm 7
    (parted) mkpart 7 106496 925695
    (parted) name 7 CACHE
    (parted) p

    Num...... Start................ End............ Size..... Fs....... Name
    1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
    2.......... 49152s.......... 53247s......... 4096s............... SBL1
    3.......... 53248s.......... 57343s......... 4096s............... SBL2
    4.......... 57344s.......... 73727s....... 16384s............... PARAM
    5.......... 73728s.......... 90111s....... 16384s............... KERNEL
    6.......... 90112s........ 106495s....... 16384s............... RECOVERY
    7........ 106496s........ 925695s..... 819200s.... ext4... CACHE
    8...... 1540096s...... 1581055s....... 40960s................MODEM
    9...... 1581056s...... 4448255s... 2867200s.... ext4... FACTORYFS
    10.... 4448256s.... 29728733s..25280478s.... ext4... DATAFS
    11... 30775263s... 30777310s......... 2048s............... HIDDEN

    We just move the MODEM partition : 925696 + 40960 -1 = 966655

    (parted) rm 8
    (parted) mkpart 8 925696 966655
    (parted) name 8 MODEM

    Now, let's go for the FACTORYFS one

    (parted) rm 9
    (parted) mkpart 9 966656 2195455
    (parted) name 9 FACTORYFS
    (parted) p

    Num...... Start................ End............ Size..... Fs....... Name
    1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
    2.......... 49152s.......... 53247s......... 4096s............... SBL1
    3.......... 53248s.......... 57343s......... 4096s............... SBL2
    4.......... 57344s.......... 73727s....... 16384s............... PARAM
    5.......... 73728s.......... 90111s....... 16384s............... KERNEL
    6.......... 90112s........ 106495s....... 16384s............... RECOVERY
    7........ 106496s........ 925695s..... 819200s.... ext4... CACHE
    8........ 925696s...... . 966655s....... 40960s................MODEM
    9........ 966656s.......2195455s....1228800s................FACTORYFS
    10.... 4448256s.... 29728733s..25280478s.....ext4....DATAFS
    11.. 30775263s.... 30777310s..........2048s................HIDDEN

    There only rest DATAFS.
    For it, no calculations are needed: it starts in the sector following FACTORYFS and ends in the previous to HIDDEN.
    (parted) rm 10
    (parted) mkpart 10 2195456 30775262
    (parted) name 10 DATAFS
    (parted) p

    Num...... Start................ End............ Size..... Fs....... Name
    1............ 8192s.......... 49151s....... 40960s... ext4.....EFS
    2.......... 49152s.......... 53247s......... 4096s............... SBL1
    3.......... 53248s.......... 57343s......... 4096s............... SBL2
    4.......... 57344s.......... 73727s....... 16384s............... PARAM
    5.......... 73728s.......... 90111s....... 16384s............... KERNEL
    6.......... 90112s........ 106495s....... 16384s............... RECOVERY
    7........ 106496s........ 925695s..... 819200s.... ext4... CACHE
    8........ 925696s...... . 966655s....... 40960s................MODEM
    9........ 966656s...... 2195455s....1228800s................FACTORYFS
    10.... 2195456s.... 30775262s..28579807s................DATAFS
    11.. 30775263s.... 30777310s......... 2048s............... HIDDEN


    So, that's what we got. It seemed difficult, but it's done! :cool:


    Finishing:

    We exit parted, for the end of feast using quit command
    (parted) q

    In this moment, we've returned to recovery.


    Now, and only if our tab is a 3G/GSM one, we have to recover the modem:

    dd count=40960 bs=512 if=/external_sd/modem.bin of=/dev/block/mmcblk0p8


    Format:

    Remember that we are in recovery. So, let's go to tablet and we select:
    - mounts and storage

    Search for and click on:
    - format system
    - format cache
    - format /data and /data/media (/sdcard)
    Just and only this options.

    To check, now click on:
    - mount /system
    - mount /cache
    - mount /data
    If everything is OK, each one of the 3 options will change into unmount

    If you are an expert user, surely you know how to format from shell, without using recovery options.


    WE HAVE FINISHED. HURRAY!

    Now, we have two options to reinitialize:

    • We install our favourite Rom, boot, configure, restore data, etc.
    • Or we restore the backup we did with the recovery in the external MicroSD card and we remain as if nothing had happened (but with lot more free space).

    NOTE: I've wrote this how-to using CWM recovery, On others recovery, mount options can be slightly different

    Disclaimer: If you have read this post, and did what is told in it, it will be ONLY under YOUR RESPONSIBILITY. You've being warned... ;)

    CopyRight Tuxafgmur - Dhollmen 2013-2014. You can copy and distribute this post only if you mentions Author and references this XDA theread.
    9
    I insert below partitions data from a p3110 tablet.

    This data was attached by the user Saitoh00 from spanish HTCmania forum. This user resized partitions following this How-To.


    Model: MMC M8G2FB (sd/mmc)
    Disk /dev/block/mmcblk0: 7818MB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number Start End Size File system Name Flags
    1.........4194kB..........25.2MB............21.0MB.......ext4.......EFS
    2........ 25.2MB..........27.3MB...........2097kB......................SBL1
    3.........27.3MB..........29.4MB...........2097kB..................... SBL2
    4.........29.4MB..........37.7MB...........8389kB......................PARAM
    5.........37.7MB..........46.1MB...........8389kB......................KERNEL
    6.........46.1MB..........54.5MB...........8389kB......................RECOVERY
    7.........54.5MB...........474MB............419MB.......ext4........CACHE
    8..........474MB...........495MB...........21.0MB......................MODEM
    9..........495MB...........914MB............419MB.......ext4........FACTORYFS
    10........914MB.........7817MB..........6903MB.......ext4........DATAFS
    11......7817MB.........7818MB...........1049kB......................HIDDEN


    Model: MMC M8G2FB (sd/mmc)
    Disk /dev/block/mmcblk0: 15269888s
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number Start End Size File system Name Flags
    1............8192s..........49151s.........40960s.........ext4......EFS
    2..........49152s..........53247s...........4096s......................SBL1
    3..........53248s..........57343s...........4096s......................SBL2
    4..........57344s..........73727s.........16384s......................PARAM
    5..........73728s..........90111s.........16384s......................KERNEL
    6..........90112s........106495s.........16384s......................RECOVERY
    7........106496s........925695s.......819200s.........ext4......CACHE
    8........925696s........966655s.........40960s......................MODEM
    9........966656s........785855s.......819200s.........ext4......FACTORYFS
    10....1785856s....15267806s...13481951s.........ext4......DATAFS
    11..15267807s....15269854s...........2048s......................HIDDE
    4
    hooray! I've made it on my 8gb p3110 :D Here is my table if you want:
    Number Start End Size File system Name Flags
    1 8192s 49151s 40960s ext4 EFS
    2 49152s 53247s 4096s SBL1
    3 53248s 57343s 4096s SBL2
    4 57344s 73727s 16384s PARAM
    5 73728s 90111s 16384s KERNEL
    6 90112s 106495s 16384s RECOVERY
    7 106496s 925695s 819200s ext4 CACHE
    8 925696s 966655s 40960s MODEM
    9 966656s 2195455s 1228800s FACTORYFS
    10 2195456s 15267806s 13072351s DATAFS
    11 15267807s 15269854s 2048s HIDDEN
    but it's nothing special, it uses OP's values adapted to 8gb model. I'm very happy with results: https://www.dropbox.com/s/haq4j16shfcdf9q/Screenshot_2015-04-27-21-46-12.png?dl=0

    btw I had strage issue. After whole process I couldn't format my cache partition. I tried to remove it and add again but it didn't help. Hopefully solution was easy: I had to reboot my recovery. Now everything is fine :D
    Thanks for great guide

    p.s.
    repartitionig is preatty easy but i've spent more than hour trying to fix adb drivers :p
    3
    If we resized the partitions, maybe all custom rom would not boots?

    Sent from my GT-I9300 using XDA Premium 4 mobile app
    Don't worry, as long as the rom sticks on the partition (specially system partition)