[Guide][XL][ADVANCED] Repartition internal memory (Data+SDCard0)→more space for apps

Search This thread

Kahana82

Senior Member
[Guide][XL][ADVANCED] Repartition internal memory (Data+SDCard0)→more space for apps

A lot of people are trying to extend the internal memory to install more apps after flashing Lollipop.
ART is using up more space and the /data partiton is clearly too small on our Xperia L...

It is possible to resize the /data/ partition by taking space allocated to the internal memory /SDCard0/ partition.
This guide will explain you how (for any phone)
Please read this through, so you know how to work with the commands below I used on the Xperia L.

Also read the disclaimers and precautions (backups etc) carefully before you start.

use at your own risk, I will not be held personnaly responsible for bricked phones, but will help as much as possible.
This thread has lots of information on backup/restore partitions and memblocks.

It seems flashing an official stock rom (.FTF) does not succeed in restoring the original partition table in case of problems
IT WILL MOST LIKELY BRICK YOUR DEVICE ... please stay on custom rom after this mod
Read post n°80 in this thread on how to possibly restore your phone memory (not reported as successful)


I have done this successfully by leaving only 2GB for the internal SD card partition, adding a little more than 2GB to the /data/ partition.
Feel free to adjust the partition sizes to suit your needs, just don't delete the internal SDCard partition or make it 0 in size.
After that, no more messing around with Link2SD or other methods, you can just install about anything you need normally...

The steps below were originaly posted in this thread


So, here is how it goes for our Xperia L:

Open a command window: CMD, then get into shell:
adb shell

Once in shell, type:
umount /storage
parted /dev/block/mmcblk0
print


This prints out the partition information of your phone's memory chip
You will see the partition numbers in the first column, partition names in the last one,
in between you have the start/end memory index and the partition size

------start---end---size
...
31---1795---3506---1711---userdata
32---3506---7818---4312---sdcard​
In the above output, consider the values indicated in italic as not to be changed !

Now calculate (open a spreadsheed if you like) the new value for the end of the userdata partition,
and use the same value for the start of the sdcard partition
On your sheet it should look something like this if you added 2048 to the userdata size
------start---end---size
31---1795---5554---3759---userdata
32---5554---7818---2264---sdcard​

Remove userdata and sdcard partitions:
rm 31
rm 32


Create the new userdata and sdcard partitions:
mkpartfs logical ext2 1795 5554
name 31 userdata

mkpartfs logical fat32 5554 7818
name 32 sdcard


Exit parted to go to the adb shell again:
quit


userdata partition (31) needs to have ext4 file system
The following will do the ext2->ext4 conversion:
cd /storage/sdcard1/fs-utils
tune2fs -j /dev/block/mmcblk0p31
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p31
e2fsck -fpDC0 /dev/block/mmcblk0p31


Now you can go to recovery and format the sdcard partition (default)
Then you can restore the backup you made before all this or do a clean install

Enjoy installing your apps :)
 
Last edited:

Kahana82

Senior Member
Wow this is cool!!! How much storage do you recomend we keep? 2 gigs or push it to one?
Depends on how much space you need to install your apps and what you need on the internal SD.
I found adding 2GB to be a good balance: 2GB internal SD is still ok if you don't have added an external SD.
That being said with the /data partition big enough after the resize, there will only be a few small things on that internal SD (mine has only 100MB of space used).

Only thing that comes to mind filling up the internal SD are the crash dumps when having a blue screen, which are like 1 ~ 1,5GB.
If the crash dump can't be done entirely, you'll have to remove the battery and go clean that partial file manually after you have rebooted, otherwise your internal SD will stay full.

So you can leave only 1GB or even 512 to internal SD it should work...
 
Last edited:

Kahana82

Senior Member
Thank you, i always searching how to resize the partition, and today i found your guide.
You're very welcome :)

