Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,771,312 Members 52,784 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] Enlarge DATAFS partition and get rid of Internal SD (UMS)

Tip us?
 
mtpi
Old
(Last edited by mtpi; 26th November 2013 at 02:18 PM.)
#1  
Member - OP
Thanks Meter 38
Posts: 37
Join Date: Nov 2010
Location: Padua, Italy

 
DONATE TO ME
Default [GUIDE] Enlarge DATAFS partition and get rid of Internal SD (UMS)

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".

Code:
$ adb shell
~ # parted /dev/block/mmcblk0
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) unit s                                                           
unit s
(parted) print                                                            
print
Model: MMC V3U00M (sd/mmc)
Disk /dev/block/mmcblk0: 30777344s
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     51711s     2560s                   SBL1
 3      53248s     55807s     2560s                   SBL2
 4      57344s     73727s     16384s                  PARAM
 5      73728s     90111s     16384s                  KERNEL
 6      90112s     106495s    16384s                  RECOVERY
 7      106496s    311295s    204800s    ext4         CACHE
 8      311296s    344063s    32768s                  MODEM
 9      344064s    1392639s   1048576s   ext4         FACTORYFS
10      1392640s   29720475s  28327836s  ext4         DATAFS
11      29720476s  29720575s  100s       fat32        UMS
12      29720576s  30769151s  1048576s   ext4         HIDDEN
Change android storage layout

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.

Code:
$ java -jar /Android/apktool1.5.2/apktool.jar if framework-res.apk
$ java -jar /Android/apktool1.5.2/apktool.jar if twframework-res.apk
$ java -jar /Android/apktool1.5.2/apktool.jar d framework-res.apk
Now you have to edit framework-res/res/xml/storage_list.xml as follow for a samsung stock derived rom:

Code:

In order to repack the apk:

Code:
$ java -jar /Android/apktool1.5.2/apktool.jar b framework-res/ framework-res.apk
For the samsung stock you have to copy the signature from the original apk (the META-INF directory and AndroidManifest.xml).

Code:
$ zip -r ../framework-res.apk META-INF
$ zip -r ../framework-res.apk AndroidManifest.xml
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).

Code:
persist.sys.vold.switchexternal=1
ro.vold.switchablepair=/storage/sdcard0,/storage/sdcard1
No need for update zip, just repartition and edit build.prop

Files
Credits

I would have never succeeded in making this guide if I hadn't found these useful forum posts on xda.
[GUIDE] External2Internal Ultimate
PIT file method to revive your phone from a MMC_CAP_ERASE brick
Sd card swapping on cm 10.2
Attached Thumbnails
Click image for larger version

Name:	2013-07-06 21.25.40.jpg
Views:	6143
Size:	23.7 KB
ID:	2097251  
The Following 25 Users Say Thank You to mtpi For This Useful Post: [ Click to Expand ]
 
garymeg
Old
#2  
garymeg's Avatar
Senior Member
Thanks Meter 13
Posts: 241
Join Date: Apr 2006
Location: Lincoln

 
DONATE TO ME
Can this be used on other Sammy modles? Mrs got a galaxy ace and it can only get about 5 apps on with latest stock rom

Sent from my GT-I9100 using xda premium
Search, Read, Learn and you will be wise............
Ask when not wise.......

Samsung Galaxy Note III Rooted can't decided between stock KK, PAC-Man Roms or SlimKat
Samsung Galaxy sII Rooted running SlimKat but could be changed any day
Samsung Galaxy Tab2 Rooted running SlimKat

My old phones

HTC Diamond, HTC Artemis, HTC Wizard

Playing with.....
HTC Leo HD2 Running Android, HTC Sensation XE, HTC Wildfire S Rooted
 
