I managed to repartition my G330 to 450MB /cache, 5MB /cust, 1.1GB /system, 1GB /data and 930MB /storage/sdcard0
without losing any data. My installed installed SlimKat 9.0 still worked after this.
(I have no clue how much /cache one needs, maybe less iss enough.)
Note: Below, I have posted a reduced guide if you only want to increase /data at cost of internal SD size.
This is how I repartitioned my G330:
- installed CWM 184.108.40.206 (others may work, I just had this one installed)
- adb (from Android SDK)
- external SD card with >4GB free space
- "resize2fs_s" from https://github.com/moddingg33k/android_kernel_y300_general/blob/master/ramdisk/synopsis/sbin/resize2fs_s
- accepting that this may permanently brick your phone
- being able to read & doing exactly what is written here
Note1: I don't know if it's just my phone, but it spontaneously rebooted several times
while in CWM (idle, copying files in phone or between phone and PC).
Note2: I didn't check this guide. I just wrote it up after doing all this to my phone. Step 1: Planning the partition layout
Boot the phone to recovery.
Run "adb shell" from command line
run: fdisk -H64 -S32 -l /dev/block/mmcblk0
to print the current partition table
The last lines are (I added the mount points on the right hand side)
Device Boot Start End Blocks Id System
/dev/block/mmcblk0p15 201 392 196608 83 Linux -> /cache
/dev/block/mmcblk0p16 393 472 81920 83 Linux -> /cust
/dev/block/mmcblk0p17 473 984 524288 83 Linux -> /system
/dev/block/mmcblk0p18 985 1624 655360 83 Linux -> /data
/dev/block/mmcblk0p19 1625 3728 2154496 6b Unknown -> /storage/sdcard0 ("internal SD card")
"mmcblk0" is the phone-internal flash, and the "pXX" suffix enumerates the partitions in this flash.
"Blocks" is in 1MB units. You can see /system is only 512MB
This is what we are going to do:
/dev/block/mmcblk0p15 202 649 458752 83 Linux -> /cache
/dev/block/mmcblk0p16 650 659 10240 83 Linux -> /cust
/dev/block/mmcblk0p17 660 1799 1167360 83 Linux -> /system
/dev/block/mmcblk0p18 1800 2799 1024000 83 Linux -> /data
/dev/block/mmcblk0p19 2800 3728 951296 6b Unknown -> /storage/sdcard0
Make sure that each new partition is big enough to hold the current content.
For p15-p18, you can use "resize2fs_s -P" (see step 3) to get the minimum required size.
For p19, mount the phone as USB storage, then check in Windows how full the internal SD drive is.
The partition layout is somewhat inconsitent/corrupt if the first few partitions.
To avoid problems from overlap, I chose to recreate /cache starting at 202, not 201. Step 2: Preparation
Copy resize2fs_s to your external SD card root dir.
On phone (under mounts & storage), mount /storage/sdcard1 (your actual SD card) and unmount /cache.
Copy resize2fs_s to root partition & make it executable
run: cp /storage/sdcard1/resize2fs_s .
run: chmod a+x resize2fs_s Step 3: Make a backup of all relevant EXT partitions
You need to do this step for all partitons you want to keep.
Other partiton content will be lost.
- backup /data and /cust
- backup /system (unless you want to do a fresh ROM install after repartitioning AND don't need a fallback)
- skip /cache (just format them in CWM after repartitioning)
- skip /storage/sdcard0, this is a FAT partition and we need handle to handle this differently.
We're resizing the partitions now to make them smaller (example is p15 = /cache here):
run: ./resize2fs_s -P /dev/block/mmcblk0p15
This gives you the minimum partition size for mmcblk0p15 (=/cache)
"Estimated minimum size of the filesystem: 14170" (in 4KB blocks)
Now shrink to some size that is ~10% larger.
run: ./resize2fs_s /dev/block/mmcblk0p15 15000
Then copy to shrunk partition image to external SD card.
Partition p15 goes into a file "p15". Specify the copy size accordingly.
run: dd if=/dev/block/mmcblk0p15 of=/storage/sdcard1/p15 bs=4K count=15000 Step 4: Make a backup of InternalSdCard FAT partition (/storage/sdcard0)
In CWM, select "mount USB storage".
On Windows, copy all files from internal SD card partition to some directory (e.g. "InternalSDcardBackup") on PC.
(You should first enable display of hidden files, in case there are some)
"Eject" both phone drives in Windows, then leave "mount USB storage" in CWM.
In CWM unmount all partitions except /storage/sdcard1. Step 5: Change partition layout
run: fdisk -H64 -S32 /dev/block/mmcblk0
Delete all partitions to be changed:
(Enter d, then the partition number to delete)
do: d [enter] 19 [enter]
do: d [enter] 18 [enter]
do: d [enter] 17 [enter]
do: d [enter] 16 [enter]
do: d [enter] 15 [enter]
Create new partitions (automatically numbered in order):
(Enter n, then the start block number, then the end block number)
For the table above, it would be:
do: n [enter] 202 [enter] 649 (for p15 = /cache)
do: n [enter] 650 [enter] 659 (for p16 = /cust)
do: n [enter] 660 [enter] 1799 (for p17 = /system)
do: n [enter] 1800 [enter] 2799 (for p18 = /data)
do: n [enter] 2800 [enter] 3728 (for p19 = /storage/sdcard0)
Change partition type for p19 to "6b" (it was like this before, and recreating the partition changed it to 83):
do: t [enter] 19 [enter] 6b [enter]
Check that the new layout is what you want:
do: p [enter]
Write the new layout to flash:
In CWM, make sure all partitons except /storage/sdcard1 are unmounted, otherwise you'll get an error here.
do: w [enter]
All partitons are now it the right size, but without right content. Step 6: Restore partition content.
In CWM, make sure all partitons except /storage/sdcard1 are unmounted.
For all EXT partitions you made a backup in step 3 (here for example p15 = /cache):
Copy shrunk backup back into new partition:
run: dd if=/storage/sdcard1/p15 of=/dev/block/mmcblk0p15 bs=4K
Enlarge file system to full partition size:
run: ./resize2fs_s /dev/block/mmcblk0p15
Repeat step 6 for all EXT partiton you want to have restored.
For skipped partitons (except p19 = /storage/sdcard0), format the partition in CWM. Step 7: Restore InternalSdCard FAT partiton
In CWM, go into USB storage mode.
On PC, format the InternalSdCard partition (default settings). Windows will ask for it by itself.
Copy files from InternalSDcardBackup to this empty partition.
Unmount phone drives in windows, then reboot phone from CWM.