• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[Guide] Repartition internal storage to get more space on /data

Search This thread

out386

Senior Member
Sep 2, 2014
106
96
**DISCLAIMER**
**I WILL NOT BE RESPONSIBLE IF YOUR PHONE DIES.**
**PROCEED AT YOUR OWN RISK**
**IF YOU MESS UP, USE SP FLASH TOOLS TO FLASH ROM IN THE FORMAT ALL+ DOWNLOAD MODE**

A lot of space in the internal storage in sprout4 devices is wasted. This will give you a bit more space in userdata. I put this guide in Android One General, but this will apply to most devices. At least to those devices that use GPT partitions like the Sprouts do.
Requirements:
An Android device (duh)
TWRP Materialized by musfiqus, from here: http://forum.xda-developers.com/cro...p-materialised-twrp-recovery-android-t3088715 It includes the Parted binary. Some other builds of TWRP don’t have that. You need it.
Something resembling intelligence
Patience
A PC (Windows , Linux, Mac, whatever) is optional. The instructions here use a PC, but if you don’t have one, you can type commands in TWRP terminal).
ADB drivers, if you’re using a PC.
A hardware calculator. Using an on-screen calculator so many times is going to get you to go Hulk.

Here’s how to do it.
Reboot to TWRP recovery, and open a terminal / Command Prompt. Take a backup of IMEI.
Type:
adb shell
You’ll get a screen like this:
image.png

Type :
parted /dev/block/mmcblk0
image.png


By default, Parted uses MB as the storage unit. To prevent possible unused space after repartitioning, we’ll use sectors as a unit instead.
Type
unit s
This’ll change to sectors.

Type
print

It’ll give a warning, just type
i
Then:
print free

image.png


At the top, you’ll see that the sector size is written. Write this number down somewhere. For my Android One 4GB, the sector size is 512 bytes.
Now, you need to understand what the list means. Each horizontal row shows the details of a partition.
The 1st column shows the partition number.
The 2nd column shows the start offset of that partition. That means that the partition starts at the location mentioned.
The 3rd column shows where the partition ends. Notice that each partition starts exactly 1 sector after the previous one ends.
The 4th column is obviously the size of the partition.
The 5th column is the file system used by the partition. If nothing is written in this column, that means that it’s a binary partition.
The 6th column is the partition name.

You’ll see that the sizes in that list are weird. They’re not in any standard unit you might know. That’s because we used sectors instead of megabytes. The ‘s’ after each number indicates that it’s in sectors. (You can use the default MB unit (1MB=1000 KB. 1KB=1000bytes), or the MiB unit (1MiB=1024 KiB), but that just might leave 1 or 2 MB of space unused. So, I’m using sectors).
Remember that 1 sector = 512 bytes for my phone.

There’s some free space at the top and bottom of the list. Leave that free space there. Do not make partitions using those.

To convert sectors to MiB or KiB:
1s = 512bytes (Use the sector size you wrote down previously for this step, it might not be 512 bytes for you)

1024 bytes = 1 KiB
1024 KiB = 1 MiB
1024 MiB = 1GiB

So, 4833280s = (4833280 x 512) B = 2474639360 B
= (2474639360 / 1024) KiB = 2416640 KiB
= (2416640 /1024) MiB = 2360 MiB
= (2360 / 1024) GiB = 2.30 GiB

We’ll use another terminal window with sizes in MiB now. So open another Parted prompt in a new terminal / command prompt window, but instead of
unit s,
this time, write
unit MiB
Type “print”, “i”, and “print free” again.

image.png


Look at my 11th partition. Its size is 8MiB. I know that this logo partition doesn’t need more than 2 MiB. So, I’ll make it smaller.
When you make partitions smaller, all the data inside will be lost. So, we need to back up the partitions first.
Open a 3rd terminal window. Type
adb shell dd if=/dev/block/mmcblk0p11 of=/microSD/p11
The “dd” command copies bytes from the “if=” location, to the “of=” location. The internal storage is /dev/block/mmcblk0. The “p11” after that refers to the partition we are backing up. Notice that in the Parted list, “logo” has a partition number of “11”. So the general command to back up partitions is
adb shell dd if=/dev/block/mmcblk0p<partition_number> of=/microSD/p<partition_number>
From recovery, unmount all partitions except microSD and oem. Then back up partitions 11, and 13 from PC. We will copy the files from OEM instead of using dd. So type
adb shell mkdir /microSD/oem
adb shell cp –a /oem/ /microSD/oem
Go to /microSD/oem/oem/app with TWRP’s file manager, and delete everything there.

