Mi2S - extending size of storage partition


stillka

Members
Aug 31, 2011
145
50
Hello,
I have facing problem with (for me) not very optimal partition layout of MI2S 16GB.

/data partition was too big (around 3GB of free space after all my applications installed) and /storage partition too small (9GB is not too much, few 1080p videos, offline GPS navigation maps, few MP3 albums and you are done).

So, I decided to change partition layout in this way - remove 2,5GB from /data and add them to /storage (/sdcard) partition.

If is somebody interested, here is how-to:

Prerequisites:
- CWM is installed and complete System1 backup is done
- connection to phone from PC over adb is functional in CWM
- OS backup with all other user data is copied to computer (whole internal storage)


Notice: /data and /sdcard partitions will be removed and re-created with new size, you have to restore all your data from the computer when finished
Characters after #(including #) are my comments, don't type them into adb command line!
command you have enter are marked red.


Preparation:
- copy content of partition_tools.zip into /system/bin and add executable attributes if necessary
- reboot phone into CWM, connect phone to PC
- connect to phone over adb and check if you are root (type "id") and also type "mount" to verify that /system is mounted and ALL other "/dev/block/platform*" partitions are unmounted (/data*, /cache, /sdcard etc...), by default it's not and you have to:
- mount system partition: mount /system
- umount cache partition: umount /cache
- umount data partition(s): umount /data*


Finally it should looks like that:
~ # mount
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/block/platform/msm_sdcc.1/by-name/system on /system type ext4 (rw,nodev,noatime,nodiratime,data=ordered)

If everything is OK, we can begin:

- in adb type:
parted /dev/block/mmcblk0 #this start "parted" and access the storage
unit MB #we set default unit of size to MB
print #this display actual partition layout, save this output in txt file!!!

#example of output:
Model: MMC SEM16G (sd/mmc)
Disk /dev/block/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 89.1MB 89.1MB fat16 modem
2 89.1MB 178MB 89.1MB fat16 modem1
3 178MB 179MB 524kB sbl1
4 179MB 179MB 524kB sbl2
5 179MB 180MB 1049kB sbl3
6 180MB 181MB 1049kB rpm
7 181MB 182MB 1049kB tz
8 182MB 183MB 524kB DDR
9 183MB 187MB 4194kB aboot
10 187MB 188MB 1049kB misc
11 188MB 191MB 2990kB logo
12 191MB 192MB 799kB m9kefs1
13 192MB 193MB 799kB m9kefs2
14 193MB 193MB 1024B m9kefsc
15 193MB 201MB 8501kB bk1
16 201MB 202MB 799kB m9kefs3
17 202MB 268MB 66.3MB bk2
18 268MB 284MB 15.7MB boot
19 284MB 300MB 15.7MB boot1
20 300MB 316MB 15.7MB recovery
21 316MB 327MB 11.5MB bk3
22 327MB 336MB 8389kB ext4 persist
23 336MB 872MB 537MB ext4 system
24 872MB 1409MB 537MB ext4 system1
25 1409MB 1812MB 403MB ext4 cache
26 1812MB 5570MB 3758MB ext4 userdata
27 5570MB 15758MB 10188MB ext4 storage

#because "parted" so far don't have support for ext4 FS resize, we must remove partitions 26 and 27
#and recreate them with different size from the scratch.
#still in the "parted" type:

rm 26 #this remove /data (userdata) partition
rm 27 #same with /sdcard (storage) partition

#now we create partitions back with new size
#(it's up to you to decide new sizes of partitions, in my case I have reduced /data by -2500MB
#and add them to /sdcard)

mkpartfs primary ext2 1812 3070 #new partition created, starting on 1812MB and ending on 3070MB
#=> size of the partition is: 3070 - 1812 = 1258MB (more then enough for my apps, I have still 568MB free in /data...

