[SCRIPT] Fix partition table for Android 4.4


A more logical way is to go to "mounts and storage" / "mount /storage/sdcard0" rather than misusing "flash zip from sdcard" for mounting the card.
I guess there is a symlink /sdcard pointing to /storage/sdcard0; if not, you'll have to edit the script before running to get the path right.
 
  • Like
Reactions: kelvinokeyo
Thanks guys, it worked well. Now I have restored my MIUI backup on system 1 and installed CM11 on system 2. It works fine.
 
Help guys, i think i totally screw up my phone.I flashed the fix partition script, just changed the numbers so i have bigger userdata partition.Everything changed accordingly.I also format sdcard through clockworkmod.After installing CM11 i realised that my sdcard was not able to r/w, i couldn't make a file and apps couldn''t download anything to sdcard.I had some warnings from titanium backup about su as i wrote in another post, don't know if it's related.I tried to flash miui stock with miflash but there was some kind of error related to a partition size.I have working fastboot and recovery but i don't have adb and of course cannot boot to CM11.What can i do?
 
1) connect your phone to PC via usb and boot into CWM or CM11.
2) on PC: "adb reboot dload" in a shell
3) MiFlash will recognize your phone as a COM-device now. Just flash the latest MIUI fastboot package.
 
  • Like
Reactions: X4nfire
After i enter "adb reboot dload" it's asking if i want to format several partitions if i want to use them.What should i do?
Edit: I flashed everything is ok, thanx a lot!!! I still wonder what was the problem, something wrong with the script or the fact that i formated sdcard from clockworkmod?Was it some kind of permission problem?Can it be fixed without more easily?
 
Last edited:
Hi guys, I tried to apply the repartition script with the instructions from OP and this happened. Did I something wrong? Thanks for your help ;) I have Xiaomi Mi2S 32Gb with MIUI on both systems.

fco507.jpg
same error here. What's wrong?
 
same error here. What's wrong?
When you are in the recovery you've to mount /sdcard... You can do it just simply going in the file manager of the recovery( install zip-->choose zip from storage, stay in this page and then insert Micha's command ) or by mount option in recovery

It's all described in previous pages
 
There's some problem.
I got this error:
cazzo.png

Readed about the mounting sdcard but.. I can't.
In the recovery it tells me
E: Can't mount /cache/recovery/log
E: Can't open /cache/recovery/log
E: Can't mount /cache/recovery/last_log
E: Can't open /cache/recovery/last_log
E: Can't mount /cache/recovery/last_install
E: Can't open/cache/recovery/last_install

And of course when I try to mount sdcard it tells me
Error mounting /storage/sdcard0!
Now I can't use my phone, doesn't boot.
Can anyone help me please? @M1cha
 
Last edited:
It gives me error also with MiFlash...
(0x800004005: FAILED (remote: partition table doesn't exist)
I don't know what to do.
 
It gives me error also with MiFlash...
(0x800004005: FAILED (remote: partition table doesn't exist)
I don't know what to do.

There's some problem.
I got this error:
cazzo.png

Readed about the mounting sdcard but.. I can't.
In the recovery it tells me
E: Can't mount /cache/recovery/log
E: Can't open /cache/recovery/log
E: Can't mount /cache/recovery/last_log
E: Can't open /cache/recovery/last_log
E: Can't mount /cache/recovery/last_install
E: Can't open/cache/recovery/last_install

And of course when I try to mount sdcard it tells me
Error mounting /storage/sdcard0!
Now I can't use my phone, doesn't boot.
Can anyone help me please? @M1cha
Run adb reboot dload from recovery, start miflash and it should detect device in Download mode so it can write partition table again. If this doesn't work you have to use qcom drivers to write partition table again
 
  • Like
Reactions: Fortinho
Run adb reboot dload from recovery, start miflash and it should detect device in Download mode so it can write partition table again. If this doesn't work you have to use qcom drivers to write partition table again
Grazie mille ma.. same error..
How can I use qcom divers? And what I have to do to write partition table?
 
Hi there @M1cha @linuxx
I want to extend the size of "data" partition on System 1... What should I do? Also tell me why does your script start from "336MB" why not from 0???


Code:
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 5570MB || return 1
 
Hi there @M1cha @linuxx
I want to extend the size of "data" partition on System 1... What should I do? Also tell me why does your script start from "336MB" why not from 0???


Code:
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 5570MB || return 1
The userdata partition is only one (mounted at /data_root), inside that partition there are 2 folders called system1 and system2, if tdb is enabled the partition mounted as /data is not always system1 (as if tdb is disabled) but the one "right" for the system that u're using.
So if u want to extend data, you have to extend all data partitions
 
The userdata partition is only one (mounted at /data_root), inside that partition there are 2 folders called system1 and system2, if tdb is enabled the partition mounted as /data is not always system1 (as if tdb is disabled) but the one "right" for the system that u're using.
So if u want to extend data, you have to extend all data partitions
And how do I do that? I mean you said that "So if u want to extend data, you have to extend all data partitions?"

Note: I have TDB enabled!
 
Miflash or stock images

Inviato dal mio MI 2 utilizzando Tapatalk

Hi @linuxx @M1cha
I wanted to revert my Mi2s to the factory state after altering the partition sizes with your {repartition.sh} script, so I downloaded the latest FASTBOOT image and used miflash to flash it. It is true that I have successfully flashed the fastboot image, but the problem is, that the partition sizes have remained the same. I just want to increase the size of my data partition to 4 GB. I need it, please help me!
 
Hi @linuxx @M1cha
I wanted to revert my Mi2s to the factory state after altering the partition sizes with your {repartition.sh} script, so I downloaded the latest FASTBOOT image and used miflash to flash it. It is true that I have successfully flashed the fastboot image, but the problem is, that the partition sizes have remained the same. I just want to increase the size of my data partition to 4 GB. I need it, please help me!
Do not worry, its because of fastboot packages.
Just format the partition that u made bigger (and now it looks as stock) from cwm, it will become as big as u decided :)
 
@M1cha @linuxx
Look what I have done, please tell me I can be saved..... I am so sad.... I even tried MiFlash, but it gave the error "Partition table has been changed"
please reply quickly!

Have a look at my current Partition table! :(

Code:
[agent47@mansion ~]$ adb shell
~ # parted -s /dev/block/mmcblk0 print
parted -s /dev/block/mmcblk0 print
Model: MMC SEM32G (sd/mmc)
Disk /dev/block/mmcblk0: 31.3GB
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
27      5570MB  31.3GB  25.7GB  ext4        storage
 
@M1cha @linuxx
Look what I have done, please tell me I can be saved..... I am so sad.... I even tried MiFlash, but it gave the error "Partition table has been changed"
please reply quickly!

Have a look at my current Partition table! :(

Code:
[agent47@mansion ~]$ adb shell
~ # parted -s /dev/block/mmcblk0 print
parted -s /dev/block/mmcblk0 print
Model: MMC SEM32G (sd/mmc)
Disk /dev/block/mmcblk0: 31.3GB
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
27      5570MB  31.3GB  25.7GB  ext4        storage
Put it into dload mode using cwm and
Adb reboot dload
Then miflash should be able to restore p.t.
BTW missing both systems
 
  • Like
Reactions: GuseppiGuliano