[Android One (First-Generation) Cross-Device Genera] out386:
**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://xdaforums.com/crossdevice-de...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:

Type :

parted /dev/block/mmcblk0

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

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.

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

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

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

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

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

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.

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.

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,

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,

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.