[SCRIPT] Fix partition table for Android 4.4 - Xiaomi Mi 2

Since the gapps for 4.4 need very much space wee need bigger system partitions.
I've created a script which automates this process and increases them both to 840MB.
the space is taken from the userdata partition.
You should backup your whole phone before doing this(storage will not be touched but you shouldn't take the risk)
I tested it with 32GB version only so if you want to know if it will work for 16gb, too give me the output of this command:
parted -s /dev/block/mmcblk0 print
Download:
http://d-h.st/FWz
Instructions:
1) boot into CWM
2) adb push repartition.sh /tmp
3) adb shell chmod 0777 /tmp/repartition.sh
4) adb shell /tmp/repartition.sh
5) adb reboot recovery
6) now you can do all the usual stuff like enabling TDB and installing ROM's

Sounds great but I cannot test it, since I dont have any parted binaries (at least in my 4.1.1 Wajk Wiui ROM) ? Can you please tell me where I can get them.
Second Question:
Im currently running TDB:
System 1 latest WIUI 4.1.1 v5 ROM
System 2 MIUI v6 1.9.19
Both system partitions are completely full (usage 98 %) and the same with the data partitions ( usage 97 % )!
Would it be possible to decrease /sdcard space and repartition it like the following with TDB enabled:
system 800 mb
system1 800 mb
data 1500 mb
data1 1500 mb
sdcard *the rest*
thanks in advance

sounds like you tried to repartition from Android
You need to boot to CWM - you have parted there.

Sorry I hate people who just ask stupid questions before reading the instructions carefully ...silly me sorry for that...
What about the second question, is it possible to either increase the data partitions for less space on /sdcard ?

there isn't sth. like a data1 partition. we have one data partition only that's why we need the TDB hack.
other than that it's possible but you should backup all your data and restore it afterwards.

m11kkaa said:
there isn't sth. like a data1 partition. we have one data partition only that's why we need the TDB hack.
other than that it's possible but you should backup all your data and restore it afterwards.
Click to expand...
Click to collapse
Ok got it.
So following your instructions and editing script like the following should work ?
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 6515MB || return 1
parted -s /dev/block/mmcblk0 mkpartfs primary ext2 6515MB 31.3GB || 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
}
Code:
ui_print "format partitions"
for NUM in 23 24 25 26 27
do
if ! format_partition "$NUM"; then
ui_print "Failed format partition $NUM"
exit 1
fi
done
already did full backup of sdcard, i just dont know if i should disable TDB before i stat repartitioning ... I dont know how TDB works to split the data partition thats my problem :/

yes that should work.
You don't need to disable TDB because your whole data partition will be wiped and it stores the TDB configuration(that means that TDB automatically gets disabled).

Had some errors but now its working fine ..thanks

unmount sdcard in CWM. It's a bug of this script.
Nice to hear it works now.

7 days ago Phone not start because partition corrupt
Hello
First do not panic is not the fault of your script but for you experience with mi2s and partitions are the few people in the world that can save my phone.
I'm playing a game phone(Xiaomi m2s 16GB) hang and one or more partitions are corrupt (I think this is the problem). But all de documentation than i find to delete o edit partition not work. Fastboot rom installation all ok but always only start with white logo. Mirecovery works perfectly and CWM by ivan works but temporally with this command sudo fastboot boot recovery.img
This is the result of your script
check environment
/sbin/mount
/sbin/umount
/sbin/parted
/sbin/tune2fs
/sbin/e2fsck
dump old table
unmount partitions
umount: can't umount /system: Invalid argument
umount: can't umount /system1: No such file or directory
umount: can't umount /data: Invalid argument
umount: can't umount /data_root: Invalid argument
umount: can't umount /sdcard: Invalid argument
change partition table
parted: delete
parted: create
Error: Unable to satisfy all constraints on the partition.
Failed changing table
OTHER TEST
/dev/block # e2fsck -fDp /dev/block/mmcblk0p24
e2fsck: Bad magic number in super-block while trying to open /dev/block/mmcblk0p24
/dev/block/mmcblk0p24:
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
/dev/block # tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p24
tune2fs 1.41.14 (22-Dec-2010)
tune2fs: Bad magic number in super-block while trying to open /dev/block/mmcblk0p24
Couldn't find valid filesystem superblock.
I try to delete partition and create a new one but fail.
(parted) rm 24
rm 24
(parted) mkpartfs primary ext2 872 1409
mkpartfs primary ext2 872 1409
Error: Unable to satisfy all constraints on the partition.
I FOUND THIS IN XDA FORUM BUT I HAVEN'T IMAGE TO TEST
adb push mmcblk0p19_repaired.img /tmp/
adb shell dd if=/tmp/mmcblk0p19_repaired.img of=/dev/block/mmcblk0p19
adb reboot bootloader
MY PARTITION TABLE SYSTEM1 NOT HAVE FILESYSTEM EXT4
[email protected]:~/Escritorio/recovery$ sudo adb shell parted -s /dev/block/mmcblk0 print
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 system1
25 1409MB 1812MB 403MB ext4 cache
26 1812MB 5570MB 3758MB ext4 userdata
27 5570MB 15.8GB 10.2GB ext4 storage

Xiaomi Mi2 32GB
XIAOMI MI2 32GB ONLY
For those using a single MIUI ROM I've made a partition table with system1 set to 1024Mb.
Run the attached from CWM (in /tmp).

Aternus said:
XIAOMI MI2 32GB ONLY
For those using a single MIUI ROM I've made a partition table with system1 set to 1024Mb.
Run the attached from CWM (in /tmp).
Click to expand...
Click to collapse
Can you explain a little more? Does it only leave 1 system partition? Can I flash it like a regular zip?
Enviado desde mi MI 2S mediante Tapatalk

any step by step manual how to change partition? with all necessary downloads etc...
or.... is it possible to delete system2 with all its parts? - for me I'd to use system1 only