mathy007
Old
#3  
mathy007's Avatar
Senior Member
Thanks Meter 114
Posts: 371
Join Date: Dec 2012
Location: warri
+1 for this post this is what have been waiting to see i'm tired of the low internal storage i need to swap it to external 32gig mmc kudos to the poster hopes it works with stock 4.1.2 jellybean
http://forum.xda-developers.com/deviceForum/screenshots/2162/20130315T104337.JPG
Device: SGS4 GT-i9500
Kernel: Stock Repacked kernel
Rom: OzcanRom v4.1 Aroma XXUGNG3
Baseband: I9500XXUGNF6
If i Help You in Anyway Hit The Thanks Button
 
mtpi
Old
#4  
Member - OP
Thanks Meter 38
Posts: 37
Join Date: Nov 2010
Location: Padua, Italy

 
DONATE TO ME
Quote:
Originally Posted by garymeg View Post
Can this be used on other Sammy modles? Mrs got a galaxy ace and it can only get about 5 apps on with latest stock rom

Sent from my GT-I9100 using xda premium
I think it could be done. Just take a look at the partition table or PIT file...
 
mtpi
Old
#5  
Member - OP
Thanks Meter 38
Posts: 37
Join Date: Nov 2010
Location: Padua, Italy

 
DONATE TO ME
Quote:
Originally Posted by mathy007 View Post
+1 for this post this is what have been waiting to see i'm tired of the low internal storage i need to swap it to external 32gig mmc kudos to the poster hopes it works with stock 4.1.2 jellybean
I made the update.zip for neatrom, I think it should also work on stock. But with no-internal-ums-samsung.zip it will get rid of internal storage and make external storage as primary.
 
mathy007
Old
#6  
mathy007's Avatar
Senior Member
Thanks Meter 114
Posts: 371
Join Date: Dec 2012
Location: warri
One more thing must i factory reset the phone because I've already installed apps and games in it,or i just flash the update.zip
http://forum.xda-developers.com/deviceForum/screenshots/2162/20130315T104337.JPG
Device: SGS4 GT-i9500
Kernel: Stock Repacked kernel
Rom: OzcanRom v4.1 Aroma XXUGNG3
Baseband: I9500XXUGNF6
If i Help You in Anyway Hit The Thanks Button
 
mtpi
Old
#7  
Member - OP
Thanks Meter 38
Posts: 37
Join Date: Nov 2010
Location: Padua, Italy

 
DONATE TO ME
Quote:
Originally Posted by mathy007 View Post
One more thing must i factory reset the phone because I've already installed apps and games in it,or i just flash the update.zip
I suggest to
1) backup your internal sd, as you'll loose everything
2) backup your pit with heimdall
3) backup with cwm or twrp
4) upload new pit with repartition flag
5) format data and restore backup
6) flash no-internal-ums-samsung.zip

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.
 
mathy007
Old
#8  
mathy007's Avatar
Senior Member
Thanks Meter 114
Posts: 371
Join Date: Dec 2012
Location: warri
Quote:
Originally Posted by mtpi View Post
I suggest to
1) backup your internal sd, as you'll loose everything
2) backup your pit with heimdall
3) backup with cwm or twrp
4) upload new pit with repartition flag
5) format data and restore backup
6) flash no-internal-ums-samsung.zip

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.
thanks I'll keep that in mind
http://forum.xda-developers.com/deviceForum/screenshots/2162/20130315T104337.JPG
Device: SGS4 GT-i9500
Kernel: Stock Repacked kernel
Rom: OzcanRom v4.1 Aroma XXUGNG3
Baseband: I9500XXUGNF6
If i Help You in Anyway Hit The Thanks Button
 
rlorange
Old
#9  
rlorange's Avatar
Senior Member
Thanks Meter 1875
Posts: 3,846
Join Date: Nov 2010
Location: Melbourne
Would this approach be useful for the galaxy s4? With the Google experience rom available there is tonnes of wasted space in the system partition.

Sent from my GT-I9505 using Tapatalk 2
 
mtpi
Old
(Last edited by mtpi; 10th July 2013 at 07:59 PM.)
#10  
Member - OP
Thanks Meter 38
Posts: 37
Join Date: Nov 2010
Location: Padua, Italy

 
DONATE TO ME
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

Tags
datafs, internal sd, ums
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes