Android - Resize /system partition of Galaxy S 2

Firstly and most important, the credits:

I made this following this great tutorial at XDA-Developers by user metalgearhathaway: http://forum.xda-developers.com/galaxy-s2/development-derivatives/mod-partition-internal-memory-app-t2538947

I used PIT files (I'll explain what they are, don't worry) made from user ElGamal from XDA also, located here (comment number 509).

And a little bit of help from user CrackDaddy, also from XDA.

Second, what you'll need:

  • A machine running Windows. I used Windows 7 Ultimate 64-bits;
  • Odin 3.07. Careful when installing, it is full of optional AdWares. There's also a Linux and Mac version available called JOdin3, but I didn't try it;
  • Flashable ClockWorkMod 6 for Galaxy S II (it is a .tar file with a file named zImage inside);
  • PIT file with desired partition table configuration;
  • Samsung drivers for Galaxy S2. Usually you can install Samsung Kies but there's also a installer just with drivers available;
  • Your original stock unrooted Samsung Jellybean firmware. You can find it at sammobile.com;
  • Any ROM of your choice. I highly recommend the last nightly build of Cyanogenmod 11;
  • Optionally: GApps 20140606 or newer.

I made most of those available in the following bundle file: https://drive.google.com/open?id=0BxccpydIocBpd21FOE5MaGJiMkU&authuser=0

What is missing is GApps, CyanogenMod, and a stock Samsung JellyBean ROM (as it depends of country and carrier, and might not be legal to provide it here).

Third, the default warning:

I am not responsible for anything that might go wrong with your device, neither any of the mentioned users nor anyone here at Stack Overflow or XDA-Developers. This procedure will root your phone if it isn't already and also void your warranty if it isn't already. If anything goes wrong, don't panic, it is most likely fixable by reflashing the stock ROM and starting over again.

Finally, how to:

This will only work with the 16GB International version (GT-I9100) of Samsung Galaxy S II

Firstly, copy CyanogenMod 11 .zip file (or your desired ROM) and optionally GApps .zip file to your external SD card;

Make a backup of everything inside your internal storage, copy it to your computer or somewhere else. It will be completelly erased. Don't worry about your external SD Card, it won't be touched.

Make a NAnd backup of your current ROM, you'll be able to restore it after the repartition. To do it, you must have ClockWorkMod recovery installed, then boot your phone into recovery mode (Volume UP + Home + Power), select backups and restore, then backup to /storage/sdcard1;

When backup finishes, reboot your phone into Download mode (Volume DOWN + Home + Power) and connect your phone to the computer. Let Windows install the drivers. If it fails, try to install Samsung Kies or just the drivers provided in the bundle I made available, and try again.

Open Odin3 as Administrator and connect the phone. It should detect your phone and show it under the label ID:COM, and also in the Message. If it didn't, try to restart your computer, phone, reinstall drivers, check your USB cable, etc., and try again.

Now you'll need to choose a PIT file. PIT means Partition Information Table and it is a Samsung-only thing. In the bundle file, I made available ElGamal's PIT file (I91001GB_6GB.pit) which also resizes /system partition to 1GB, /data to 6GB and the rest goes to internal storage. If you wish different sizes, check the thread at XDA-Developers as he made many different versions available. I also included a PIT file for the default configuration (I9100_2GB-STOCK.pit) if you wish to go back to as it was later.

When you have chosen your PIT file, go to Odin and tick the following checkboxes: Re-Partition, Auto Reboot and F. Reset Time. In the Re-Partition section, click on the PIT button and select your chosen PIT file. In the Files (Download) section, click on the AP button and select Samsung's stock JellyBean ROM. Double check everything and click Start. This can take a while, go grab a coffee.

After everything finishes, your phone will reboot into the stock Samsung JellyBean ROM. Two things can happen now, or it will work normally and if so you can use it and check if everything is as you want. Or it can ask you for a password to access the "encrypted volume", which is nothing but your internal storage that is not formatted. In both ways, unplug your phone (it it's still plugged) and reboot it into Download mode again.

It is interesting to close and reopen Odin3 to reset the settings. Plug your phone again and wait until Odin3 detects it. This time, leave checked just Auto Reboot and F. Reset Time and make sure Re-Partition is NOT checked. Click on AP button and select the ClockWorkMod Recovery .tar file, then click Start. This one is faster, but if you feel sleepy, go for another coffee ;)

When it finishes, you should have ClockWorkMod Recovery 6 installed in your phone, so go ahead and reboot into Recovery mode. Go to mounts and storage, select format /storage/sdcard0 and format it as exfat (if for some reason you have write problems in your internal storage later, come back here and select another format until it works, but exfat should do the trick).

