[MOD] Get more usable space with smaller custom roms

fuflo

Member
Sep 6, 2012
32
33
0
Hello

scroll to the bottom of this post for an update

So, i've been searching now for a while for a guide on how to get more internal space and reduce the /system partition of my sgs3,
since many custom roms are much smaller in size compared to stock.
Since i haven't found any, i've figured i'll try doing it myself.

This requires some linux/unix shell knowledge, so unless you used linux shell and/or adb before, i don't recommend trying this.
Also, i have done this on GT-I9300, the international version. If yours is not the same, the partition layout will probably differ

Requirements:
* parted ( can't post links yet.. )

* adb ( android sdk, platform tools )

* CWM recovery installed

* Custom ROM zip on your PC to upload after the operation.


Alright, so here goes. ( since i already mentioned this is an advanced operation, i'll keep it pretty basic )

1. Reboot into CWM recovery
2. Unmount everything possible (either in CWM or 'adb shell', i used the latter - more reliable i would guess)
3. adb push X:\xx\xx\parted /
4. adb shell
5. chmod +x parted

Now the real fun begins.

6. /parted /dev/block/mmcblk0

This will launch parted. type 'p' and press 'enter', you'll see something like this:

Code:
Number  Start   End     Size    File system  Name      Flags
 1      4194kB  8389kB  4194kB               BOTA0
 2      8389kB  12.6MB  4194kB               BOTA1
 3      12.6MB  33.6MB  21.0MB  ext4         EFS
 4      33.6MB  41.9MB  8389kB               PARAM
 5      41.9MB  50.3MB  8389kB               BOOT
 6      50.3MB  58.7MB  8389kB               RECOVERY
 7      58.7MB  92.3MB  33.6MB               RADIO
 8      92.3MB  1166MB  1074MB  ext4         CACHE
 9      1166MB  2777MB  1611MB  ext4         SYSTEM
10      2777MB  3364MB  587MB   ext4         HIDDEN
11      3364MB  3372MB  8389kB               OTA
12      3372MB  15.8GB  12.4GB  ext4         USERDATA
Now you need to calculate the partition sizes you actually need. Ignoring first partitions up to CACHE not to mess things up.

As far as i know, the CACHE partition is used for OTA, hence it's size - to fit ~ size of the rom. Personally i have no intention of using OTA, so i made the partition 100mb. I'm definitelly no expert in hacking android yet, but personally i haven't noticed myself using /cache more than that.

HIDDEN contains some preloaded apps - not valid in case of custom roms. I made it 1mb.
Not sure what OTA partition is used for, but again, i don't use OTA so i don't really care. 1mb.

As for SYSTEM, this depends how big is your custom rom. I currently use SlimBean which is ~100mb together with gapps, but just in case i've set the size to 300mb.

and the rest goes for USERDATA. I think you can already forsee a few more GBs for internal storage :)


So, just remove all the partitions that need to be resized and recreate them:
Code:
(in parted)
rm 8
rm 9
rm 10
rm 11
rm 12
then issue 'mkpart' 5 times to recreate the partitions.
When asked for a name, just press enter (we'll set the names later, since mkpart didn't change the names for me anyway)
When asked for type, you can either enter ext4 or simply press enter. We'll format partitions afterwards anyway.
When asked for start, enter the value from last partition's 'End'. For CACHE that would be the end of RADIO, so 92.3MB
For End enter the size you want. 10KB, 20MB, 1GB - annotations accepted.
After you create a partition, issue 'p' to check it's End for the next partition's start.

For USERDATA End just enter what you saw in the beggining, 15.8GB in my case.

exit parted, 'q'

7. format new partitions (except OTA)

Code:
mke2fs -T ext4 /dev/block/mmcblk0p8
mke2fs -T ext4 /dev/block/mmcblk0p9
mke2fs -T ext4 /dev/block/mmcblk0p10
mke2fs -T ext4 /dev/block/mmcblk0p12
For USERDATA i also used an option '-m 0.2' to get those extra 300mb from ext4 reserve.

8. mount /data/ ; mkdir /data/media
9. exit adb ; adb push X:\xx\customRom.zip /data/media

10. Flash new rom in CWM and reboot.


That's pretty much it. At least it was for me.

I may have missed something, but i'm now assured that this is possible.

For reference:

Code:
Before:
Number  Start   End     Size    File system  Name      Flags
 1      4194kB  8389kB  4194kB               BOTA0
 2      8389kB  12.6MB  4194kB               BOTA1
 3      12.6MB  33.6MB  21.0MB  ext4         EFS
 4      33.6MB  41.9MB  8389kB               PARAM
 5      41.9MB  50.3MB  8389kB               BOOT
 6      50.3MB  58.7MB  8389kB               RECOVERY
 7      58.7MB  92.3MB  33.6MB               RADIO
 8      92.3MB  1166MB  1074MB  ext4         CACHE
 9      1166MB  2777MB  1611MB  ext4         SYSTEM
10      2777MB  3364MB  587MB   ext4         HIDDEN
11      3364MB  3372MB  8389kB               OTA
12      3372MB  15.8GB  12.4GB  ext4         USERDATA
After:
Code:
Number  Start   End     Size    File system  Name      Flags
 1      4194kB  8389kB  4194kB               BOTA0
 2      8389kB  12.6MB  4194kB               BOTA1
 3      12.6MB  33.6MB  21.0MB  ext4         EFS
 4      33.6MB  41.9MB  8389kB               PARAM
 5      41.9MB  50.3MB  8389kB               BOOT
 6      50.3MB  58.7MB  8389kB               RECOVERY
 7      58.7MB  92.3MB  33.6MB               RADIO
 8      92.3MB  192MB   99.7MB  ext4         CACHE
 9      192MB   500MB   308MB   ext4         SYSTEM
10      500MB   501MB   1000kB  ext2         HIDDEN
11      501MB   502MB   1000kB               OTA
12      502MB   15.8GB  15.3GB  ext4         USERDATA

So now i have 13.8Gb of usable space on my sgs3 and i'm pretty happy about it.. No need to convert user apps to system apps in titanium any more..


Since i'm not sure about the effects of this for the long term, please provide me feedback if it went ok for you or not.
And if you have any points to make why this is not good i would also appreciate that.





UPDATE:
First of all, parted seems to be included in CMW, at least the cwm-touch-6.0.1.2 version has it ( noticed only after a while )
So no need to look for parted binaries if you're using that.

Second - as mentioned by sorg, this does mess up the partition table and anything that needs odin will not work. Tried myself, messed up the whole thing, but recovery was still half operational.
Anyway, using .pit ( GT-I9300_mx_20120329.pit ) the partition table was restored on my I9300 while flashing official stock, LH8.

So that's all fine. In case you don't want to try .pit method, you could simply restore the partition table using parted. Basically resize the partitions using same method to the original sizes. haven't tried this myself, but i imagine it should work

One last note, since i was too eager to do this all, i didn't notice the 'unit' command in parted. basically you can use 'unit kib', 'unit mib' to get the 'computer' values for sizes, which actually make more sense looking at parted output. the OTA partition is for example exactly 8mb (mib).

To get the 1000s units, use 'unit kb', 'unit 'mb' or 'unit compact' which selects the unit automatically based on partition size.
 
Last edited:

tolis626

Senior Member
Dec 31, 2009
2,518
598
0
Amaliada
Alright,you've got some balls dude.I got to give you that!Bravo,really nice work.I don't need it atm (32gb version rocks hard),but I may do it for the fun of it. ;)
 