Why can not I change the size of the system partition?
Already tried several times, with disabled TDB and with enabled TDB.
Full wipe did and still no result.
P.S. I have already been able to do any repartitioning.
Code:
PS C:\Android> adb push repartition.sh /tmp
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
21 KB/s (3797 bytes in 0.169s)
PS C:\Android> adb shell chmod 0777 /tmp/repartition.sh
PS C:\Android> adb shell /tmp/repartition.sh
check environment
/sbin/mount
/sbin/umount
/sbin/parted
/sbin/tune2fs
/sbin/e2fsck
dump old table
__bionic_open_tzdata: couldn't find any tzdata when looking for localtime!
__bionic_open_tzdata: couldn't find any tzdata when looking for GMT!
__bionic_open_tzdata: couldn't find any tzdata when looking for posixrules!
unmount partitions
umount: can't umount /system: Invalid argument
umount: can't umount /system1: No such file or directory
umount: can't umount /data: Invalid argument
umount: can't umount /sdcard: Invalid argument
change partition table
parted: delete
parted: create
parted: name
format partitions
format: /dev/block/mmcblk0p23
tune2fs 1.41.14 (22-Dec-2010)
tune2fs: No such file or directory while trying to open /dev/block/mmcblk0p23
Couldn't find valid filesystem superblock.
e2fsck 1.41.14 (22-Dec-2010)
e2fsck: No such file or directory while trying to open /dev/block/mmcblk0p23
Possibly non-existent device?
tune2fs 1.41.14 (22-Dec-2010)
e2fsck 1.41.14 (22-Dec-2010)
Adding dirhash hint to filesystem.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p23: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p23: 11/500856 files (0.0% non-contiguous), 62917/1000445 blocks
format: /dev/block/mmcblk0p24
tune2fs 1.41.14 (22-Dec-2010)
Creating journal inode: done
This filesystem will be automatically checked every 30 mounts or
0 days, whichever comes first. Use tune2fs -c or -i to override.
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p24: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p24: 11/262144 files (0.0% non-contiguous), 49386/524289 blocks
tune2fs 1.41.14 (22-Dec-2010)
e2fsck 1.41.14 (22-Dec-2010)
Adding dirhash hint to filesystem.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p24: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p24: 11/262144 files (0.0% non-contiguous), 49386/524289 blocks
format: /dev/block/mmcblk0p25
tune2fs 1.41.14 (22-Dec-2010)
Creating journal inode: done
This filesystem will be automatically checked every 30 mounts or
0 days, whichever comes first. Use tune2fs -c or -i to override.
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p25: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p25: 11/196608 files (0.0% non-contiguous), 32935/393217 blocks
tune2fs 1.41.14 (22-Dec-2010)
e2fsck 1.41.14 (22-Dec-2010)
Adding dirhash hint to filesystem.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p25: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p25: 11/196608 files (0.0% non-contiguous), 32935/393217 blocks
format: /dev/block/mmcblk0p26
tune2fs 1.41.14 (22-Dec-2010)
Creating journal inode: done
This filesystem will be automatically checked every 30 mounts or
0 days, whichever comes first. Use tune2fs -c or -i to override.
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p26: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p26: 11/399200 files (9.1% non-contiguous), 28951/798348 blocks
tune2fs 1.41.14 (22-Dec-2010)
e2fsck 1.41.14 (22-Dec-2010)
Adding dirhash hint to filesystem.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 3A: Optimizing directories
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p26: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p26: 11/399200 files (9.1% non-contiguous), 28951/798348 blocks
Done.
PS C:\Android> adb reboot recovery
PS C:\Android>
UPD. The problem was that I was using Windows Povershell
Run the script from the command line and everything turned out.

Thanks!
I have to format first system and system1 in recovery to apply this script, because I have and error :
tmp/repartition.sh lin 115 can´t create /sdcard/parted_12_06_2014_FDFD6F4CB043F4956D9CAD053C3738AA.

DO MOUNT your SDCARD
then Follow the instruction
duhh...

I modified the script a little bit for 1 ROM usage. System1 is 840MB as in the original and System2 is 5MB. The rest goes into userdata. This is for the 16GB version.

Ok! I did again and umount the sdcard abd it worked fine.
Thanks

I found a better way
If u reboot into dload mode, u can change the partition table from your computer
The problem is that most partition managers don't support changing the GPT Partition names and that's why I added support for that to GParted.
GParted supports booting from Live CD/USB so Windows/Mac users aren't left out.
http://i.imgur.com/3SwSXs2.png
I pushed the patch to GParted repo's and I'll inform u once there're any news.

from my point of view the best way for use is:
- system (system1) - let 1024 MB
- system1 (system2) - let 10 MB
- userdata (apps) - let 4096 MB (take it from sdcard) - but maybe more

Related

[Q] /system/ directory corrupted, Salvage?