Open the 1st terminal with sizes in sectors.
Type
rm 11
This will delete the oem partition. Type
print free

image.png


Partition 11 has been replaced with free space. Let’s make the Logo partition 2MiB. 2MiB = 4096s. The start sector is 113920, so the end sector needs to be (113920 + 4096 - 1) = 118015.
The command to create partitions is:
mkpart <name> <start_sector> <end_sector>
name <partition_number> < name>
So, type:
mkpart logo 113920s 118015s
name 11 logo

image.png


Some free space has appeared below logo. If you type “print free” on the 2nd terminal, with units set to MiB,

image.png


You’ll see that logo is now only 2 MiB, and an extra 6 MiB of free space is available. Also, oem takes 64 MiB. Open the 3rd terminal, from which you took backups, and type
adb shell df /oem

image.png


Divide the number under “used” with 1024. That’ll tell you how much space is being used. My oem partition is 64 MiB, but it’s only using about 6MiB. Typical. Not all space in the partition is available for file storage, so I’ll make the oem partition 11 MiB.
Unmount oem from recovery. Open the 1st terminal window, with sizes in sectors.
Type
rm 12
print free

image.png


11MiB = 22528s. new End size will be (118016 + 22528 - 1)s = 140543s
Type
mkpart oem 118016s 140543s
name 12 oem
Look at the 1st partition listing in this post. Oem had a ext4 file system. Open the 3rd terminal window. Type:
adb shell make_ext4fs /dev/block/mmcblk0p12
This will make an ext4 file system. Type “print free” in the MiB terminal. Things look good. Copy back the contents of oem. Mount oem from recovery, and type:
adb shell cp -a /microSD/oem/oem/* /oem/
If you get out of space errors, delete oem, and make it a bit larger. Now type:
adb shell chown root:root /oem/oem.prop
adb shell chmod 644 /oem/oem.prop
This will fix permissions of oem.prop.

image.png


I won’t change sizes of partition 13. So I’ll make it occupy 33536s from location 140544s. End sector will be (134400 + 33536 – 1)s = 174079s. So do it like the last two times. If you want to change the size of system, read my next post below first. I suggest that you keep the size of system intact. So, delete system, make it again just after expdb, and make an ext4 file system in it, like you did for oem.
Cache is about 128MiB big, but you just need it to be 5MiB. Any more is a waste. Delete cache, make it again right below system, with a size of 5MiB, and make an ext4 file system in it. This is what my partition table looks like after doing that.

image.png


image.png


So, after all that insanity, I just gained a tiny 182MiB of space. I’m not sure about the gen partition, and metadata is apparently used for encrypting data, so I’ll leave those two untouched. In my screenshots, userdata doesn’t have any file system, but that’s because I just unlocked my bootloader. Userdata is usually ext4. So, I’ll delete userdata,

image.png


and make userdata again. No need to calculate the end size again, as userdata will occupy all the free space, start sector will be 2232320s and end sector will be 7438335s. Then put an ext4 file system on userdata,

image.png


and done!
Now restore the partition 11 and 13 backup. If partition 11 gives an error, just ignore it.
dd if=/microSD/p11 of=/dev/block/mmcblk0p11
dd if=/microSD/p13 of=/dev/block/mmcblk0p13
Now reboot recovery, flash a new rom, restore IMEI, and reboot. Read the next post to get more space.
 

Shybet

Member
Mar 13, 2009
37
8
Waingapu
Great tutorial.
Just a little question. I'm sprout8 users, but i use sprout 4 rom. And in sprout4, the default data storage is on external memory (SDCard). The internal memory (userdata) is hidden (on rooted device, i can acces it in data/media/0/)
I think is a waste of space just to let 5.75 GB space only to be hidden.
the question: Can i convert the user data partition to make the system partition a little bigger?
 
Last edited:

out386

Senior Member
Sep 2, 2014
106
96
Great tutorial.
Just a little question. I'm sprout8 users, but i use sprout 4 rom. And in sprout4, the default data storage is on external memory (SDCard). The internal memory (userdata) is hidden (on rooted device, i can acces it in data/media/0/)
I think is a waste of space just to let 5.75 GB space only to be hidden.
the question: Can i convert the user data partition to make the system partition a little bigger?
Yes, definitely. Just delete userdata, then make it again with a smaller size, delete system, and put the free space in system. Then make the ext4 volumes on them.
 

out386

Senior Member
Sep 2, 2014
106
96
1) I had intended to make a flashable zip. But I was too lazy to make one. I'll make it soon.
2) A flashable zip might actually be more risky than this manual method.
3) Unlock your phone's bootloader, and install MTK Vcom drivers, then SP Flash will recognize it.
 

wb407

New member
Nov 7, 2010
2
0
How to backup IMEI?

Hi. Sorry if this is a noob question. In the article, the first and last steps are to backup/recover the IMEI. Is this done by backing up the "nvram" partition?

ex (backup):
adb shell dd if=/dev/block/mmcblk0p2 of=/microSD/nvram.img
adb pull /microSD/nvram.img

ex (restore):
adb push nvram.img /microSD
adb shell dd if=/microSD/nvram.img of=/dev/block/mmcblk0p2

or is there more to it than that?
 

actyon20

New member
Oct 26, 2016
2
0
After I boot in TWRP it says error: "no devices/emulators found". Can you please help me ? I love my cheap phone , I just want to make the system partition a little larger so that I can add some extra apps
 

out386

Senior Member
Sep 2, 2014
106
96
After I boot in TWRP it says error: "no devices/emulators found". Can you please help me ? I love my cheap phone , I just want to make the system partition a little larger so that I can add some extra apps
It says that on PC? That probably means that you didn't install the ADB drivers. Google for "Minimal ADB XDA", and download it from there. Then it should work.

If not, run all the commands in this post from TWRP - > Advanced - > Terminal (no need for PC).

By the way, a larger data partition = more user apps (from Play Store, etc). Larger system = more system apps (not usually needed).
 

out386

Senior Member
Sep 2, 2014
106
96
Great tutorial!
But how do I restore everything back to normal?
Should I undo the steps or just restoring a TWRP Backup will do?
To undo, you can just flash with SP Flash using the format + download mode.

However, many devices have been getting bricked by SP Flash lately. So I suggest repeating the steps in this post, but use the original offsets and sizes. That will also undo it.
 
  • Like
Reactions: CSAkshay

out386

Senior Member
Sep 2, 2014
106
96
Hi. Sorry if this is a noob question. In the article, the first and last steps are to backup/recover the IMEI. Is this done by backing up the "nvram" partition?

ex (backup):
adb shell dd if=/dev/block/mmcblk0p2 of=/microSD/nvram.img
adb pull /microSD/nvram.img

ex (restore):
adb push nvram.img /microSD
adb shell dd if=/microSD/nvram.img of=/dev/block/mmcblk0p2

or is there more to it than that?
Actually, I'm not exactly sure. :)

It didn't work for me, so I had to use the IMEI fix zip from these forums to rewrite the IMEI.
 

actyon20

New member
Oct 26, 2016
2
0
It says that on PC? That probably means that you didn't install the ADB drivers. Google for "Minimal ADB XDA", and download it from there. Then it should work.

If not, run all the commands in this post from TWRP - > Advanced - > Terminal (no need for PC).

By the way, a larger data partition = more user apps (from Play Store, etc). Larger system = more system apps (not usually needed).

First of all , thanks a lot for the reply.
Second , yes , I tried that from pc with windows 10 64-bit.
My steps:
1. From my phone I enabled debugging.

2. I downloaded "android-sdk_r24.4.1-windows.zip" from //developer.android.com/studio/index. After I launch SDK Manager I installed:
*Android SDK Tools
*Android SDK Platform-Tools
*Google USB Drive
At Environment Variables at Path I added ;C:\android-sdk\tools;C:\android-sdk\platform-tools
When I type "adb" in cmd a long list appears.

3. I downloaded some "ADB Drivers_Updated" and I go in that folder , Open new cmd+shfit and I type "adb shell" and the next text appears ( without lines )
[email protected]_P4Life:/ $-----------------

BEFORE this you said that I must root in TWRP so I google it and I did the following steps :
1. Went in C:\android-sdk\platform-tools
2. Open new cmd+shift and I type "adb reboot recovery" the phone reboots and the next image appears:
//i.imgur.com/JLWdPXU.jpg

After this I'm lost because when I type abd shell in cmd it says "/no emulators found..."

I want to make a bigger partition for "system content apps" because even if I have ~5GB internal memory remaining I saw that there is a 1GB partition that when it's full (programs registry or I don't know what ) you can't install program anymore even if you have an empty SD card attached and the Default Write option in system is set to SD card.

Can you please help me ? This is my first time doing this and my phone is Allview P4 Life . I really like that cheap phone.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 30
    **DISCLAIMER**
    **I WILL NOT BE RESPONSIBLE IF YOUR PHONE DIES.**
    **PROCEED AT YOUR OWN RISK**
    **IF YOU MESS UP, USE SP FLASH TOOLS TO FLASH ROM IN THE FORMAT ALL+ DOWNLOAD MODE**

    A lot of space in the internal storage in sprout4 devices is wasted. This will give you a bit more space in userdata. I put this guide in Android One General, but this will apply to most devices. At least to those devices that use GPT partitions like the Sprouts do.
    Requirements:
    An Android device (duh)
    TWRP Materialized by musfiqus, from here: http://forum.xda-developers.com/cro...p-materialised-twrp-recovery-android-t3088715 It includes the Parted binary. Some other builds of TWRP don’t have that. You need it.
    Something resembling intelligence
    Patience
    A PC (Windows , Linux, Mac, whatever) is optional. The instructions here use a PC, but if you don’t have one, you can type commands in TWRP terminal).
    ADB drivers, if you’re using a PC.
    A hardware calculator. Using an on-screen calculator so many times is going to get you to go Hulk.

    Here’s how to do it.
    Reboot to TWRP recovery, and open a terminal / Command Prompt. Take a backup of IMEI.
    Type:
    adb shell
    You’ll get a screen like this:
    image.png

    Type :
    parted /dev/block/mmcblk0
    image.png


    By default, Parted uses MB as the storage unit. To prevent possible unused space after repartitioning, we’ll use sectors as a unit instead.
    Type
    unit s
    This’ll change to sectors.

    Type
    print

    It’ll give a warning, just type
    i
    Then:
    print free

    image.png


    At the top, you’ll see that the sector size is written. Write this number down somewhere. For my Android One 4GB, the sector size is 512 bytes.
    Now, you need to understand what the list means. Each horizontal row shows the details of a partition.
    The 1st column shows the partition number.
    The 2nd column shows the start offset of that partition. That means that the partition starts at the location mentioned.
    The 3rd column shows where the partition ends. Notice that each partition starts exactly 1 sector after the previous one ends.
    The 4th column is obviously the size of the partition.
    The 5th column is the file system used by the partition. If nothing is written in this column, that means that it’s a binary partition.
    The 6th column is the partition name.

    You’ll see that the sizes in that list are weird. They’re not in any standard unit you might know. That’s because we used sectors instead of megabytes. The ‘s’ after each number indicates that it’s in sectors. (You can use the default MB unit (1MB=1000 KB. 1KB=1000bytes), or the MiB unit (1MiB=1024 KiB), but that just might leave 1 or 2 MB of space unused. So, I’m using sectors).
    Remember that 1 sector = 512 bytes for my phone.

    There’s some free space at the top and bottom of the list. Leave that free space there. Do not make partitions using those.

    To convert sectors to MiB or KiB:
    1s = 512bytes (Use the sector size you wrote down previously for this step, it might not be 512 bytes for you)

    1024 bytes = 1 KiB
    1024 KiB = 1 MiB
    1024 MiB = 1GiB

    So, 4833280s = (4833280 x 512) B = 2474639360 B
    = (2474639360 / 1024) KiB = 2416640 KiB
    = (2416640 /1024) MiB = 2360 MiB
    = (2360 / 1024) GiB = 2.30 GiB

    We’ll use another terminal window with sizes in MiB now. So open another Parted prompt in a new terminal / command prompt window, but instead of
    unit s,
    this time, write
    unit MiB
    Type “print”, “i”, and “print free” again.

    image.png


    Look at my 11th partition. Its size is 8MiB. I know that this logo partition doesn’t need more than 2 MiB. So, I’ll make it smaller.
    When you make partitions smaller, all the data inside will be lost. So, we need to back up the partitions first.
    Open a 3rd terminal window. Type
    adb shell dd if=/dev/block/mmcblk0p11 of=/microSD/p11
    The “dd” command copies bytes from the “if=” location, to the “of=” location. The internal storage is /dev/block/mmcblk0. The “p11” after that refers to the partition we are backing up. Notice that in the Parted list, “logo” has a partition number of “11”. So the general command to back up partitions is
    adb shell dd if=/dev/block/mmcblk0p<partition_number> of=/microSD/p<partition_number>
    From recovery, unmount all partitions except microSD and oem. Then back up partitions 11, and 13 from PC. We will copy the files from OEM instead of using dd. So type
    adb shell mkdir /microSD/oem
    adb shell cp –a /oem/ /microSD/oem
    Go to /microSD/oem/oem/app with TWRP’s file manager, and delete everything there.

    Open the 1st terminal with sizes in sectors.
    Type
    rm 11
    This will delete the oem partition. Type
    print free

    image.png


    Partition 11 has been replaced with free space. Let’s make the Logo partition 2MiB. 2MiB = 4096s. The start sector is 113920, so the end sector needs to be (113920 + 4096 - 1) = 118015.
    The command to create partitions is:
    mkpart <name> <start_sector> <end_sector>
    name <partition_number> < name>
    So, type:
    mkpart logo 113920s 118015s
    name 11 logo

    image.png


    Some free space has appeared below logo. If you type “print free” on the 2nd terminal, with units set to MiB,

    image.png


    You’ll see that logo is now only 2 MiB, and an extra 6 MiB of free space is available. Also, oem takes 64 MiB. Open the 3rd terminal, from which you took backups, and type
    adb shell df /oem

    image.png


    Divide the number under “used” with 1024. That’ll tell you how much space is being used. My oem partition is 64 MiB, but it’s only using about 6MiB. Typical. Not all space in the partition is available for file storage, so I’ll make the oem partition 11 MiB.
    Unmount oem from recovery. Open the 1st terminal window, with sizes in sectors.
    Type
    rm 12
    print free

    image.png


    11MiB = 22528s. new End size will be (118016 + 22528 - 1)s = 140543s
    Type
    mkpart oem 118016s 140543s
    name 12 oem
    Look at the 1st partition listing in this post. Oem had a ext4 file system. Open the 3rd terminal window. Type:
    adb shell make_ext4fs /dev/block/mmcblk0p12
    This will make an ext4 file system. Type “print free” in the MiB terminal. Things look good. Copy back the contents of oem. Mount oem from recovery, and type:
    adb shell cp -a /microSD/oem/oem/* /oem/
    If you get out of space errors, delete oem, and make it a bit larger. Now type:
    adb shell chown root:root /oem/oem.prop
    adb shell chmod 644 /oem/oem.prop
    This will fix permissions of oem.prop.

    image.png


    I won’t change sizes of partition 13. So I’ll make it occupy 33536s from location 140544s. End sector will be (134400 + 33536 – 1)s = 174079s. So do it like the last two times. If you want to change the size of system, read my next post below first. I suggest that you keep the size of system intact. So, delete system, make it again just after expdb, and make an ext4 file system in it, like you did for oem.
    Cache is about 128MiB big, but you just need it to be 5MiB. Any more is a waste. Delete cache, make it again right below system, with a size of 5MiB, and make an ext4 file system in it. This is what my partition table looks like after doing that.

    image.png


    image.png


    So, after all that insanity, I just gained a tiny 182MiB of space. I’m not sure about the gen partition, and metadata is apparently used for encrypting data, so I’ll leave those two untouched. In my screenshots, userdata doesn’t have any file system, but that’s because I just unlocked my bootloader. Userdata is usually ext4. So, I’ll delete userdata,

    image.png


    and make userdata again. No need to calculate the end size again, as userdata will occupy all the free space, start sector will be 2232320s and end sector will be 7438335s. Then put an ext4 file system on userdata,

    image.png


    and done!
    Now restore the partition 11 and 13 backup. If partition 11 gives an error, just ignore it.
    dd if=/microSD/p11 of=/dev/block/mmcblk0p11
    dd if=/microSD/p13 of=/dev/block/mmcblk0p13
    Now reboot recovery, flash a new rom, restore IMEI, and reboot. Read the next post to get more space.
    2
    daemon started successfully P*
    error: device not found
    error: device not found
    Install adb drivers for your phone. You need both adb itself and the drivers. Get it here http://forum.xda-developers.com/showthread.php?t=2588979
    1
    Nice thread dude, :) though awesome tutorial
    1
    Yes, many times.