nfsmw_gr

Senior Member
Dec 25, 2010
3,800
1,941
258
26
Salamina,Greece
www.facebook.com
Nice mod man!
You've got balls of steel trying to do that,i really admire you...:)
Anyway,excuse me if i'm wrong but i think applications you get form market get downloaded in cache first?
If you shrink that partition won't you have issues with apps?
 

b-eock

Senior Member
Dec 30, 2010
3,591
1,397
0
Dallas, Texas
1024Kb is one MB not 1000. it is 2^10 for a full MB. Great guide though, and VERY nice detailed instructions. Thank you, and you might wanna put a "I am NOT responsible" banner at the top!!! :D
 

fuflo

Member
Sep 6, 2012
32
33
0
Nice mod man!
You've got balls of steel trying to do that,i really admire you...:)
Anyway,excuse me if i'm wrong but i think applications you get form market get downloaded in cache first?
If you shrink that partition won't you have issues with apps?
You might have issues if you try to download apps that the apk is bigger than the cache partition. Otherwise i don't think there's an issue. And since i don't download anything above 100mb, that's why i made it so. and even then, you can just symlink some folder in /data to /cache and you'll have all the space in the world for you cache.. :)

1024Kb is one MB not 1000. it is 2^10 for a full MB. Great guide though, and VERY nice detailed instructions. Thank you, and you might wanna put a "I am NOT responsible" banner at the top!!! :D
That's how parted displays it.
 
  • Like