mkpartfs primary ext2 3070 15758 #in the same way we re-create storage partition
name 26 userdata #we have to set back partition labels
name 27 storage
quit


#now we convert new partitions to ext4:
tune2fs -j /dev/block/mmcblk0p26
e2fsck -fDp /dev/block/mmcblk0p26
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p26
e2fsck -fDp /dev/block/mmcblk0p26


tune2fs -j /dev/block/mmcblk0p27
e2fsck -fDp /dev/block/mmcblk0p27
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p27
e2fsck -fDp /dev/block/mmcblk0p27



#lets run "parted" again to do a final check:
parted /dev/block/mmcblk0
unit MB
print


#example of correct output:

Model: MMC SEM16G (sd/mmc)
Disk /dev/block/mmcblk0: 15758MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 0.02MB 89.1MB 89.1MB fat16 modem
2 89.1MB 178MB 89.1MB fat16 modem1
3 178MB 179MB 0.52MB sbl1
4 179MB 179MB 0.52MB sbl2
5 179MB 180MB 1.05MB sbl3
6 180MB 181MB 1.05MB rpm
7 181MB 182MB 1.05MB tz
8 182MB 183MB 0.52MB DDR
9 183MB 187MB 4.19MB aboot
10 187MB 188MB 1.05MB misc
11 188MB 191MB 2.99MB logo
12 191MB 192MB 0.80MB m9kefs1
13 192MB 193MB 0.80MB m9kefs2
14 193MB 193MB 0.00MB m9kefsc
15 193MB 201MB 8.50MB bk1
16 201MB 202MB 0.80MB m9kefs3
17 202MB 268MB 66.3MB bk2
18 268MB 284MB 15.7MB boot
19 284MB 300MB 15.7MB boot1
20 300MB 316MB 15.7MB recovery
21 316MB 327MB 11.5MB bk3
22 327MB 336MB 8.39MB ext4 persist
23 336MB 872MB 537MB ext4 system
24 872MB 1409MB 537MB ext4 system1
25 1409MB 1812MB 403MB ext4 cache
26 1812MB 3070MB 1258MB ext4 userdata #userdata is smaller
27 3070MB 15758MB 12688MB ext4 storage #storage is bigger, good...

#now we can quit "adb" and in CWM menu remove dalvik cache and reboot the phone
#after fist boot we can connect phone to computer and copy our data back to /sdcard
# then we have to reboot to CMW and do an advanced restore to have user applications (/data) back.
# after that we can do a final reboot and enjoy new extended storage space :)

Good luck.

Hint: I have removed System1 partition and recreated it with size 16MB (no more dualboot) and also lower Cache partition size to 200MB to get more space for Storage, it works fine.
 

Attachments

  • modified_sdcard.jpg
    modified_sdcard.jpg
    30.3 KB · Views: 1,788
  • partition_tools.zip
    409.2 KB · Views: 2,182
Last edited:
Wow!

But.... If I flash a new ROM, it return like original one?

Inviato dal mio MI 2 con Tapatalk 2
 
I would also like to know this as I am thinking of using this this guide to extend the app space available on my mi2s

Sent from my MI 2SC using Tapatalk 2
 
I would also like to know this as I am thinking of using this this guide to extend the app space available on my mi2s

Sent from my MI 2SC using Tapatalk 2

yes of course, you can in the same way extend userdata as well...you have 32GB verion?
 
Yes I do have the 32gb version. I am enjoying the phone except for the size of the partitions so will look at this closely. Thanks for sharing.

Sent from my Nexus 4 using Tapatalk 2
 
Hey i have a trick to earn an extra 536 MB if you don´t use dualboot feature, i removed system1 and then assigned it a size of 1mb (this is necesary to mantain the default partition layout to avoid problems).
Of course you have to remove the cache partition also and then assign its right size (403mb) again to redistribute the earned space correctly. I really don´t know why is necesary a cache with 403 mb size, maybe we can reduce it also.
Do not forget to do a full wipe before reboot.

This is my partition table after the trick:
Captura.PNG
 
As far as I know cache partition isn't that important anymore as it was on 2.3
And these changes will be kept forever. Flashing a new rom will not change the partition layout.
However u should be very careful because u can easily brick ur phone.
 
This is good information, maybe I reduce /cache as well, I'll try to find more information about Android 4.1 - 4.2 cache role.

Regarding dual boot, I am not using it so I also reduce it to 1mb :p

Sent from my MI 2S using Tapatalk 4 Beta
 
Hey i have a trick to earn an extra 536 MB if you don´t use dualboot feature, i removed system1 and then assigned it a size of 1mb (this is necesary to mantain the default partition layout to avoid problems).
Of course you have to remove the cache partition also and then assign its right size (403mb) again to redistribute the earned space correctly. I really don´t know why is necesary a cache with 403 mb size, maybe we can reduce it also.
Do not forget to do a full wipe before reboot.

Regarding information I found, cache partition is mostly used by Google market to temporary store apk files before installation to data partition. If apk not fit it the cache, it can't be installed.

So, if you are playing games (=> installing BIG apk files), you need big cache partition.
If not, you can consider resize it to smaller (128mb or less).

It would be interesting to test it...
 
Wonderful news...
I don't use dual boot!!!
What about a bigger system partition? (Now I have only 8mb free on sodden position)

M1cha.... isn't there a possibility to make a zip flashable file or a simple GUI?

Inviato dal mio MI 2 con Tapatalk 2
 
@xeGox: generally, it's possible, but quicker and more safer solution is remove unnecessary system applications via titanium backup...
 
i am struck at parted /dev ...... command. till that point i am ok... once i type parted /dev.... command & press enter in CMD, it says parted is not recognised as an internal or external command.... what is wrong with my procedure ?
should i type ADB before parted or just type part /dev/..... like that ?
i am really confused... guide me pls...
 
i am struck at parted /dev ...... command. till that point i am ok... once i type parted /dev.... command & press enter in CMD, it says parted is not recognised as an internal or external command.... what is wrong with my procedure ?
should i type ADB before parted or just type part /dev/..... like that ?
i am really confused... guide me pls...

Hi,

be sure that you did all steps from "preparing" phase:

- reboot phone to CWM and mount /system partition
- umount /cache partition
- connect to phone over adb and check if you are root (type "id") and also type "mount" to verify that /system is mounted (and /cache unmounted):
~ # mount
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
/dev/block/platform/msm_sdcc.1/by-name/system on /system type ext4 (rw,nodev,noatime,nodiratime,data=ordered)

If you have not mounted /system partition, path to "parted" binary doesn't exist!
 
  • Like
Reactions: Dipkumar
I am sorry, as sson as i reboot into CWM & mount the system partition & unmount cache partition,
i type adb devices.... i am not seeing any serial number. it just says list of devices attached... nothing else....
if i type adb id also nothing comes up.... some text rolls down & thats it.. again back to where i was....

should i post the screen shot here ? may be that would help you diagnose the issue right ?
i will do it soon.... thanks for your helping hand,,,
 
hi bro, here is the error i get when i type adb devices after i reboot into CWM recovery & mount system & unmount cache...
vur9.jpg



but in normal desktop mode, adb device is working properly & listing the device id.... not in CWM recovery mode... why is that ?
 
Hm, it should work...do you have all necessary drivers installed in Windows?

I have no problem connect device in CWM, I will check at home which driver is used at that time and if it's same like in MIUI...
 
yeah.... i have used the same drivers.. it is getting detected normally when i am not in CWM recovery mode in CMD window.... but not when i reboot into recovery mode & choose mount system !!! mo listing.... i am geting above screen shot !!!

what should i do now ?
 
nop.... should i ?
reinstall CWM & copy thoese files once again with change in permissions ?