21

I need to increase the size of my Galaxy S 2's /system partition from 503.4MB to... Well, anything possible.

The (main) reason why I want to do this is because I want to install GApps 20140606, which is not compatible with devices with small (under 500MB) /system partitions.

The Galaxy S 2's internal storage is 16GB but I mostly use my SD card, so I don't really care how much of this will be taken to use in the /system partition.

I've found a lot of pages explaining different methods to achieve this, like this one from TechoTV, and this one from XDA, but all of them were phone-specific and never gave the information if it would be compatible with other models or not, or they would resize to a specific set size.

There's also this question from Android SE, but the answer weren't satisfactory enough for me, as the author limited himself to only say that it is possible, but not saying how.

To add a few more information, the phone is rooted and with CyanogenMod 11 (20140806-NIGHTLY), which is Android 4.4.4.

It would be interesting if the information provided works under Linux. I have access to Windows but rather not have to use it.

Aren't there any simple way of resizing the partitions, like GParted (but for Android)?

  • 1
    Just to add that I managed to resize it successfully. I will write an answer explaining in details how to do it. It is not complicated. – Bruno Finger Aug 22 '14 at 19:47
  • 1
    Did you ever have a chance to write that answer? I'm also interested in re-partitioning my S2. Thanks – Mikeage Aug 26 '14 at 9:36
  • @Mikeage Sorry about that, I think I own the community this answer now that I made this comment... I am writting it right now, check it back soon :) – Bruno Finger Aug 26 '14 at 14:02
  • 1
    @Mikeage check the answer and good luck ;) – Bruno Finger Aug 26 '14 at 15:44
21

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.

  • What if I need to do in a different phone?. Is there any generic tool or method? – skan Jul 31 '15 at 19:04
  • Unfortunately it seems not. I also searched very hard for it but I couldn't find. I can't tell if it's because it hasn't been made yet or because every phone or manufacturer has its own partitioning architecture. The perfect way would be a tool as easy to use as GParted but I don't expect to see that for Android any time soon. – Bruno Finger Jul 31 '15 at 19:08
  • What about modifying the Firmware image file before burning it on the phone? – skan Aug 1 '15 at 10:31
10

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.

  • This is the best answer on the net I have read so far! I knew there had to be a way avoiding reinstalling the stock ROM. Thanks so much! All other answers are either badly written, lacking important stuff or do superfluous things +1! – Sebastian Apr 12 '15 at 13:07
  • I like it better than having to install stock rom again. I'll give this a try. – Milan Maharjan Jul 7 '15 at 8:58
  • Thanks for the tutorial but I got 'Error mounting.. " at the end of step 11 and the phone died :-( (by the way, step 7 was very quick) – ItayB Dec 3 '15 at 17:28
  • Error mounting /storage/sdcard0.,android_secure! Skipping format... Can't mount /storage/sdcard0/.android_secure! – ItayB Dec 3 '15 at 18:48
  • I've tried to format /storage/sdcard0 and perform from step 11 again.. It's end without the mounting error (got Restore complete!) but still black screen on reboot.. – ItayB Dec 3 '15 at 21:13
4

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

  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

  • An edit was proposed to this that I think should be a comment: "For cm13 you have to pick ext4 or any other linux filesystem. Otherwise your internal storage will not work." – Matthew Read May 15 '16 at 6:05
  • I formatted /system, /data, /cache, etc as ext4. But when I formatted internal storage as ext4 it consistently became corrupt. This happened for me on CM 12.1 as well as CM 13. I reformatted as vfat and again as exfat and my problems went away. I found a couple other sources that said the same thing: (1) (2) – bmaupin May 15 '16 at 19:03
  • @Patrick I clarified my answer and added sources. Thanks for pointing that out! – bmaupin May 16 '16 at 11:34
1

Here's what's probably an even better way: https://github.com/Lanchon/REPIT

It's as easy as flashing a zip and preserves data. Requires TWRP recovery and patience. Worked first time for me on an S2 (i9100) that already had CM13.

  • Doesn't seem to work for some reason. Flashed one of those zips using TWRP. Recovery complained that I should run it again from tmp. I run it again, recovery restarts after a few seconds. Still unable to flash OpenGApps. – Hugo Zink Nov 11 '16 at 21:48
  • Not sure what's happening there @HugoZink - you should probably save some screenshots/logs & report the issue at REPIT's github. – eug Nov 13 '16 at 23:32

protected by Community Jan 4 '15 at 4:13

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.