Reactions: nfsmw_gr

fuflo

Member
Sep 6, 2012
32
33
0
Ok, so 1000KB in parted equals 1024KBs or 1MB? Just trying to get this right...

Sent from my GT-I9300 using xda premium
1MB. In the guide above i have put 501MB for start and 502MB for end for OTA partition for example. That's 1MB in size, but gets displayed as 1000Kb. And 1000MB would be 1GB there.

I guess parted calculates in 10s and actually all of the hard drives are calculated like that on label. So in reality there's 16000000000 of bytes in my SGS3. divide that by 1024 a couple of times and you get lower 'actual' size. then file system format reduces usable space even more, but that's another subject...
 
  • Like
Reactions: Erahgon

JJEgan

Senior Member
Oct 24, 2010
30,191
5,868
243
Does this not qualify as Original Development .
OP i would PM a mod to ask for inclusion in Original i have .


jje
 

fuflo

Member
Sep 6, 2012
32
33
0
Well yes i guess. Just didn't have permissions to post there :)

If a mod reads this, feel free to move the thread. Otherwise i'll pm someone when i get home


Sent from my GT-I9300 using xda app
 

d4fseeker

Senior Member
Oct 16, 2010
1,300
437
0
Hardware uses the industry-standard 10^3=1000 (according to sni: KiB) while software tends to use 2^10=1024 (according to sni: KB)

Sent from my GT-I9300 using xda premium
 

ykkfive

Inactive Recognized Developer
Jul 25, 2010
2,819
2,826
193
ykkfive.blogspot.com
i made similar changes to my I9000 before, no problems at all

edit forgot to mention that the only thing you have to take care of is how to install newer roms with the new layouts in the future, but i bet with your knowledge in linux it wont be a problem to you at all :)
 
Last edited by a moderator:

sorg

Senior Member
Sep 5, 2006
1,049
1,136
143
台灣
Will these changes in parted be saved into PIT structure?
Otherwise ODIN may repartition this if u will flash anything through it. Probably it won't touch data outside flashed part, so in this case it's still possible to flash for example recovery partition (in case if it get corrupted). If ODIN write some marks in all partitions every time then you may corrupt data on later partitions.


Btw, to make this thread useful, here is parted i've found on http://forum.cyanogenmod.com/topic/6433-solved-messed-up-partitions-on-internal-storage/ :

http://www.sendspace.com/file/w6hi6x
 

9Lukas5

Senior Member
Dec 14, 2010
3,805
2,015
253
near Stuttgart
Will these changes in parted be saved into PIT structure?
Otherwise ODIN may repartition this if u will flash anything through it. Probably it won't touch data outside flashed part, so in this case it's still possible to flash for example recovery partition (in case if it get corrupted). If ODIN write some marks in all partitions every time then you may corrupt data on later partitions.


Btw, to make this thread useful, here is parted i've found on http://forum.cyanogenmod.com/topic/6433-solved-messed-up-partitions-on-internal-storage/ :