And what if internal is fully turned into data and external sd (or external sd's second partition) is turned into internal storage?

Sent from my C2105 using XDA Free mobile app
Could work, if you like to test this.
Please report your findings, always interesting to know :good:

So my userdata and sdcard will gonna formatted right?
Yes after repartitioning you will have to format again in recovery.
 

zero995

Senior Member
Apr 4, 2013
197
61
@Kahana82
i did all steps but my phone stays in bootloop and i can't flash a ftf with flashtools


19/047/2015 02:47:13 - INFO - Selected Bundle for Sony Xperia L (C2104). FW release : 15.3.A.1.17. Customization : Gneric IN
19/047/2015 02:47:13 - INFO - Preparing files for flashing
19/047/2015 02:47:22 - INFO - Please connect your device into flashmode.
19/047/2015 02:47:23 - INFO - Opening device for R/W
19/047/2015 02:47:23 - INFO - Reading device information
19/047/2015 02:47:50 - INFO - Unable to read from phone after having opened it.
19/047/2015 02:47:50 - INFO - trying to continue anyway
19/047/2015 02:47:50 - INFO - Start Flashing
19/047/2015 02:47:50 - INFO - Processing loader.sin
19/047/2015 02:47:50 - INFO - Checking header
19/047/2015 02:47:50 - ERROR - Processing of loader.sin finished with errors.
19/047/2015 02:47:50 - INFO - Ending flash session
19/047/2015 02:47:50 - ERROR - Error in processHeader : 22 : El dispositivo no reconoce el comando.
19/047/2015 02:47:50 - ERROR - Error flashing. Aborted
19/047/2015 02:47:50 - INFO - Device disconnected
19/055/2015 02:55:31 - INFO - Device connected in flash mode
19/055/2015 02:55:33 - INFO - Device disconnected
19/056/2015 02:56:06 - INFO - Device connected with USB debugging off
19/056/2015 02:56:06 - INFO - For 2011 devices line, be sure you are not in MTP mode
 

Kahana82

Senior Member
Hi, do i need to connect the phone in recovery mode and then start adb shell? Because in this case it doesn't work for me
Yes.
Problem with drivers ?

@Kahana82
i did all steps but my phone stays in bootloop and i can't flash a ftf with flashtools


19/047/2015 02:47:13 - INFO - Selected Bundle for Sony Xperia L (C2104). FW release : 15.3.A.1.17. Customization : Gneric IN
19/047/2015 02:47:13 - INFO - Preparing files for flashing
19/047/2015 02:47:22 - INFO - Please connect your device into flashmode.
19/047/2015 02:47:23 - INFO - Opening device for R/W
19/047/2015 02:47:23 - INFO - Reading device information
19/047/2015 02:47:50 - INFO - Unable to read from phone after having opened it.
19/047/2015 02:47:50 - INFO - trying to continue anyway
19/047/2015 02:47:50 - INFO - Start Flashing
19/047/2015 02:47:50 - INFO - Processing loader.sin
19/047/2015 02:47:50 - INFO - Checking header
19/047/2015 02:47:50 - ERROR - Processing of loader.sin finished with errors.
19/047/2015 02:47:50 - INFO - Ending flash session
19/047/2015 02:47:50 - ERROR - Error in processHeader : 22 : El dispositivo no reconoce el comando.
19/047/2015 02:47:50 - ERROR - Error flashing. Aborted
19/047/2015 02:47:50 - INFO - Device disconnected
19/055/2015 02:55:31 - INFO - Device connected in flash mode
19/055/2015 02:55:33 - INFO - Device disconnected
19/056/2015 02:56:06 - INFO - Device connected with USB debugging off
19/056/2015 02:56:06 - INFO - For 2011 devices line, be sure you are not in MTP mode
Before finding out why Flashtool can't flash the FTF maybe it is best to find out what went wrong when repartitioning...
- Are you still able to enter recovery ? (if not flash thunderzap kernel with adb)
- Did you reformat the SD-Card0 in recovery ?
- Did you either restore a backup to the data partition or did a clean install when finished ?
- Can you go again like in the guide and type (to see how your partitions are at this point) :
umount /storage
parted /dev/block/mmcblk0
print
 
Last edited:

luckyshan

Member
Apr 23, 2014
6
0
@Kahana82
I followed your steps and actually got increased internal memory as u said.But now I cant flash stock rom.
I tried and once failed.Then I even cant flash a custom rom via cwm recovery :(
When I try to flash a custom or cwm restore....cwm says that it cant mount E: (any internal storage)
Plz help...................................Now phone is useless:(
I think repartitioning may solve....but adb itself says that it cant mount E:


The flashtool error messege is when trying to flash stock rom;

21/045/2015 10:45:57 - INFO - Selected Bundle for Sony Xperia L (C2105). FW release : 15.3.A.1.17. Customization : CE
21/045/2015 10:45:57 - INFO - Preparing files for flashing
21/046/2015 10:46:44 - INFO - Please connect your device into flashmode.
21/046/2015 10:46:53 - INFO - Device connected in flash mode
21/046/2015 10:46:54 - INFO - Opening device for R/W
21/046/2015 10:46:54 - INFO - Reading device information
21/047/2015 10:47:53 - ERROR - Error in processHeader : 22 : The device does not recognize the command.
21/047/2015 10:47:53 - ERROR - Error flashing. Aborted
21/047/2015 10:47:53 - INFO - Device disconnected
 

zenaufa

Senior Member
May 9, 2011
124
50
Jakarta
Tried this on blisspop nightly and thunderzap 4.14 and it's work like a charm :) i did the repartitioning with adb shell when the phone on cwm,and i need to re format the sdcard0 few times till it stable ._. when i format it first time i cant put data on it,but after reboot - format for a few times everything works like a charm :) thanks OP :3
Edit : aww,when i think it was stable the device get BSOD and keep bootlooping ._. luckly i can revert the partition table to original from adb shell in cwm ._. for people who got "device or resource busy" try to unmount the sdcard 0 from mount and storage :)
 

Attachments

  • Screenshot_2015-03-22-00-25-17.png
    Screenshot_2015-03-22-00-25-17.png
    43.4 KB · Views: 894
Last edited:
  • Like
Reactions: rostifaner

nbicalcarata

Member
Oct 27, 2014
6
1
Durango
Same problem here

@Kahana82
I followed your steps and actually got increased internal memory as u said.But now I cant flash stock rom.
I tried and once failed.Then I even cant flash a custom rom via cwm recovery :(
When I try to flash a custom or cwm restore....cwm says that it cant mount E: (any internal storage)
Plz help...................................Now phone is useless:(
I think repartitioning may solve....but adb itself says that it cant mount E:


The flashtool error messege is when trying to flash stock rom;

21/045/2015 10:45:57 - INFO - Selected Bundle for Sony Xperia L (C2105). FW release : 15.3.A.1.17. Customization : CE
21/045/2015 10:45:57 - INFO - Preparing files for flashing
21/046/2015 10:46:44 - INFO - Please connect your device into flashmode.
21/046/2015 10:46:53 - INFO - Device connected in flash mode
21/046/2015 10:46:54 - INFO - Opening device for R/W
21/046/2015 10:46:54 - INFO - Reading device information
21/047/2015 10:47:53 - ERROR - Error in processHeader : 22 : The device does not recognize the command.
21/047/2015 10:47:53 - ERROR - Error flashing. Aborted
21/047/2015 10:47:53 - INFO - Device disconnected

Did you find a solution, i have the exactly same problem
 
Jul 6, 2014
30
2
Hi! :)

First of all, thank you for sharing this post with us, I've found a general tutorial do to this, but it's very hard to follow and "convert" for my phone, this tutorial it's very easy and clear!

Only two little questions:
1) I've seen that /userdata partition start at point 1795, there is another partition that start at 0 point and end at 1794? It's OS partition?
2) I want to do this and install CM12 nightly (I've seen you wrote in that topic :p ), I need to expand /userdata partition before install CM12, or after?
 

Kahana82

Senior Member
this guide for stock kernel only, yes??
I did this with ThunderZap kernel when LP just came out in beta stage.
According to the original guide any kernel with CWM 6.0.4.6 or later will do.

Hi! :)

First of all, thank you for sharing this post with us, I've found a general tutorial do to this, but it's very hard to follow and "convert" for my phone, this tutorial it's very easy and clear!

Only two little questions:
1) I've seen that /userdata partition start at point 1795, there is another partition that start at 0 point and end at 1794? It's OS partition?
2) I want to do this and install CM12 nightly (I've seen you wrote in that topic :p ), I need to expand /userdata partition before install CM12, or after?
You're very welcome, glad it worked for you.
The numbers you see in my guide were from my phone, when I did the repartitionning. It could be that the partitions on other peoples phones are different. Userdata (/data) is partition number 31 for me and much of the 30 partitions before that are quite small in size, except for the /system partition. It is not 1 big partition in the begining on my phone.
Best is to do it before you install CM12. If you do it after you will have to take a backup of your /data partition and restore it after the resize.

[Not yet.............Still trying.......I think tha author of thi post must help :(
I'm trying to understand what went wrong, but honestly I'm a but out of my depth here.
It would help me to see how your partiton table looks like (like I asked in my previous post)
Also if from the start your partitions are different from mine, then the basic idea is to calculate the numbers for your phone's partitions and not to follow the commands blindly, which can end up messing things up if that's how it is.
The problem probably lies within the table not being ok.
Also try to unmount/remount your internal storage and format it in CWM recovery a few times, like zenaufa suggested a few posts back.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 13
    [Guide][XL][ADVANCED] Repartition internal memory (Data+SDCard0)→more space for apps

    A lot of people are trying to extend the internal memory to install more apps after flashing Lollipop.
    ART is using up more space and the /data partiton is clearly too small on our Xperia L...

    It is possible to resize the /data/ partition by taking space allocated to the internal memory /SDCard0/ partition.
    This guide will explain you how (for any phone)
    Please read this through, so you know how to work with the commands below I used on the Xperia L.

    Also read the disclaimers and precautions (backups etc) carefully before you start.

    use at your own risk, I will not be held personnaly responsible for bricked phones, but will help as much as possible.
    This thread has lots of information on backup/restore partitions and memblocks.

    It seems flashing an official stock rom (.FTF) does not succeed in restoring the original partition table in case of problems
    IT WILL MOST LIKELY BRICK YOUR DEVICE ... please stay on custom rom after this mod
    Read post n°80 in this thread on how to possibly restore your phone memory (not reported as successful)


    I have done this successfully by leaving only 2GB for the internal SD card partition, adding a little more than 2GB to the /data/ partition.
    Feel free to adjust the partition sizes to suit your needs, just don't delete the internal SDCard partition or make it 0 in size.
    After that, no more messing around with Link2SD or other methods, you can just install about anything you need normally...

    The steps below were originaly posted in this thread


    So, here is how it goes for our Xperia L:

    Open a command window: CMD, then get into shell:
    adb shell

    Once in shell, type:
    umount /storage
    parted /dev/block/mmcblk0
    print


    This prints out the partition information of your phone's memory chip
    You will see the partition numbers in the first column, partition names in the last one,
    in between you have the start/end memory index and the partition size

    ------start---end---size
    ...
    31---1795---3506---1711---userdata
    32---3506---7818---4312---sdcard​
    In the above output, consider the values indicated in italic as not to be changed !

    Now calculate (open a spreadsheed if you like) the new value for the end of the userdata partition,
    and use the same value for the start of the sdcard partition
    On your sheet it should look something like this if you added 2048 to the userdata size
    ------start---end---size
    31---1795---5554---3759---userdata
    32---5554---7818---2264---sdcard​

    Remove userdata and sdcard partitions:
    rm 31
    rm 32


    Create the new userdata and sdcard partitions:
    mkpartfs logical ext2 1795 5554
    name 31 userdata

    mkpartfs logical fat32 5554 7818
    name 32 sdcard


    Exit parted to go to the adb shell again:
    quit


    userdata partition (31) needs to have ext4 file system
    The following will do the ext2->ext4 conversion:
    cd /storage/sdcard1/fs-utils
    tune2fs -j /dev/block/mmcblk0p31
    tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p31
    e2fsck -fpDC0 /dev/block/mmcblk0p31


    Now you can go to recovery and format the sdcard partition (default)
    Then you can restore the backup you made before all this or do a clean install

    Enjoy installing your apps :)
    8
    Image of mmcblk0

    My phone got back from service, 100% stock.
    I managed to take the image from the memory chip now (see download link at the bottom of this post)

    This is what I did prior to that to prepare the phone:
    • Backuped the TA data
    • Unlocked bootloader (stuck at bootlogo after this)
    • Reflashed stock C2105_15.3.A.1.17_Customized_FR.ftf with FlashTool
    • Flashed ThunderZap 4.15 kernel
    • Performed Full cleanup as to install a new ROM
    • Formatted the external SDCard as EXT3 to accomodate the 8GB image file
    • Partition table and all the rest on the phone is still stock


    Then I made the image of mmcblk0

    In Recovery go to mount & storage and mount /storage/sdcard1
    Then in command window:
    adb shell
    stty raw
    dd if=/dev/block/mmcblk0 of=/storage/sdcard1/backup.img bs=4096
    exit
    adb pull -p /storage/sdcard1/backup.img %USERPROFILE%\Desktop\backup.img




    In reverse, to restore the image the commands are :
    Remark: be patient. Transfer times between the PC and the phone's external SDCard take up a long time.

    In Recovery go to mount & storage and mount /storage/sdcard1
    Then in command window:
    adb shell
    adb push -p %USERPROFILE%\Desktop\backup.img /storage/sdcard1/backup.img
    stty raw
    dd if=/storage/sdcard1/backup.img of=/dev/block/mmcblk0 bs=4096
    exit


    Hope this will save a few pohones :)

    269Mb rar archive with inside 7,8GB mmcblk0.img file:
    mmcblk0.rar
    2
    Yeah I saw that, but it will backup the data inside the partition!! What I want to do is back up the partition table itself.. Or else backing up mmcblk0.. Is it possible? On the post just above this someone spoke about adb pull command, and i checked in the main thread also as you have mentioned but there is not information about adb pull....

    with adb from pc(adb debugging enable?) do:

    adb pull /dev/block/mmcblk0 mmcblk0.img



    Sent from my C2105 using XDA Free mobile app
    1
    this thing can be done on windows or linux only?
    I did this in windows using ADB (from Android dev-kit) in MS-Dos console (cmd.exe)
    1
    This for people that don't have hard bricked phones:
    If you done with this, you may flash STOCK ROM! BUT
    Exclude partitions.sin then flash, but if you didn't do this - hardbrick :D

    Or make stock firmware that already exlcuded stock partition table