When it finishes, still in Recovery mode, Wipe data/factory reset, Wipe cache and Wipe Dalvik cache. Let's be sure nothing remains from the previous ROMs.

Now, install zip -> choose zip from /storage/sdcard1 and select the CyanogenMod 11 .zip file (or of your desired ROM) and flash it. Optionally also flash GApps afterwards. Reboot your phone and check if everything is right.

If everything is right, reboot your phone into Recovery mode again, do a new wipe data/factory reset, wipe cache and wipe Dalvik cache, and then recover your backed up ROM from the beginning. Reboot your phone.

Check again if everything works right. A few apps might need to be reinstalled (Spotify and Waze are examples) to work correctly again, but that's be only major issue.

Hope everything goes well.


Kudos to @Bruno for a detailed solution and needed files. A much quicker method is listed below, which does not require installing any ROM/Gapps or reboot into the ROM in between steps. You need an external SD card with enough free space to hold all apps+data+photos+etc that are on your internal phone storage.

You can skip steps 1-5 if you already have CWM and also a NAND backup on your external SD card already (but make sure you have a NAND backup on your external SD or else you'll lose all data).

NOTE: You should backup your data from your internal SD card too in case things go awry, i.e. /storage/sdcard0 (a NAND backup does not back that up).

  1. Extract the files provided by @Bruno somewhere on your pc.
  2. Reboot phone in download mode (vol down + home + power) then connect it to the pc via USB.
  3. Start Odin 3.09. Uncheck Auto-Reboot, put the CWM-KitKatCompatible-i9100.tar file in the AP section, then click Start and wait until Odin says "RES OK !!" in the Message log. This should be fairly quick, a few seconds.
  4. Now reboot the phone in recovery mode (vol up + home + power)
  5. Go to backup and restore > backup to /storage/sdcard1 -- note the 1, not 0 (your CWM may say "external sd" instead of /storage/sdcard1; just chose the backup option corresponding to the external SD card, this is important, otherwise you'll lose all data). Wait for the backup to finish, this will take a while.
  6. Reboot phone into download mode (vol down + home + power)
  7. Start Odin 3.09, Uncheck Auto-Reboot, check Re-Partition, put the file I91001GB_6GB.pit in the PIT section, put the file CWM-KitKatCompatible-i9100.tar in the AP section, then click Start and wait until Odin says "RES OK !!" in the Message log. This will take a while.
  8. Reboot phone into recovery mode (vol up + home + power)
  9. Go to mounts and storage > Format /system, then Format /cache, then Format /data
  10. Go back to wipe data/factory reset
  11. Go back to backup and restore > restore from /storage/sdcard1 and restore the NAND backup made previously
  12. Done. Reboot phone normally.

Procedure tested with Cyanogenmod 11 (KitKat 4.4) nightly and snapshot. Should work with any recent ROM. No need to install any custom or stock ROMs or Gapps or even boot into the ROM in between steps.

DISCLAIMER: I can't be held responsible if your phone starts singing or dancing Lambada (oh how I hate that song!), calls you names, blows up, loses any of your data etc.


In my case, I needed a cross-platform solution since I use Linux. Here's what worked for me:

  1. Back everything up. This will wipe everything on the phone, including the internal SD card.

  2. Download:

    • A PIT file you want to flash. I used this one, which resizes /system from 512 MB to 1 GB and /data from 2 GB to 6 GB
    • Any compatible recovery. I used this one
    • (Optional) A ROM you want to install. I installed CyanogenMod 13 nightly
  3. Download and install Heimdall

    • Ubuntu: sudo apt install heimdall-flash
    • Others: https://bitbucket.org/benjamin_dobell/heimdall/downloads
  4. Boot to download mode

    1. Unplug the USB cable
    2. Power off
    3. Press and hold the volume down, home, and power buttons (you can let go once you see the warning screen)
    4. Press the volume up button to continue past the warning screen
  5. Connect the USB cable to your phone and PC

  6. (Optional) Back up the existing PIT

    sudo heimdall download-pit --output i9100-stock.pit --no-reboot
    
  7. Flash the new PIT and recovery

    sudo heimdall flash --repartition --pit I91001GB_6GB.pit --KERNEL cwmr6047.img --no-reboot
    
  8. Boot to recovery

    1. Unplug the USB cable
    2. Power off
    3. Press and hold the volume up, home, and power buttons (you can let go once you see the I9100 screen)
  9. Format all partitions, including /system, /data, /cache, and the internal SD card (sdcard0)

    • When formatting the internal SD card, if it asks you what filesystem to use pick fat, vfat, or exfat. If you pick ext4 you will have problems. (Sources: [1] [2])
    • For all other partitions pick ext4 if asked
  10. Install the ROM or restore your backup