~ # e2fsck -c /dev/block/mmcblk0p9
e2fsck 1.41.12 (17-May-2010)
/dev/block/mmcblk0p9: Updating bad block inode.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Directory inode 46753, block #0, offset 0: directory corrupted
Salvage<y>?
Is this supposed to happen or do I indeed have a corrupted directory?
I went ahead anyway and this was my result
/dev/block/mmcblk0p9: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p9: 1576/54544 files (0.2% non-contiguous), 71430/218112 blocks
Narada2XK said:
I went ahead anyway and this was my result
/dev/block/mmcblk0p9: ***** FILE SYSTEM WAS MODIFIED *****
/dev/block/mmcblk0p9: 1576/54544 files (0.2% non-contiguous), 71430/218112 blocks
Click to expand...
Click to collapse
hmmm what it shows? ;D it means that your emmc isnt fcked? or smt like that
EdgaBimbam said:
hmmm what it shows? ;D it means that your emmc isnt fcked? or smt like that
Click to expand...
Click to collapse
~ # umount /cache
~ # umount /system
~ # parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.179-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
print
Model: MMC VYL00M (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 4194kB 25.2MB 21.0MB ext4 EFS
2 25.2MB 26.5MB 1311kB SBL1
3 27.3MB 28.6MB 1311kB SBL2
4 29.4MB 37.7MB 8389kB PARAM
5 37.7MB 46.1MB 8389kB KERNEL
6 46.1MB 54.5MB 8389kB RECOVERY
7 54.5MB 264MB 210MB ext4 CACHE
8 264MB 281MB 16.8MB MODEM
9 281MB 1174MB 893MB ext4 FACTORYFS
10 1174MB 3322MB 2147MB ext4 DATAFS
11 3322MB 15.2GB 11.9GB fat32 UMS
12 15.2GB 15.8GB 537MB ext4 HIDDEN
(parted) quit
quit
~ # e2fsck -n -f -v /dev/block/mmcblk0p9
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
1568 inodes used (2.87%)
3 non-contiguous files (0.2%)
1 non-contiguous directory (0.1%)
# of inodes with ind/dind/tind blocks: 0/0/0
Extent depth histogram: 1293/1
70009 blocks used (32.10%)
0 bad blocks
0 large files
1190 regular files
103 directories
0 character device files
0 block device files
0 fifos
0 links
266 symbolic links (266 fast symbolic links)
0 sockets
--------
1559 files
~ #
I don't have any bad blocks and so far I don't see any problems, however, when I checked mmcblk0p10, that came back with errors, which I am not sure if I should have or not. I didn't bother to fix that though.
I suppose it's supposed to be that was because I re-install CM9, factory reset / wiped and...
~ # umount /cache
~ # umount /system
~ # e2fsck -n -f -v /dev/block/mmcblk0p9
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Directory inode 46753, block #0, offset 0: directory corrupted
Salvage? no
e2fsck: aborted
~ #
going to restore my nandroid now.

[HACK] Grow your data partition

>>> Please note that Vashiru reworked this guide for reliability and alternate values, so I recommend you check his various posts in this thread starting with this one. <<<
Click to expand...
Click to collapse
THE PROBLEM
As many of us have noticed, it is fairly easy to get an "Out of space" message when installing apps on our phones because, for some weird reason, Oppo decided that the storage part of the device should linger in the dark ages, when /userdata and /sdcard were separate partitions and you only had 2GB of data storage, even if your phone was a 32GB model.
Now, imagine that you are running KitKat and would like to try ART. This may be a bad idea as, if your data partition is more than 30% full, you will find that while converting your apps to this new format, Android will run out of space.
At OppoForums, a few bright people started looking into the issue and, of course, there is a way to improve the situation.
WARNING!
If you follow the steps below correctly, you should not run in any trouble. If you do not, however, you may end up spending much more time fixing your phone.
FIRST, THE THANKS SECTION
Anders tinkered with his device’s partition table until he got to where he had grown the /userdata partition to something useable. Yes, it’s some people’s definition of “play”
Jousa11 is the first person trying to put a guide together explaining the steps to reproduce Anders’ work. WARNING: I did no get to see said guide as Jousa quickly deleted it due to the risks involved. So, take that in account!
Rockman for providing the last resort rescue tools in case you brick your phone
Lucky for providing the WiFi fix
Please let me know if you are not on this list and I forgot to give you credit!
YOU WILL NEED
The hardware:
An Oppo Find5 phone(!)
A computer (Windows/Linux/Mac) with adb installed and working
A USB cable
On your computer:
adb
[Optional] fastboot
On your phone (SDCard):
parted + mke2fs + tune2fs
mmcblk0p21_persist_ext4.img
openrecovery-twrp-2.6.3.0-find5-TP-patch.img
[Optional] gdisk
You will use parted to work on your partition table; mke2fs and tune2fs to create ext4 filesystems on some of these partitions (parted does not know how to create ext4 partitions)
mmcblk0p21_persist_ext4.img is an image that you need to restore your /persist partition and avoid issues such as non-working WiFi.
openrecovery-twrp-2.6.3.0-find5-TP-patch.img is a patched recovery image. I know: you already have a recovery image if you are going through these steps. However, we are going to wipe it so you want to install this guy before rebooting. Note that if you forget, you can always flash it later using fastboot.
On your computer:
adb to access your phone recovery, push files to SDCard, reboot...
[Optional] fastboot. You will only need fastboot if you mess up your recovery partition.
WHAT IF SOMETHING GOES AWFULLY WRONG?
You may “brick” your phone. Apparently it’s near impossible to hard brick your Find5, though. See below.
First, Anders recommends making a backup of your partition table. I didn’t because I felt that if I messed something up, it would be a partitions’ content rather than the partition table but that’s not the wisest approach.
Furthermore, if you are really worried about what stilly error your fat fingers will cause (I know I should be!) you can also backup your partitions.
Backing up your partition table:
On your phone:
Code:
gdisk -b /sdcard/gpt.bin /dev/block/mmcblk0
Backing up a single partition:
On your phone:
Code:
dd if=/dev/block/mmcblk0p<partition id> of=/sdcard/backup-<partition id>.bin
On your computer:
Code:
adb pull /sdcard/gpt.bin
adb pull /sdcard/backup-<partition id>.bin
LAST RESORT
OK. So, you've bricked your phone. Now what?
First, you will need Windows. So if you're on a Mac or Linux and have no access to a Windows machine/VM, er..don't brick your phone.
- Download drivers and tools
- Download and follow the instructions
READY ? LET'S GET STARTED
>>>>>>>>>>>> First, Download The Files <<<<<<<<<<<<
Then...
On your computer:
UPDATE As dixxa pointed out, mke2fs and tune2fs may already be present on your device. It was not the case for me but you should check first; it seems like a good idea to use existing binaries.
Code:
adb reboot recovery
adb push parted /sbin
adb push mke2fs /sbin
adb push tune2fs /sbin
On your phone:
Code:
chmod 755 /sbin/parted /sbin/mke2fs /sbin/tune2fs
umount /cache
umount /sdcard
umount /emmc
umount /data
parted /dev/block/mmcblk0
You are now in the parted shell.
CAREFUL! Do not delete any partition below 20 or you will enter "Big Oops" territory. I recommend typing carefully and, yes, staying away from copy/paste operations that may swallow a character like, say, the '2' in '20'
Note that the size value I am using here is '4GB' for /userdata (rather than 2GB). I guess you could make /userdata bigger than 4GB, in which case you would have to recompute all the offsets in the commands below(!)
Code:
# rm sdcard
rm 29
# 28 thru 23 are reserved
rm 28
rm 27
rm 26
rm 25
# rm recovery
rm 24
# rm misc
rm 23
# rm cache
rm 22
# rm persist
rm 21
# rm data/emmc
rm 20
# now, re-create partitions but data is bigger
mkpart primary 1325 5421
name 20 userdata
mkpart primary 5421 5430
name 21 persist
mkpart primary 5430 5967
name 22 cache
mkpart primary 5967 5968
name 23 misc
mkpart primary 5968 5979
name 24 recovery
mkpart primary 5979 6012
name 25 reserve1
mkpart primary 6012 6019
name 26 reserve2
mkpart primary 6019 6028
name 27 reserve3
mkpart primary 6028 6062
name 28 reserve4
mkpart primary 6062MB 100%
name 29 sdcard
# exit parted shell
q
Let's create a file system on the partitions that require one. Note that I am formatting the SDCard using VFAT as, yes, EXT4 is a better FS, but it is also incompatible with Oppo's ROM and some apps may not require the proper permissions etc.
Code:
# Notes:
# -m 0: no reserved blocks
# -c 0: no max mount count
# -C -1: no mount count
# -i -1: max_int interval between checks
mke2fs -t ext4 -m 0 -L userdata /dev/block/mmcblk0p20
tune2fs -c 0 -i -1 -C -1 /dev/block/mmcblk0p20
mke2fs -t ext4 -m 0 -L persist /dev/block/mmcblk0p21
tune2fs -c 0 -i -1 -C -1 /dev/block/mmcblk0p21
mke2fs -t ext4 -m 0 -L cache /dev/block/mmcblk0p22
tune2fs -c 0 -i -1 -C -1 /dev/block/mmcblk0p22
# Hey look it’s an ext4 SDCard!
mke2fs -t ext4 -m 0 -L sdcard /dev/block/mmcblk0p29
tune2fs -c 0 -i -1 -C -1 /dev/block/mmcblk0p29
# Actually to avoid errors like unable to write to root of sdcard:
mkdosfs -n sdcard -F 32 /dev/block/mmcblk0p29
mount -t vfat /dev/block/mmcblk0p29 /sdcard
At this point, we have clobbered the /persist partition and this could cause issues as mentioned earlier. Let's restore it.
Code:
# Restore /persist partition
mount -t ext4 /dev/block/mmcblk0p29 /sdcard
# On computer
adb push mmcblk0p21_persist_ext4.img /sdcard/
# On phone
dd if=mmcblk0p21_persist_ext4.img of=/dev/block/mmcblk0p21
IMPORTANT! Flash your recovery partition now. If you wait until after rebooting, you will need to use fastboot instead.
Code:
# Recovery partition: on computer
adb push openrecovery-twrp-2.6.3.0-find5-TP-patch.img /sdcard/
# On phone
dd if=openrecovery-twrp-2.6.3.0-find5-TP-patch.img of=/dev/block/mmcblk0p24
Admire your work
Code:
parted /dev/block/mmcblk0 print
Reboot into your new recovery and install your favorite ROM
FAQ
Q: Is this dangerous?
A: Yes. Yes, it is.
Q: Any tip?
A: Yes. Follow these instructions carefully and if something wrong happens, unless you know what you are doing, leave your device alone and come here to ask for help.
Q: Can I hold you responsible for any damage to my phone/etc?
A: As usual, the answer is 'No'
Q: I found an error in your write-up!
A: Please let me know immediately.
-Chris.
You should probably use the latest TWRP 2.6.3.1 found here: http://techerrata.com/file/twrp2/find5/openrecovery-twrp-2.6.3.1-find5.img
Looks good to me. Just be very carefully doing this.
Sent from my Find 5 using xda app-developers app
gdisk -b /sdcard/gpt.bin /dev/block/mmcblk0
those commands need to be typed in recovery even that one ?
Yes although I imagine this particular command should also work when booting system.
Sent from my Find 5 using Tapatalk
This thread is fine the only problem here is with those 2 binaries: mke2fs and tune2fs
You don't need to push them or chmod them since they are already in the recovery
Except that that thread is perfect.
Since we're at toying with partition, can't we merge the partitions in some way ?
Just wondering is there any way to build a script to do this in an automated way thus avoiding user errors and typos?
There is a thread on the oppo forums
http://www.oppoforums.com/threads/guide-resizing-internal-storage-on-find-5-32gb.8361/
Hello everyone,
is the guide for the 32 or 16 gb model?
I have 16 gb Oppo find 5.
Thanks.
PS: what "on your phone" is supposed to mean"?
Click to expand...
Click to collapse
If you don't know what does that mean don't do it you'll screw your phone.
hi
Please would you make something like this for oppo find 7a x9006?
thanks
Anyone willing to recompute all the offsets dor just one 16gb partition?
Scribed henceforth from thy G pad.
Hi all, I am trying to do this mod and I am half way through it with a problem
I am stuck on the new file system, I cannot use mke2fs or tune2fs, i get
Code:
mke2fs: not found
like it doesn't even exist, but it does I can see it. I get the same error for tune2fs. but parted and gdisk work fine.
Yes I did push them and chmod 755 them.. and I have tried running it from the /sbin directory.
Help!
Hello!
I'm getting the same error over and over again creating /dev/block/mmcblk0p21 to /dev/block/mmcblk0p22:
tune2fs -c 0 -i -1 -C -1 /dev/block/mmcblk0p21
"Bad magic number in super-block while trying to open /dev/block/mmcblk0p21"
"Couldn't find valid filesystem superblock"
So i can't create a file system on the created partitions. I have been looking everywhere for an answer. Somebody have an idea?
U should just wait. Andrew dodd found a way to make find7a have unified partition and he claims he can make it work on find5 as well. Let's give him a bit to figure it out tho.
Scribed henceforth from thy G pad.
Gdisk not working...
Ok guys sort of a noob here... Firstly, totally appreciate what you guys are doing here... I wants it bad, thass why i'm here.
So far... I have i have done...
"adb reboot recovery"
"adb push gdisk /sbin"
I figured that's how you are supposed to install it ... hope i'm not wrong, but i guess it pushed through fine
But after rebooting to system in TWRP , i opened terminal emulator and when i use the command
"gdisk -b /sdcard/gpt.bin /dev/block/mmcblk0"
I get ...
"/system/bin/sh: gdisk: not found"
now i'm too scared to proceed without backing up the partition tables... so please help...
edit - FYI , i'm running the last build of Asylum Carbon... should i just go back to latest oopo stable stock rom and then root my device again and then try all this again... would that help... ???
Directly from Andrew Dodds g+ " IT HAS BEGUN.
The first phase of Find 7a/7s LVM testing is here.* See linked post for details.* (Sorry to disappoint, but the first phase is "make sure we don't break existing configurations")
Once this phase is complete, the remaining list is:
Fix up the remaining TWRP issues (make RECOVERY_SDCARD_ON_DATA runtime instead of compile-time)
Make user-friendly conversion processes
Once things are solid on Find 7, I'll work on Find 5 and N1."
Stay thirsty my friends. Good things ahead
Sent from my A0001 using Tapatalk
Does this work for the 16gb model?
Can someone help please?
I'm trying to do this, but after enter in parted [parted /dev/block/mmcblk0] when i try to do "rm 29", i get "can't remove 29: no such file or directory
I'm doing the "on your phone" commands in TWRP command line., is that correct?
I'm running stable colorOS 1.0.9i
Finally I finish the process.
My notes:
Goal:
Keep my current system intact (stable colorOS 1.0.9i , because i have no patience to format, install a new ROM and reinstall/recofigure everything
So I backup everything on phone with TWRP and I push sdcard content (wich include the system backup i made) with ADB
1 - If I push mke2fs and tune2fs IT WILL NOT WORK. I flash the last find 5 recovery (openrecovery-twrp-2.8.1.0-find5.img) and I dont push or chmod anyting, parted, mke2fs, tune2fs are all already in the recover and that's the only way I could run mke2fs and tune2fs
edit: 1.5 - The phone commands had to be enter via ADB shell. In TWRP command line, after you enter in parted it will not accept commands.
2 - To "rm 29", i had to "umount /dev/block/mmcblk0", otherwise "rm 29" fail due to partition in use
3 - after this instruction:
mount -t vfat /dev/block/mmcblk0p29 /sdcard
(the last one on the 4 block of code)
We have this:
# Restore /persist partition
mount -t ext4 /dev/block/mmcblk0p29 /sdcard
This instruction was the only one that give me a error, so I move to the next ones.
The error was that the partition was busy, what makes senses because in the last instruction we mount the same partition on the same folder but with different file system!!??
So I move to the next instruction. I have no idea if it's a instructions mistake but it looks like, because it says "# Restore /persist partition" but the command has nothing to do with /persist
4 - FINISH
5 - Reboot in recovery. Push sdcard backup to /sdcard. restore system backup with TWRP restore
Voila, my phone exactly as before but with 3,76GB for APPS. Finally!!! The "running out of space" message on a flagship quad-core 2GB RAM phone!!!!!!?????? Was driving me CRAZYYYYY
Thanks Fickx for the up to date information, I just did my re-partition successfully, here's what I did:
- Use Rashr update the recovery to twrp-2.8.1.0
- reboot into recovery
- connect to PC (Make sure adb works, "adb devices")
- on PC:
> adb shell
> umount /cache
> umount /sdcard
> umount /emmc
> umount /data
> umount /dev/block/mmcblk0p29
> parted /dev/block/mmcblk0
> rm 29
>...
> rm 20
> mkpart primary 1325 5421
> name 20 userdata
> ...
> name 29 sdcard
> q
> mke2fs ...
> ...
> mount -t -vfat /dev/block/mmcblk0p29 /sdcard
Open another PC command terminal
> adb push mmcblk0p21_persist_ext4.img /sdcard/
> adb push openrecovery-twrp-2.8.1.0-find5.img /sdcard/
Back to original terminal in "adb shell".
> dd if=/sdcard/mmcblk0p21_persist_ext4.img of=/dev/block/mmcblk0p21
> dd if=/sdcard/openrecovery-twrp-2.8.1.0-find5.img of=/dev/block/mmcblk0p24
> exit
> adb reboot recovery
Flash the rom.

How to fix bad Superblocks ?

Hello,
I have an Iconia A200 that I tried to flash with the latest Imni-Rom 4.4.4 .
So far I had a lot of obstacles cause of missing Knowledge, but status is now:
- Bootloader CWM 6.045 installed and unlocked
- Had issues with formatting/mounting, but fixed.
- Flashed Omnirom, but it doesnt boot up -> Unable to purge /Data
Now I cannot 'use' the Data Partition.
I tried the codeblock this Codeblock via ADB:
Code:
1) mke2fs -j -b 4096 /dev/block/mmcblk0p8
2) tune2fs -O extents,uninit_bg,dir_index -C 1 /dev/block/mmcblk0p8
3) e2fsck -fy /dev/block/mmcblk0p8
The first Command i had to repeat 20 times, cause it always stopped at
Code:
'Writing inode tables: 72/224'
The second Command does not work.
The third says me:
Code:
Code:
e2fsck 1.41.14 (22-Dec-2010)
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/block/mmcblk0p8
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
When i try the -b Option the result is the same.
Do I have bad Blocks in the internal Memory?
Any chance to fix this?
Thanks!

