Tired of running out of space in the /data partition? I found a way to get rid of the UMS partition and enlarge the DATAFS partition on our beloved Galaxy S II.

WARNING: with this guide you can brick your phone and it's not intended for novice users, you have to know what you're doing.

Theory about partitions

The internal MMC (/dev/block/mmcblk0) contains partition information in two areas, one standard, the GPT partition table and in another area Samsung-specific, the PIT. With odin (or heimdall) you can simply upload a new PIT and flag for repartition, this way both the PIT and the GPT get updated. I think the PIT needs to be updated in order to use Odin for flashing stock firmware.

Creating a modified PIT file

You can get your current PIT file by downloading it with heimdall or getting a stock one for your specific model from the internet. I attached the stock one for my phone, I9100 16GB (original_I9100_16GB.pit).

Code:

$ heimdall download-pit --output mypit.pit

After you got the original PIT you can edit it with PIT Magic, a Windows .NET tool to edit PIT information, you can also run it with mono on linux/osx.

Open the file in PIT Magic and go to PIT Entry list #11, the DATAFS partition. We need to focus on two fields, the "Block size", that's the block where the partition starts and "Block count", the size of the partition in blocks. The next partition must start on the block given by the sum of the previous partition block size and block count.

In order to enlarge the DATAFS partition, just raise the value in the block count field, keeping in mind the size of a block is 512 bytes. The next partition (UMS, the internal sd) must start as stated above, so just write the correct value in the block size field of the #12 partition. I suggest to keep the UMS partition if you're running a stock or stock-derived rom, just make it very small (in the attached PIT I made it about 50MB, small-ums_I9100_16GB.pit), but if you're running an AOSP flavor of android you can get rid of the UMS partition and the HIDDEN one (/preload). Keep in mind the sum of block size and block count of the #12 UMS partition must be exactly the number in the block size of the #13 HIDDEN partition (or the DATAFS must end on the last block of the HIDDEN partition if you're getting rid of the last two partitions).

After you saved the new pit file, just upload to your phone with heimdall or odin.

Code:

$ heimdall flash --repartition --pit newpit.pit

You can have a look at the new partition table in recovery, with an adb shell, using parted. You can see the same numbers as the ones in the PIT file using the command "unit s" then "print".

Now we have to tell android to ignore the internal partition and use the external sd card as the main one. If you just want to swap the two, just google around, there are plenty of guides about this.

We have to edit two files, /system/etc/vold.fstab and storage_list.xml inside /system/framework/framework-res.apk. I have attached an update.zip for samsung stock roms (no-internal-ums-samsung.zip) and for cyanogenmod 10.1 (no-internal-ums-cm10.1.zip), if you use one of these, you can skip the following details, the updater will take care of the modifications.

In vold.fstab we just have to remove references to the internal sdcard and change the mount point for the external one to /storage/sdcard0.

The other file, storage_list.xml is trickyer, as it's inside an apk. This file contains a list of all the storage the hardware can handle. We need to remove the internal sd card from this file. In order to do this you need apktool. These are the command I used to extract the apk.

CyanogenMod 10.2
In order to use this method with cm 10.2, repartition (removing both ums and preload or by resizing them) and add this in /system/build.prop (in order to make the external sd the main storage).

If anything goes wrong you can restore your original pit, but beware that if you make changes to crucial partitions you can brick your phone, if you use my pit file, i suggest tolook if oother partitions remain unchanged.

If anything goes wrong you can restore your original pit, but beware that if you make changes to crucial partitions you can brick your phone, if you use my pit file, i suggest tolook if oother partitions remain unchanged.

I think it should also work on the s4 as it hase the pit partition and gpt i think, you have to experiment a bit... But if you flash the google experience rom with odin the size mismatch of the partition and the image file can be a problem, you have to find a solution for this, like extracting the files and make an update.zip.

I think it should also work on the s4 as it hase the pit partition and gpt i think, you have to experiment a bit... But if you flash the google experience rom with odin the size mismatch of the partition and the image file can be a problem, you have to find a solution for this, like extracting the files and make an update.zip.

Sent from my GT-I9100 using xda app-developers app

Yeah everyone is using a CWM install zip but many people would love to reclaim that wasted space. Google ROM is 500Mb sitting in a 2.5GB system partition!!

XDA Developers was founded by developers, for developers. It is now a valuable resource for people who want to make the most of their mobile devices, from customizing the look and feel to adding new functionality.Are you a developer?