http://www.sendspace.com/file/w6hi6x
As far as I know Odin only repartitions the device if you include the correct pit for the device and check repartition.

L
 

sorg

Senior Member
Sep 5, 2006
1,049
1,136
143
台灣
As far as I know Odin only repartitions the device if you include the correct pit for the device and check repartition.
ODIN always read PIT file from device if you don't provide such. You can check ODIN logs. I believe, ODIN does following things:
1) if PIT file not provided, then read it from device
2) check file names assigned to every partition and pick them from supplied TAR file
3) write files directly (after un-sparse img files if required) to flash addresses taken from PIT.

so, if PIT structure in I9300 is not the same as GPT partition table, then you may mess data if you will accidentally flash parts beyond CACHE partition through ODIN.
 

fuflo

Member
Sep 6, 2012
32
33
0
A little update:

First of all, parted seems to be included in CMW, at least the cwm-touch-6.0.1.2 version has it ( noticed only after a while )
So no need to look for parted binaries if you're using that.

Second - as mentioned by sorg, this does mess up the partition table and anything that needs odin will not work. Tried myself, messed up the whole thing, but recovery was still half operational.
Anyway, using .pit ( GT-I9300_mx_20120329.pit ) the partition table was restored on my I9300 while flashing official stock, LH8.

So that's all fine. In case you don't want to try .pit method, you could simply restore the partition table using parted. Basically resize the partitions using same method to the original sizes. haven't tried this myself, but i imagine it should work

One last note, since i was too eager to do this all, i didn't notice the 'unit' command in parted. basically you can use 'unit kib', 'unit mib' to get the 'computer' values for sizes, which actually make more sense looking at parted output. the OTA partition is for example exactly 8mb (mib).

To get the 1000s units, use 'unit kb', 'unit 'mb' or 'unit compact' which selects the unit automatically based on partition size.
 

9Lukas5

Senior Member
Dec 14, 2010
3,805
2,015
253
near Stuttgart
[...] Second - as mentioned by sorg, this does mess up the partition table and anything that needs odin will not work. Tried myself, messed up the whole thing, but recovery was still half operational.
Anyway, using .pit ( GT-I9300_mx_20120329.pit ) the partition table was restored on my I9300 while flashing official stock, LH8. [...]
Do you mean that after repartitioning that way, you weren't able to flash e.g. a modem with Odin? Because I tried it just now, and for me it's working fine.
From my understanding about the .pit file, the pit gives informtion about the start and end point for the partitions. After we have repartitioned the device partially, for the changed partitoins the information in the pit file doesn't match anymore, but as kernel, modem, recovery, etc. are stored on the partitons 1-7 and we haven't changed them, Odin pulls the pit from our device and flash to modem e.g. to the place the information in the pit file says. So all flashing actions which only go to the partitions 1-7 shouldn't be problematic, only if you want to flash a whole samsung firmware with Odin you have to tick repartitioning and select the correct pit file in Odin.

And then I have a question regarding doing the same on the S4. The S4 has a protected bootloader as you maybe has heard of. Do you think this method is also usable on the S4 without the danger of a hard-brick? From the recovery all the partitions I want to change ( cache, system, data, ...) are also flashable, only those before are protected, so could/should it work? Invisiblek has written it would brick my phone :eek: :

DO NOT DO THIS

that link is for an exynos sgs3

our pit is signed. This will brick your device.


L
 

fuflo

Member
Sep 6, 2012
32
33
0
You are most likely correct with the first part of your post. I haven't tried flashing separate parts of a rom at that time, but it would most likely work.

Regarding S4, to be honest i have no knowledge of it. Even more so about signed stuff. From general knowledge, if the signature isn't connected the things you want to modify, it would probably work, but don't take my word for it. You'd better off discussing this in the S4 forums :)



Regarding GT-I9300_mx_20120329.pit, i later read that it's for 64gb version of i9300. Although it worked fine for me. As for where to get it, just google it.. there are zips all around the net with various versions, including this one.
 
  • Like
Reactions: 9Lukas5
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone