Mi2S - extending size of storage partition


after an endless run of fails i decided to flash last dev MIUI with miflash.
but this did go also into an error. miflash aborted the flashing with error "remote partition tooo large".
so i did flash all the images myself with "fastboot flash system system.img" and so on.

MIUI did boot without errors and the storage is writeable again.
last step was flashing CWM and CM11.

don't know what's the trick in flashing the storage.img.... but it did fix the poblem.
 
First of all I want to thank you for sharing.
I studied the guide and today I tryed to do it. I'm stuck in the umont step. It should be part of the preparation step but the first try gave a similar but not identical output as yours, but I'm very sure that after the mount umount commands the only /dev/... was system. so i decided to move on...
everything ok until: rm 27.
output told me it couldnt be done since it was in use... so I checked mount again and another dev line appeared:
...
/dev/block/platform/msm_sdcc.1/by-name/system on /system type ext4 (rw,seclabel,
relatime,data=ordered)
/dev/block/vold/179:27 on /storage/sdcard0 type ext4 (rw,dirsync,context=u:eek:bject_r:sdcard_external:s0,nosuid,nodev,noexec,noatime,data=ordered)

So I remade back the partition 26 back to the original size, ext, name, and it was ok.

I've made some googling trying to figure out how to umount that last /storage/sdcard0 but I'm super noob at this stuff and I often do not understand instructions made for devs only; for example I had to read all the discussion to figure out that to type id or mount I must type "adb shell" "mount" and not "adb mount".......

I've tryed "umount /storage", "umount /sdcard", "umount /sdcard0", "umount /storage/sdcard0" without success...
I cant find a correlation between displayed partition names and their shell names....
So I'm back at preparation phase, this is my actual "mount":
mount
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,seclabel,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,seclabel,relatime)
tmpfs on /storage type tmpfs (rw,seclabel,relatime,mode=050,gid=1028)
tmpfs on /mnt/secure type tmpfs (rw,seclabel,relatime,mode=700)
tmpfs on /mnt/fuse type tmpfs (rw,seclabel,relatime,mode=775,gid=1000)
/dev/block/platform/msm_sdcc.1/by-name/system on /system type ext4 (rw,seclabel,relatime,data=ordered) /dev/block/vold/179:27 on /storage/sdcard0 type ext4 (rw,dirsync,context=u:eek:bject_r:sdcard_external:s0,nosuid,nodev,noexec,noatime,data=ordered)

What should I command the shell to finish preparation phase?

edit: Problem solved.
I did phone reboot then reboot in recovery, the code din't show anymore.
partitions changed. Thanks a lot!
 
Last edited:
@M1cha
should the following code work for my 32GB MI2? I want to extend my data partition as the same.
thanks very much.
wow, I replied in the wrong place. the following code is from your repartition.sh script.
Code:
change_table() {
    ui_print "parted: delete"
    parted -s /dev/block/mmcblk0 rm 23 || return 1 # system
    parted -s /dev/block/mmcblk0 rm 24 || return 1 # system1
    parted -s /dev/block/mmcblk0 rm 25 || return 1 # cache
    parted -s /dev/block/mmcblk0 rm 26 || return 1 # userdata
    parted -s /dev/block/mmcblk0 rm 27 || return 1 # storage

    ui_print "parted: create"
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 336MB 1176MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 1176MB 2016MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 2016MB 2419MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 2419MB 8081MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 8081MB 31269MB || return 1

    ui_print "parted: name"
    parted -s /dev/block/mmcblk0 name 23 system || return 1
    parted -s /dev/block/mmcblk0 name 24 system1 || return 1
    parted -s /dev/block/mmcblk0 name 25 cache || return 1
    parted -s /dev/block/mmcblk0 name 26 userdata || return 1
    parted -s /dev/block/mmcblk0 name 27 storage || return 1
  
    return 0
}
 
Problem was that /storage/sdcard0 permissions were wrong, changed it to 777 am all went ok.
Could you tell me if symlinks made in /storage/sdcard0/ also appear in (/storage_int/, /sdcard/ or) other directories related to sdcard0 ? I'm trying to solve this issue and I can't try mysefl as I can only load fastboot for now. Thx
 
Some help needed here..
Partition tools files on system/bin
TDB disabled
System unmounted (via CWM)
Cache unmounted (via CWM)
When I try to rm 26 i got this error: "Error: Partition /dev/block/mmcblk0p26 is being used. You must unmount it before you modify it with Parted."

I guess that here's some problem, but I don't know how to fix it. I tried to type umount /data and umount /data_root but tells me "Invalid argument".
Code:
~ # mount
mount
rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,seclabel,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,seclabel,relatime)
tmpfs on /storage type tmpfs (rw,seclabel,relatime,mode=050,gid=1028)
tmpfs on /mnt/secure type tmpfs (rw,seclabel,relatime,mode=700)
tmpfs on /mnt/fuse type tmpfs (rw,seclabel,relatime,mode=775,gid=1000)
/dev/block/vold/179:27 on /storage/sdcard0 type ext4 (rw,dirsync,context=u:objec
t_r:sdcard_external:s0,nosuid,nodev,noexec,noatime,data=ordered)
/dev/block/platform/msm_sdcc.1/by-name/system on /system type ext4 (rw,seclabel,
relatime,data=ordered)
/dev/block/platform/msm_sdcc.1/by-name/cache on /cache type ext4 (rw,seclabel,re
latime,data=ordered)
~ #
 
I think that cache is the problem.
When I unmount it via CWM, if I go back and then I return to Mounts and Storage the option is still "unmount /cache".
I tried to do wipe cache partition and also to format /cache, but it didn't help. What can I do?
 
Could you tell me if symlinks made in /storage/sdcard0/ also appear in (/storage_int/, /sdcard/ or) other directories related to sdcard0 ? I'm trying to solve this issue and I can't try mysefl as I can only load fastboot for now. Thx
Symlinks were ok, only thing I changed was chmod 777.
 
Last edited:
@aleixsr Good. Are we talking about same symlinks? Just to be sure... Take this exemple: I have a folder A in the root of /storage_int and I symlink folder B -> A. Does this symlink also works and could you access to the folder from B if you go through /sdcard, /storage/sdcard0?
This doesn't works for me and it was...

@Fortinho Try with staying into Mount&Storage then umount /cache* and don't move from this menu. It works like that for me.
 
@aleixsr Good. Are we talking about same symlinks? Just to be sure... Take this exemple: I have a folder A in the root of /storage_int and I symlink folder B -> A. Does this symlink also works and could you access to the folder from B if you go through /sdcard, /storage/sdcard0?
This doesn't works for me and it was...

@Fortinho Try with staying into Mount&Storage then umount /cache* and don't move from this menu. It works like that for me.
Sorry but I don't understand you, what I can say is that currently I've: sdcard -> /storage/sdcard0 and it works.
I don't have any symlink inside /storage_int
 
So.. nobody is able to help me here?
I guess it is pretty hard to understand what is the reason for your problem.

I remember that when I tried to modify my partition table manually that I had some unmount issues as well, but managed to force some unmounts adding an extra command to umount (forgot what one but Google will show you when you search for it)

However the easiest way to change the position table was using Micha`s script.
 
  • Like
Reactions: Fortinho
i have a problem after using this method. My 32gb Mi2s have only 10gb avaliable storage. Can anyone help me?
 
ok guys i did something stupid. I skipped the part - umount data partition(s): umount /data*. So i cant mount the system or data. I get E: failed mounting dataroot!

So is it possible to fix this issue?

EDIT: Ok i fixed my problem now how do i remove dual boot and internal storage so the system storage 16gb
 
Last edited:
the end that did not happen, but now will not start the last rom you install in the system 2, I get in any of the 2 system

E: Can `t mount / storage/sdcard0

I want to reinstall a rom, but will not let me and keeps coming

E: Can `t mount / storage/sdcard0

any solution, please help
 
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.

please any solution ??

11111.jpg
 
if only mi2s had SD slot :) thank you for this useful tutorial even so


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
achat ipad air galaxy note 4
 
Last edited:
@M1cha
should the following code work for my 32GB MI2? I want to extend my data partition as the same.
thanks very much.
wow, I replied in the wrong place. the following code is from your repartition.sh script.
Code:
change_table() {
    ui_print "parted: delete"
    parted -s /dev/block/mmcblk0 rm 23 || return 1 # system
    parted -s /dev/block/mmcblk0 rm 24 || return 1 # system1
    parted -s /dev/block/mmcblk0 rm 25 || return 1 # cache
    parted -s /dev/block/mmcblk0 rm 26 || return 1 # userdata
    parted -s /dev/block/mmcblk0 rm 27 || return 1 # storage

    ui_print "parted: create"
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 336MB 1176MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 1176MB 2016MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 2016MB 2419MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 2419MB 8081MB || return 1
    parted -s /dev/block/mmcblk0 mkpartfs primary ext2 8081MB 31269MB || return 1

    ui_print "parted: name"
    parted -s /dev/block/mmcblk0 name 23 system || return 1
    parted -s /dev/block/mmcblk0 name 24 system1 || return 1
    parted -s /dev/block/mmcblk0 name 25 cache || return 1
    parted -s /dev/block/mmcblk0 name 26 userdata || return 1
    parted -s /dev/block/mmcblk0 name 27 storage || return 1

    return 0
}
@bnqzzdf Hey is your code worked or not
i want to try it
 
Good day,
after clearing my system two recovery agrees that I lost root on the two. (system2/root is missing)

It also makes you?
 
Could someone make flashable zip files? Would this be possible?

And that's how I imagine it:
We could use aroma installer and have the ability to custom select size values of system / second system, cache and data and the remaining extra space could be assigned to sdcard. Someone able to core this?

Examples:
User is able to select the size of data:
1500mb (reduce)
2000mb default
2500mb (extend)

If the user selects 1500mb the 500 extra mb will be added to sdcard storage.


Sent with my Xiaomi MI2 with Tapatalk Pro
 
Last edited:
  • Like
Reactions: xeGox and Beyaz
i have a problem , my 32 gb version now shows only 11.8 Gb as storage(mass storage)
help?
edit : fixed by remaking partitions from number 23
 
Last edited:
Could someone make flashable zip files? Would this be possible?

And that's how I imagine it:
We could use aroma installer and have the ability to custom select size values of system / second system, cache and data and the remaining extra space could be assigned to sdcard. Someone able to core this?

Examples:
User is able to select the size of data:
1500mb (reduce)
2000mb default
2500mb (extend)

If the user selects 1500mb the 500 extra mb will be added to sdcard storage.


Sent with my Xiaomi MI2 with Tapatalk Pro
Is it impossible?

Sent from Xiaomi Mi-4g ( the "g" is for graveyard not for great )...with tapatalk 26°