[GUIDE][WORK IN PROGRESS]Oneplus one - resize system partition and maybe even more

WARNING!!!​Everyone is responsible for the proper functioning of their device. This guide is the result of personal experiments and I'm not responsible for any damage caused to your device as a result of improper use of its contents.
Introduction
Stock partitions layout has a 1.3Gb /system partition that is too small for users that flash modern custom roms + some kinds of google apps.
This is a step by step guide to change the layout of the partitions table with a bigger /system partition.
How
On OnePlus One, stock partition table looks like the following
Code:
... ... ...
/dev/block/mmcblk0p14 : start= 294912, name="system"
/dev/block/mmcblk0p15 : start= 3006464, name="persist"
/dev/block/mmcblk0p16 : start= 3072000, name="cache"
... ... ...
/dev/block/mmcblk0p28 : start= 4521984, name="userdata"
/dev/block/mmcblk0p29 : start= 121552896, name="grow"
With this layout, resizing the /system partition may seem difficult because it's close to other very important partitions.
So I've experimented with another approach. By resizing userdata partition, and relocate the /system partition at the beginning of the resulting free space, other partitions are left untouched.
There are mainly two (little) issues
almost all custom roms out of there assume that /system partition is 1.3gb of size
on internal storage the old area of /system partition are unused.
For the first point, the solution is to resize the filesystem when you first flash a custom rom. To automatically resize filesystem at every update there is an addon.d script.
For the second point the new free space available (the old 1.3G /system partition) can be used as a new /cache partition.
And, again, the new free space available (the old /cache partition) can be the famous /vendor partition (that is out of the scope of this guide).
This guide uses the sfdisk tool from util-linux. In my opinion, it's more powerful than parted and it's easy to use via script.
IMPORTANT - Before you start
Obviously, this method is destructive regarding userdata partition, so make a full backup of your data.
Manually resizing filesystem of /system partition is needed only once because the addon.d script will ensure that everything works as expected. The only exception is when you wipe /system and flash a new rom
Prerequisites
a working TWRP recovery installed on device
knowledge of adb tools
a statically cross compiled sfdisk tool (you can self compile, or use the one attached below)
this addon.d script (thanks to @osmosis)
flashable zip of a custom rom (and optionally gapps, magisk etc etc etc)
flashable zip bacon-resize-system.zip (attached on this post)
Let's go
enter TWRP recovery and connect phone on a PC
push sfdisk into a temporary dir and ensure is executable
Code:
adb push sfdisk-arm /tmp
adb shell
cd /tmp
chmod 755 sfdisk-arm
make and pull a backup of your partition table (there is also the 64Gb stock layout in attachments)
Code:
./sfdisk-arm -d /dev/block/mmcblk0 > bacon.gpt
exit
adb pull /tmp/bacon.gpt
looking into the partition table you see that userdata partition starts at sector 4521984.
So in order to resize partition (for example 53G instead of 55,8G).
Code:
adb shell
cd /tmp
umount /data
umount /sdcard
echo "4521984,53G" | ./sfdisk-arm --no-reread -N 28 /dev/block/mmcblk0
. Scrolling down the output of this command the new userdata partition is
Code:
Device Start End Sectors Size Type
/dev/block/mmcblk0p28 4521984 115671039 111149056 53G unknown
so the start sector of /system partition will be 115671040 (115671039+1)
relocating system partition at the end of the new userdata partition(size now will be 2,8G)
Code:
echo "115671040,+" | ./sfdisk-arm --no-reread -N 14 /dev/block/mmcblk0
reboot recovery (kernel need to reload partition table)
Code:
reboot recovery
format userdata with TWRP(no wipe... full format)
push custom rom with adb and flash with TWRP (without rebooting)
flash bacon-resize-system.zip
finish.. you can now reboot or continue with flashing gapps, magisk etc etc (but now with a bigger system partition)
Rollback
TODO
Nice to have
flashable zip for addon.d script (WIP)(DONE)
[*] looking into the partition table you see that userdata partition starts at sector 4521984.
So in order to resize partition (for example 53G instead of 55,8G).
Code:
adb shell
cd /tmp
umount /data
umount /sdcard
echo "4521984,53G" | ./sfdisk-arm --no-reread -N 28 /dev/block/mmcblk0
Click to expand...
Click to collapse
If I understand correctly, the system partition will now be 2.8 GB larger. So it will have a total of about 4.1 GB. Is that so?
BTW this is very good work. :good::good::good::good:
BoquinhaSK said:
If I understand correctly, the system partition will now be 2.8 GB larger. So it will have a total of about 4.1 GB. Is that so?
Click to expand...
Click to collapse
the /system partition are 'moved' at the end of the resized userdata partition.. so it's only 2.8G
I've made this decision for two reasons
no needs to move critical partitions
the unused space (the old /system partition) can be used in another way(for example a larger cache partition or a vendor partition)
BoquinhaSK said:
BTW this is very good work.
Click to expand...
Click to collapse
Thanks a lot
Michele
EDIT: another reason for this method is that almost all custom roms works
I have one small problem. Internal storage (/sdcard) I haven't defined. Is it defined as "Invalid partition selection." Full storage is for /data.
How I can mount /sdcard?
Edit: I mean this: /sdcard, /storage/emulated/0, /data/media/0
I changed partition system to ext2 in TWRP.
And system partition si bigger. This works.
Edit2:
I have problem with flash new ROM. Flashing change filesystem from ext2 to ext4 always with smaller previous value. I have problem maybe with script. But I try it again tomorrow.
BoquinhaSK said:
I have one small problem. Internal storage (/sdcard) I haven't defined. Is it defined as "Invalid partition selection." Full storage is for /data.
How I can mount /sdcard?
Edit: I mean this: /sdcard, /storage/emulated/0, /data/media/0
Click to expand...
Click to collapse
after formatting /data the filesystem is empty.. these directories are created when you first start android(if not found)
BoquinhaSK said:
Edit2:
I have problem with flash new ROM. Flashing change filesystem from ext2 to ext4 always with smaller previous value.
Click to expand...
Click to collapse
This is normal. Starting from nougat/oreo the building process of an android system creates a block-based flashable zip.
This means that the system partition is preformatted in ext4 and (for Oneplus One) with a size of 1.3G (the original /system partition). So you cannot change the type of filesystem.
BoquinhaSK said:
I have problem maybe with script. But I try it again tomorrow.
Click to expand...
Click to collapse
Check if the script has the right permission (I'll update the guide).
Also keep in mind that, like others addon.d scrips, it works only with the OTA updater.
If you flash directly from recovery (changing rom, or dirty flash) you need to manually repeat the steps described for resizing partition and installing the script.
I've planned to create a flashable zip to automate these steps.
Thanks
Michele
little update... I've uploaded a simple flashable zip that resize filesystem of /system partition and install the addon.d script.
The procedure now is more simpler.
ilmich said:
little update... I've uploaded a simple flashable zip that resize filesystem of /system partition and install the addon.d script.
The procedure now is more simpler.
Click to expand...
Click to collapse
Hi ilmich, I followed your guide while flashing LOS 17.1 on my OPO and this allowed me to have a /system partition large enough to be able to have a large GApps installation, so cheers for that! However, I installed an OTA update on LOS 17.1 today (29/10 update) and that rebooted to TWRP which seemed to have installed the zip, but then entered a boot loop with several "Could not find x for ctl.interface_start" on the dmesg log. I can see the resizesystem script in the addon.d folder but something must've gone wrong because the partitions seem to have been restored to its default and /system seems to be 1.3GB again in TWRP. I will pull the partition table and post it here.
Update:
I was wrong, /system seems to be the same size on running sfdisk. The cause of the update fail must be somewhere else. Here's the /system partition from sfdisk:
Code:
/dev/block/mmcblk0p14 : start= 115671040, size= 5881856, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=B17FA16F-3B1D-8D12-329D-88B49B096554, name="system", attrs="GUID:60"
I still don't understand why TWRP displays /system as 1303MB again though. Any idea?
Still working...?
Are you still working on this guide?
I'ld love to try it, but I'm a little frightened since there seem to be issues about future udates of Lineage (see previous post).
Zyndstoff said:
Are you still working on this guide?
I'ld love to try it, but I'm a little frightened since there seem to be issues about future udates of Lineage (see previous post).
Click to expand...
Click to collapse
Sorry for the late reply. For sure, but for now, I don't have with me my opo.
But if I understand correctly
BoquinhaSK said:
Update:
I was wrong, /system seems to be the same size on running sfdisk. The cause of the update fail must be somewhere else.
Click to expand...
Click to collapse
update problems are not the repartition procedure.
BoquinhaSK said:
I still don't understand why TWRP displays /system as 1303MB again though. Any idea?
Click to expand...
Click to collapse
I suppose that TWRP is built with 1.3Gb size limit (like everything that is based on opo device tree) and without mounting the filesystem show this static value.
But the power of this procedure (and the resize script) is that you can safely install your preferred rom. The filesystem is expanded in order to fill the 'new' partition size.
During my experiments, I've updated a lineage os (also simulating OTA by pushing a recovery command into the /cache partition), with and without GAPPS.
This guide, if executed step by step, should be safe.
I'm testing again my procedure. This is my situation
Code:
bacon:/ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/block/mmcblk0p14 2.7G 1.0G 1.7G 38% /
/dev/block/mmcblk0p28 52G 15G 37G 30% /data
I've latest official lineageos with some Gapps.
Now I'm waiting for an official OTA to see if anything goes wrong.
Hi all,
I've uploaded a new bacon-resize-system.zip that fixes the issue with OTA (wrong escape sequence when creating survival script in the updater binary).
Thanks all for the bug report.
Cheers
Michele
ilmich said:
Hi all,
I've uploaded a new bacon-resize-system.zip that fixes the issue with OTA (wrong escape sequence when creating survival script in the updater binary).
Thanks all for the bug report.
Cheers
Michele
Click to expand...
Click to collapse
Hello sir,
I am still using OPO in 2021 and i want 5gb system partition.. What will be start and end sectors for that changes? I am really confused so can you please recreate your post for 5gb and will you post it in reply?
Another one question if i flashed stock rom via fastboot then it will restore partition size to default or changes still remain which we did?
Thank You.
pbankar7 said:
Hello sir,
I am still using OPO in 2021 and i want 5gb system partition.. What will be start and end sectors for that changes? I am really confused so can you please recreate your post for 5gb and will you post it in reply?
Another one question if i flashed stock rom via fastboot then it will restore partition size to default or changes still remain which we did?
Thank You.
Click to expand...
Click to collapse
Code:
adb shell
cd /tmp
umount /data
umount /sdcard
echo "4521984,51G" | ./sfdisk-arm --no-reread -N 28 /dev/block/mmcblk0
After that
Code:
Device Start End Sectors Size Type
/dev/block/mmcblk0p28 4521984 111476735 106954752 51G unknown
After this
Code:
echo "111476736,+" | ./sfdisk-arm --no-reread -N 14 /dev/block/mmcblk0
Am I right for 4.8gb??
Please answer of this 2 questions
1. If i flashed stock rom via fastboot then it will restore partition size to default or changes still remains which we did?
2. It is necessary to flash bacon-resize-system.zip everytime whenever we flash new custom rom or after ota updates?
Thank You.
ilmich said:
WARNING!!!​Everyone is responsible for the proper functioning of their device. This guide is the result of personal experiments and I'm not responsible for any damage caused to your device as a result of improper use of its contents.
Introduction
Stock partitions layout has a 1.3Gb /system partition that is too small for users that flash modern custom roms + some kinds of google apps.
This is a step by step guide to change the layout of the partitions table with a bigger /system partition.
How
On OnePlus One, stock partition table looks like the following
Code:
... ... ...
/dev/block/mmcblk0p14 : start= 294912, name="system"
/dev/block/mmcblk0p15 : start= 3006464, name="persist"
/dev/block/mmcblk0p16 : start= 3072000, name="cache"
... ... ...
/dev/block/mmcblk0p28 : start= 4521984, name="userdata"
/dev/block/mmcblk0p29 : start= 121552896, name="grow"
With this layout, resizing the /system partition may seem difficult because it's close to other very important partitions.
So I've experimented with another approach. By resizing userdata partition, and relocate the /system partition at the beginning of the resulting free space, other partitions are left untouched.
There are mainly two (little) issues
almost all custom roms out of there assume that /system partition is 1.3gb of size
on internal storage the old area of /system partition are unused.
For the first point, the solution is to resize the filesystem when you first flash a custom rom. To automatically resize filesystem at every update there is an addon.d script.
For the second point the new free space available (the old 1.3G /system partition) can be used as a new /cache partition.
And, again, the new free space available (the old /cache partition) can be the famous /vendor partition (that is out of the scope of this guide).
This guide uses the sfdisk tool from util-linux. In my opinion, it's more powerful than parted and it's easy to use via script.
IMPORTANT - Before you start
Obviously, this method is destructive regarding userdata partition, so make a full backup of your data.
Manually resizing filesystem of /system partition is needed only once because the addon.d script will ensure that everything works as expected. The only exception is when you wipe /system and flash a new rom
Prerequisites
a working TWRP recovery installed on device
knowledge of adb tools
a statically cross compiled sfdisk tool (you can self compile, or use the one attached below)
this addon.d script (thanks to @osmosis)
flashable zip of a custom rom (and optionally gapps, magisk etc etc etc)
flashable zip bacon-resize-system.zip (attached on this post)
Let's go
enter TWRP recovery and connect phone on a PC
push sfdisk into a temporary dir and ensure is executable
Code:
adb push sfdisk-arm /tmp
adb shell
cd /tmp
chmod 755 sfdisk-arm
make and pull a backup of your partition table (there is also the 64Gb stock layout in attachments)
Code:
./sfdisk-arm -d /dev/block/mmcblk0 > bacon.gpt
exit
adb pull /tmp/bacon.gpt
looking into the partition table you see that userdata partition starts at sector 4521984.
So in order to resize partition (for example 53G instead of 55,8G).
Code:
adb shell
cd /tmp
umount /data
umount /sdcard
echo "4521984,53G" | ./sfdisk-arm --no-reread -N 28 /dev/block/mmcblk0
. Scrolling down the output of this command the new userdata partition is
Code:
Device Start End Sectors Size Type
/dev/block/mmcblk0p28 4521984 115671039 111149056 53G unknown
so the start sector of /system partition will be 115671040 (115671039+1)
relocating system partition at the end of the new userdata partition(size now will be 2,8G)
Code:
echo "115671040,+" | ./sfdisk-arm --no-reread -N 14 /dev/block/mmcblk0
reboot recovery (kernel need to reload partition table)
Code:
reboot recovery
format userdata with TWRP(no wipe... full format)
push custom rom with adb and flash with TWRP (without rebooting)
flash bacon-resize-system.zip
finish.. you can now reboot or continue with flashing gapps, magisk etc etc (but now with a bigger system partition)
Rollback
TODO
Nice to have
flashable zip for addon.d script (WIP)(DONE)
Click to expand...
Click to collapse
I'm interested in installing Ubuntu touch on my OnePlus One but since I used this guide successfully to resize my system partition I don't think I can install it without restoring the partition tables. How can I restore the partitions properly without bricking my phone?
Hi all. Please help.
I ruined my OPO phone.
iI followed the steps correctly.
After reboot the system partition cannot mount.
I see in the log:
Failed to mount '/system' (invalid argument)
My GPT after the change:
/tmp # fdisk -l /dev/block/mmcblk0
Found valid GPT with protective MBR; using GPT
Disk /dev/block/mmcblk0: 122142720 sectors, 2296M
Logical sector size: 512
Disk identifier (GUID): 98101b32-bbe2-4bf2-a06e-2bb33d000c20
Partition table holds up to 32 entries
First usable sector is 34, last usable sector is 122142686
Number Start (sector) End (sector) Size Code Name
1 16384 147455 64.0M 0700 modem
2 147456 148479 512K 0700 sbl1
3 148480 148543 32768 0700 dbi
4 163840 163903 32768 0700 DDR
5 180224 182271 1024K 0700 aboot
6 182272 183271 500K 0700 rpm
7 196608 229375 16.0M 0700 boot
8 229376 230375 500K 0700 tz
9 230376 232423 1024K 0700 pad
10 232424 235495 1536K 0700 modemst1
11 235496 238567 1536K 0700 modemst2
12 238568 259047 10.0M 0700 oppodycnvbk
13 259048 279527 10.0M 0700 oppostanvbk
14 115671040 121552895 2872M 0700 system
15 3006464 3071999 32.0M 0700 persist
16 3072000 4120575 512M 0700 cache
17 4120576 4153343 16.0M 0700 recovery
18 4153344 4156415 1536K 0700 fsg
19 4161536 4161537 1024 0700 fsc
20 4161538 4161553 8192 0700 ssd
21 4161554 4163601 1024K 0700 misc
22 4163602 4196369 16.0M 0700 LOGO
23 4196370 4261905 32.0M 0700 DRIVER
24 4261906 4327441 32.0M 0700 reserve1
25 4327442 4360209 16.0M 0700 reserve2
26 4360210 4376593 8192K 0700 reserve3
27 4376594 4507665 64.0M 0700 reserve4
28 4521984 115671039 53.0G 0700 userdata
29 121552896 122142686 287M 0700 grow
/tmp # cat /etc/fstab
/dev/block/mmcblk0p1 /firmware vfat rw 0 0
/dev/block/mmcblk0p14 /system ext4 rw 0 0
/dev/block/mmcblk0p28 /data ext4 rw 0 0
/dev/block/mmcblk0p16 /cache ext4 rw 0 0
/tmp # df -h
Filesystem Size Used Available Use% Mounted on
tmpfs 1.4G 32.0K 1.4G 0% /dev
tmpfs 1.4G 28.0K 1.4G 0% /tmp
/dev/block/mmcblk0p16
503.9M 8.4M 495.5M 2% /cache
/dev/block/mmcblk0p28
52.2G 180.0M 52.0G 0% /data
/dev/block/mmcblk0p28
52.2G 180.0M 52.0G 0% /sdcard
dimitrios5000 said:
Hi all. Please help.
I ruined my OPO phone.
iI followed the steps correctly.
After reboot the system partition cannot mount.
I see in the log:
Failed to mount '/system' (invalid argument)
My GPT after the change:
/tmp # fdisk -l /dev/block/mmcblk0
Found valid GPT with protective MBR; using GPT
Disk /dev/block/mmcblk0: 122142720 sectors, 2296M
Logical sector size: 512
Disk identifier (GUID): 98101b32-bbe2-4bf2-a06e-2bb33d000c20
Partition table holds up to 32 entries
First usable sector is 34, last usable sector is 122142686
Number Start (sector) End (sector) Size Code Name
1 16384 147455 64.0M 0700 modem
2 147456 148479 512K 0700 sbl1
3 148480 148543 32768 0700 dbi
4 163840 163903 32768 0700 DDR
5 180224 182271 1024K 0700 aboot
6 182272 183271 500K 0700 rpm
7 196608 229375 16.0M 0700 boot
8 229376 230375 500K 0700 tz
9 230376 232423 1024K 0700 pad
10 232424 235495 1536K 0700 modemst1
11 235496 238567 1536K 0700 modemst2
12 238568 259047 10.0M 0700 oppodycnvbk
13 259048 279527 10.0M 0700 oppostanvbk
14 115671040 121552895 2872M 0700 system
15 3006464 3071999 32.0M 0700 persist
16 3072000 4120575 512M 0700 cache
17 4120576 4153343 16.0M 0700 recovery
18 4153344 4156415 1536K 0700 fsg
19 4161536 4161537 1024 0700 fsc
20 4161538 4161553 8192 0700 ssd
21 4161554 4163601 1024K 0700 misc
22 4163602 4196369 16.0M 0700 LOGO
23 4196370 4261905 32.0M 0700 DRIVER
24 4261906 4327441 32.0M 0700 reserve1
25 4327442 4360209 16.0M 0700 reserve2
26 4360210 4376593 8192K 0700 reserve3
27 4376594 4507665 64.0M 0700 reserve4
28 4521984 115671039 53.0G 0700 userdata
29 121552896 122142686 287M 0700 grow
/tmp # cat /etc/fstab
/dev/block/mmcblk0p1 /firmware vfat rw 0 0
/dev/block/mmcblk0p14 /system ext4 rw 0 0
/dev/block/mmcblk0p28 /data ext4 rw 0 0
/dev/block/mmcblk0p16 /cache ext4 rw 0 0
/tmp # df -h
Filesystem Size Used Available Use% Mounted on
tmpfs 1.4G 32.0K 1.4G 0% /dev
tmpfs 1.4G 28.0K 1.4G 0% /tmp
/dev/block/mmcblk0p16
503.9M 8.4M 495.5M 2% /cache
/dev/block/mmcblk0p28
52.2G 180.0M 52.0G 0% /data
/dev/block/mmcblk0p28
52.2G 180.0M 52.0G 0% /sdcard
Click to expand...
Click to collapse
have you figured it out?
i was succeeded, through
Failed to mount '/system' (invalid argument)
i have seen also.
i was able to sideload lineage and boot it.
After rebooting into recovery the error message was away.
After that i sideloaded lienage again, then bacon-resize-system.zip.
After that i was able to sideload Gapps Nano, the required size check was successful
Oh wait, you have OPO Phone, not OnePlus One
you can try to restore your partiotion table from backup created earlier
Bash:
./sfdisk-arm -f /dev/block/mmcblk0 < bacon.gpt
OnePlus One (Bacon) 3/64
twrp-3.6.0_9-0-bacon.img
lineage-18.1-20211223-nightly-bacon-signed.zip
open_gapps-arm-11.0-nano-20220112.zip

[TUTORIAL] How to resize system partition on Galaxy S3 for larger GAPPS

On newer Android versions, the system occupies more of the system partition and with GAPPS upgrades, larger GAPPS packages (such as stock and mini) cannot fit on the system partition of the 2012 Galaxy S3. You can just use pico or nano, but sometimes you want the full GAPPS, the real deal. This is also necessary for upcoming ROMs that come with GAPPS preinstalled, such as Pixel Experience. To do this, you must resize the system partition. You can do this by taking some of the space from the cache partition and giving it to the system partition.
PLEASE NOTE: This process is not risk-free! If you do not know what you are doing, I strongly advise against this procedure. I am not responsible for any bricked devices or issues you may face. You have been warned.
Requirements:
A Samsung Galaxy S3. I have the i9300 model, where I have tested it.
parted, downloadable from here. If it downloads as a txt file, delete the extension by renaming it without the txt.
TWRP installed on your device (available for i9300 from here.)
A computer with ADB installed and relevant drivers.
First of all, you must boot TWRP. Once booted, wipe all partitions in TWRP, including system. Reboot back into recovery. Then go into mount and deselect all devices, and uncheck the box saying "Mount system partition as read-only"
Secondly, connect your S3 and send parted to the device with the following command:
Code:
adb push <path_to_parted> /
Thirdly, enter the ADB shell with the following command:
Code:
adb shell
Now, give executable permission to the parted file with the following command:
Code:
chmod +x parted
Now run:
Code:
./parted /dev/block/mmcblk0
Run the print command and you will get a list of partitions. It should look something like:
Code:
Model: MMC VTU00M (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 4194kB 8389kB 4194kB BOTA0
2 8389kB 12.6MB 4194kB BOTA1
3 12.6MB 33.6MB 21.0MB ext4 EFS
4 33.6MB 41.9MB 8389kB PARAM
5 41.9MB 50.3MB 8389kB BOOT
6 50.3MB 58.7MB 8389kB RECOVERY
7 58.7MB 92.3MB 33.6MB RADIO
8 92.3MB 1166MB 1074MB ext4 CACHE
9 1166MB 2777MB 1611MB ext4 SYSTEM
10 2777MB 3364MB 587MB ext4 HIDDEN
11 3364MB 3372MB 8389kB OTA
12 3372MB 15.8GB 12.4GB ext4 USERDATA
Make a note of the Start and End points for partitions 8 and 9 (CACHE and SYSTEM). In my case, the start and end points for partition 8 are 92.3 and 1166 and the start and end points for partition 9 are 1166 and 2777.
What we're going to do is delete these two partitions, then recreate them, but make the new partition 8 (Cache) smaller and allocate the space left to partition 9 (System).
Remove them with the following commands in parted:
Code:
./parted /dev/block/mmcblk0 rm 8
./parted /dev/block/mmcblk0 rm 9
Now recreate them with the following commands:
Code:
./parted /dev/block/mmcblk0 mkpart primary <cache_start> <cache_start+200>
./parted /dev/block/mmcblk0 mkpart primary <cache_end> <system_end>
Replace <cache_start> with the start of the former cache petition. In my case, it would be:
Code:
./parted /dev/block/mmcblk0 mkpart primary 92.3 292
./parted /dev/block/mmcblk0 mkpart primary 292 2777
Now name the partitions.
Code:
./parted /dev/block/mmcblk0 name 8 CACHE
./parted /dev/block/mmcblk0 name 9 SYSTEM
Then format them as ext4:
Code:
mke2fs -T ext4 /dev/block/mmcblk0p8
mke2fs -T ext4 /dev/block/mmcblk0p9
Run ./parted, followed by print, to check if the changes have been applied. If so, well done! You have successfully enlarged the system partition. Exit parted with the quit command.
Now configure and exit:
Code:
mount -a
exit
Reboot back into recovery and install any ROM of your choice. Once you've installed the ROM, reboot into recovery once again, and navigate to wipe --> advanced wipe, select system, tap repair or change filesystem, then resize.
You can now install any GAPPS of your choice. I've gotten LineageOS 16.0 working with mini gapps (Google Play Store + some Google apps) and it is working fine. You could make the system partition bigger by borrowing some more MB from the cache partition, or experimenting further by taking some from the HIDDEN partition. Remember, I am NOT responsible for any damage done when doing this. You assume full responsibility for any problems with the device. I hope this tutorial did help you, feel free to post here if it did or ask for help if you need it.
Did you experiment this process for a long time ? With so small a cache what could be the consequences ?
A finally do you know what is the use of HIDDEN partition ?
Great tutorial anyway.
barbe31 said:
Did you experiment this process for a long time ? With so small a cache what could be the consequences ?
Click to expand...
Click to collapse
Newer Android versions don't use up as much in the cache partition. If you're on say stock ICS or JB you may encounter some issues but if you're using LOS 15 or 16 it should work fine. I've used LOS 16 with GAPPS using this method for a while on my S3 and it's been fine.
ChasTechProjects said:
parted, downloadable from here.
Click to expand...
Click to collapse
Link says file doesn't exist.
petera703 said:
Link says file doesn't exist.
Click to expand...
Click to collapse
parted
drive.google.com
Cheers for that. I've been trying for some time to do the same thing on a Galaxy S4 Mini, working from a few variations of this process that I've found here and there, but never with any success. All appears to go well, with no errors, but it doesn't stick--the device just reverts to the previous partition sizes on reboot..
I've been using parted 3.2. I wondered if it would work with the parted you were using, but the one from your new link is 1.8 and doesn't even get as far for me (tried that one previously and it gets errors on my device).
If anyone know how to overcome the issue of resized partitions not surviving a reboot on Android, please help! I've been unable to solve it.
If it was plain Linux, it would be something to do with fstab, but fstab is never mentioned in the posts where people succeed in resizing Android partitions, so I think it must be something else, and perhaps something that varies from one device to another. Looking forward to any suggestions--thanks!
Can this idea/technique be applied to other *droid based devices
like Nook HD ?
[ Having same 'not enough space for the gaps' issue]

Categories

Resources