[AT&T Samsung Galaxy S II SGH-I777] dimoochka:
HOW TO:

Merge "Internal Storage" (/storage/sdcard0) and "Data" (/data) partitions.

WHY:

1) Eliminate "not enough storage" limitation on installed apps. Install as many as you want.

2) Increase potential Internal Storage space (adding unused space from the /cache /preload /data and /emmc partitions together into one mega partition).

3) True full device encryption for /data and /storage/sdcard0 (if you desire).

OVERVIEW OF HOW IT WORKS:

1) Use Odin to flash a modified PIT file to repartition your device. /data is sized to 14+ GB, /cache, /preload, and /emmc are all downsized to 10MB each and are unused.

2) Use my script to modify your ROM to store your "Internal Storage" files on the /data/media/0 folder. This script will hijack your "su" and "sdcard" binaries to work properly.

3) Use my custom TWRP recovery for all of your recovery needs (supports encryption).

4) Encrypt your device if you like.

DIFFICULTY:

Medium

REQUIRED SKILLS:

1) Know how to use ADB

2) Know how to use Odin

3) Know how to fully backup your device and restore it after a factory reset.

SUPPORTED DEVICES:

SGH-S959G ONLY

"COULD BE" SUPPORTED DEVICES:

***DO NOT USE THIS METHOD FOR ANYTHING OTHER THAN SGH-S959G OR YOU WILL RISK HARD-BRICKING IT.

***IF YOU WANT TO TRY IT OUT THEN YOU MUST POST TO THIS FORUM FIRST AND WE WILL DISCUSS

***GETTING YOUR DEVICE SUPPORTED

***Possibly SGH-I777

***Possibly SGH-I9100

***Maybe Others

SUPPORTED ROMS:

CyanogenMOD 12+ (and probably derivative ROMs)

*Risk of soft brick if trying on another ROM (but no higher risk of hard brick).

RISKS: There is a very small risk of hard-brick when flashing a PIT file to your device. To minimize your risk:

1) Don't try to flash during a thunderstorm.

2) Don't try to flash to an unsupported device.

3) Don't try to flash if your USB cable / port / charging port is damaged/faulty. YOU MUST HAVE A RELIABLE USB PORT

4) Don't try to flash with your battery at 0%.

5) Don't try to flash with a computer that likes to crash a lot.

6) Don't unplug or restart your device or computer in the middle of a flash (it takes 10 seconds, be patient, geez).

STEPS TO INSTALL:

Step #1:

Make 2 backups of everything on your phone. All partitions, sdcard, micro-SD, etc...

MOVE THESE BACKUPS TO YOUR COMPUTER, THEY WILL BE ERASED FROM YOUR PHONE.

Make sure you know how to fully restore a completely wiped phone (without a preinstalled recovery) using the computer backups, starting only from the phone's BOOTLOADER/Download/Odin mode.

If you don't know how to do this, you must stop here.

PROCEEDING WITH THIS TUTORIAL WILL PERMANENTLY WIPE MOST PARTITIONS ON YOUR PHONE, THAT INCLUDES: /cache /modem /system /data /emmc /preload

Did you back up your /efs?

BACK UP YOUR /efs!!!

Step #2: Download all attached files.

Step #3: Verify that you have an uncorrupted version of both PIT files. To do this, use the md5 tool (attached) in the windows command line:

> md5 Original_SGH-S959G.pit

Output should read:

7237EC02379B497C6028236B5BBC0C91 Original_SGH-S959G.pit

> md5 MEGADATA_SGH-S959G.pit

Output should read:

9036368F41FAD9FAA266D08398EA2A33 MEGADATA_SGH-S959G.pit

If the MD5 sums don't match, STOP HERE.

DO NOT FLASH A .PIT FILE IF THE MD5 SUM IS WRONG.

Step #5: Install recovery ...

SGH-S959G_TWRP_v2.8.7.0_datamedia.zip

Step #6: Flash PIT

Did you do Step 3? Do it again, don't be lazy.

Open Odin (attached), click the PIT button. Select MEGADATA_SGH-S959G.pit

Re-Partition, Auto Reboot and F. Reset Time should be checked. The PIT filename should appear next to the PIT button.

NOTHING ELSE SHOULD BE CHECKED.

Boot your phone into bootloader/download mode and connect it. The first ID:COM field should turn yellow and have text that looks like 0:[COM5]. In the message field you will see something like <ID:0/005> Added!

Review the risks of what you're about to do above.

Hold your breath, press the start button.

Flashing takes about 10 seconds. Once it's done your phone will reboot. You can close Odin at this point.

Step #7: Format partitions.

Boot into recovery.

Format EMMC: adb shell make_ext4fs mmcblk0p11

Format PRELOAD: adb shell make_ext4fs mmcblk0p12

Wipe CACHE using recovery interface (from advanced wipe screen).

Format DATA using recovery interface (special button present on wipe screen) .

Wipe INTERNAL STORAGE using recovery interface (from advanced wipe screen).

Step #8: Restore partitions.

Reboot into recovery (you must do this again after you format, and the recovery must be datamedia version if you are installing, regular version if you are uninstalling - did you follow step #5?).

... restore your /modem /system /data and /emmc partitions. /cache and /preload should not be restored.

Step #9: Modify Android ...

(I tested on a fully booted android system, but probably works from recovery too.)

Run these commands (obviously correcting the "C:datamedia_installer" path).

*********************************

** If installing from recovery **

*********************************

** mount /data **

** mount /system **

*********************************

adb root

adb push "C:datamedia_installer" /data/local/datamedia_installer

adb shell chmod 700 /data/local/datamedia_installer

To Install: adb shell /data/local/datamedia_installer install

Note: If you ever flash a new ROM in the future it will likely disable this mod. You'll have to do the Step #9 command(s) again.

To Uninstall: adb shell /data/local/datamedia_installer uninstall

Reboot.

Step #10: Adjust /data/media permissions ...

adb root

adb shell chown -R media_rw /data/media/0

adb shell chgrp -R media_rw /data/media/0

adb shell find /data/media/0 -type d -exec chmod 775 {} +

adb shell find /data/media/0 -type f -exec chmod 664 {} +

adb shell chcon -R u:object_r:media_rw_data_file:s0 /data/media/0

Congratulations, if you made it this far you're golden.

STEPS TO UNINSTALL:

Step #1: Install recovery ...

SGH-S959G_TWRP_v2.8.7.0.zip

Step #2: MD5 Verify and then Flash PIT ... (see Step #6 above)

Original_SGH-S959G.pit

Step #3: Format Partitions ... (see Step #7 above)

Step #4: Restore partitions ... (see Step #8 above)

Make sure you are using regular version, not datamedia version.

**You can optionally skip the /emmc restore at this point, and instead finish Step #5 below, then restore to /storage/sdcard0 while Android is running (not in recovery). This should (theoretically) setup the right permissions so you can skip step #6 below.

Step #5: Modify Android ... (see Step #9 above)

Only difference is the first argument for datamedia_installer script (use "uninstall")

Step #6: Adjust /mnt/media_rw/sdcard0 permissions ...

Not sure exactly what the permissions need to be, never had to do this. Let me know if you are trying to do this and I can help you troubleshoot.

**See my note in uninstall Step #4 if you are having trouble here.

XDA:DevDB Information

[PIT] SGH-S959G: Merge /data and /storage/sdcard0 (/data/media mod), Tool/Utility for the AT&T Samsung Galaxy S II SGH-I777

Contributors

dimoochka, Lanchon (thanks for the idea!)

Version Information

Status: Stable

Created 2015-10-07

Last Updated 2015-10-07