[Galaxy S III Android Development] fuflo:
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:

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:

(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)

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:

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:

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.