[GUIDE] Increase your Nexus 4's system partition for more space! - Nexus 4 General

I got tired of installing amazing ROMs created by the talented folks here on XDA, but being held back on things like Google Apps because of the tiny /system partition we have on the Nexus 4. I looked around and found guides to increase the system space in the Nexus 5 and Nexus 7 2013, so I basically just adapted them to work on our beloved Nexus 4.
As always, do this at your OWN risk. I am not responsible for bricking your Nexus 4. I will simply list the process which I used to increase my Nexus 4's system partition (by taking a big ol' chunk from the cache partition). Remember, any sort of modification to your device of this caliber WILL void any warranty you might still have.
REQUIREMENTS:
parted (Uploaded to my Google Drive. If it downloads as a .txt, rename it to remove the extension and make it a plain file)
adb and fastboot, and preferably knowledge on how they work
Step 1: Install TWRP onto your Nexus 4 and reboot into it.
Step 2: Open up command prompt / terminal and check to see if your Nexus 4 is connected properly with "adb devices".
Step 3: Once you've confirmed that adb is fully working and your Nexus 4 is properly connected to your PC, download parted and use adb to push it to your Nexus 4 using the command:
Code:
adb push parted /
Step 4: Now enter the following command:
Code:
adb shell
and then the command:
Code:
chmod +x parted
This will enter adb shell and make the "parted" binary you pushed to your device earlier executable.
Step 5:
Now run the command
Code:
./parted /dev/block/mmcblk0 p
You should see a long list with a bunch of numbers and names in your terminal. These are the partitions on your device. parted will give you the partition number, the "start" and "end" of the partition, the size, and the name.
This is the partition layout on my device. It will probably be the same on your device, though the size of userdata may vary depending on whether you have the 8gb or 16gb Nexus 4.
Code:
~ # ./parted /dev/block/mmcblk0 p
Model: MMC 016G92 (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 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.2MB 524kB sbl1
3 68.2MB 68.7MB 524kB sbl2
4 68.7MB 70.8MB 2097kB sbl3
5 70.8MB 71.3MB 524kB tz
6 71.3MB 94.4MB 23.1MB boot
7 94.4MB 117MB 23.1MB recovery
8 117MB 118MB 799kB m9kefs1
9 118MB 119MB 799kB m9kefs2
10 119MB 120MB 799kB m9kefs3
11 120MB 121MB 524kB rpm
12 121MB 121MB 524kB aboot
13 121MB 122MB 524kB sbl2b
14 122MB 124MB 2097kB sbl3b
15 124MB 124MB 524kB abootb
16 124MB 125MB 524kB rpmb
17 125MB 125MB 524kB tzb
18 125MB 126MB 524kB metadata
19 126MB 143MB 16.8MB misc
20 143MB 159MB 16.8MB ext4 persist
21 159MB 1040MB 881MB ext2 system
22 1040MB 1627MB 587MB ext4 cache
23 1627MB 15.8GB 14.1GB ext4 userdata
24 15.8GB 15.8GB 524kB DDR
25 15.8GB 15.8GB 507kB grow
Step 6:
Now run the following three commands:
Code:
umount /data
umount /sdcard
umount /cache
Step 7: So, on my Nexus 4, the system partition is number 21, and cache is 22. We're kinda lucky in the fact that system and cache are right next to each other, meaning we don't have to touch any other partition.
You'll want to run these two next commands. These commands will essentially "remove" the two partitions.
Code:
./parted /dev/block/mmcblk0 rm 21
./parted /dev/block/mmcblk0 rm 22
Step 8: Now it is time to recreate these two partitions, however, when recreating them, we will make system bigger and the cache smaller. From the partitions list we got in Step 5, we can see that system starts at 159 and ends at 1040, while cache starts at 1040 and ends at 1627. The following two commands will rebuild /system starting at 159, but ending at 1590, while rebuilding cache at 1590, and ending at 1627. We are essentially stealing a large chunk from cache, since we don't really need that anymore on newer ROMs.
Code:
./parted /dev/block/mmcblk0 mkpart primary 159 1590
./parted /dev/block/mmcblk0 mkpart primary 1590 1627
Step 9: Now run this command:
Code:
./parted /dev/block/mmcblk0 p
This will bring up the partitions list, or table, again. This time, however, we'll see the new partitions where system and cache were, however, they have no names! The following two commands will name the two partitions again.
Code:
./parted /dev/block/mmcblk0 name 21 system
./parted /dev/block/mmcblk0 name 22 cache
Step 10: Great! Now the partitions should be named again! Now, we still have to format the partitions as ext4 so that we can actually use them. The following two commands will do that for you.
Code:
mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p21
mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p22
Step 11: At this point, feel free to run the command from Step 5 to take one more look at the partition table and make sure everything looks good. Now run the command
Code:
mount -a
and then type in
Code:
exit
.
Step 12: Now we are pretty much done. We've extended the system partition from approx. 881mb to 1431mb, which is a nice large chunk of memory. In the future, we could always mess with the partitions more to add even more space by stealing from userdata, but until we reach that point, I think we are pretty well set for now!
Now...
You'll want to reboot TWRP, and flash a new ROM. You can now use a much bigger Google Apps package, without any worries.
Do note, however, that flashing a ROM will "resize" system to be smaller, but this isn't a huge deal. After flashing a ROM, while still in TWRP, you'll want to go to Wipe > Advanced Wipe > check "system" then head to "Repair or Change File System", > then tap on "Resize File System." If you encounter any errors while trying to resize, try remounting system or rebooting TWRP. Afterwards, you should be able to flash your Google Apps package. I'm not sure if you need to repeat these steps after flashing things other than ROMs, but repeating this process within TWRP should work just as well.
I hope I helped y'all out and feel free to post if this guide worked for you or if you have any other comments!
CREDITS:
@surfrock66 for his Nexus 5 guide here.
@rkhat for his Nexus 7 2013 guide here.

RESERVED

Worked Thanx

It worked here on my 8 Gb mako. Here are the original parted output:
Code:
Model: MMC 008G92 (sd/mmc)
Disk /dev/block/mmcblk0: 7818MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.2MB 524kB sbl1
3 68.2MB 68.7MB 524kB sbl2
4 68.7MB 70.8MB 2097kB sbl3
5 70.8MB 71.3MB 524kB tz
6 71.3MB 94.4MB 23.1MB boot
7 94.4MB 117MB 23.1MB recovery
8 117MB 118MB 799kB m9kefs1
9 118MB 119MB 799kB m9kefs2
10 119MB 120MB 799kB m9kefs3
11 120MB 121MB 524kB rpm
12 121MB 121MB 524kB aboot
13 121MB 122MB 524kB sbl2b
14 122MB 124MB 2097kB sbl3b
15 124MB 124MB 524kB abootb
16 124MB 125MB 524kB rpmb
17 125MB 125MB 524kB tzb
18 125MB 126MB 524kB metadata
19 126MB 143MB 16.8MB misc
20 143MB 159MB 16.8MB ext4 persist
21 159MB 1040MB 881MB ext2 system
22 1040MB 1627MB 587MB ext4 cache
23 1627MB 7817MB 6190MB ext4 userdata
24 7817MB 7818MB 524kB DDR
25 7818MB 7818MB 507kB grow
I'm using Nitrogen OS 8.1 with GZR Gapps

jfsobreira said:
It worked here on my 8 Gb mako. Here are the original parted output:
Code:
Model: MMC 008G92 (sd/mmc)
Disk /dev/block/mmcblk0: 7818MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.2MB 524kB sbl1
3 68.2MB 68.7MB 524kB sbl2
4 68.7MB 70.8MB 2097kB sbl3
5 70.8MB 71.3MB 524kB tz
6 71.3MB 94.4MB 23.1MB boot
7 94.4MB 117MB 23.1MB recovery
8 117MB 118MB 799kB m9kefs1
9 118MB 119MB 799kB m9kefs2
10 119MB 120MB 799kB m9kefs3
11 120MB 121MB 524kB rpm
12 121MB 121MB 524kB aboot
13 121MB 122MB 524kB sbl2b
14 122MB 124MB 2097kB sbl3b
15 124MB 124MB 524kB abootb
16 124MB 125MB 524kB rpmb
17 125MB 125MB 524kB tzb
18 125MB 126MB 524kB metadata
19 126MB 143MB 16.8MB misc
20 143MB 159MB 16.8MB ext4 persist
21 159MB 1040MB 881MB ext2 system
22 1040MB 1627MB 587MB ext4 cache
23 1627MB 7817MB 6190MB ext4 userdata
24 7817MB 7818MB 524kB DDR
25 7818MB 7818MB 507kB grow
I'm using Nitrogen OS 8.1 with GZR Gapps
Click to expand...
Click to collapse
Awesome! Thanks for letting me know. Glad it worked for you. :good:

thank you very much !

Thx !
Thx !

Great guide works perfectly.. has anyone tried to reverse the process and go back to stock to reflash a factory image?
I just tried it on my old Nexus 4, and after resettting the partitions, and reflashing the factory image, its just a permanent bootloop. I've cleared all the cache, tried a wipe from the stock recovery, tried flashing TWRP and wiping there.. nothing seems to work. Im not too worried, but it'd be nice if it could boot again.

Thanks for your guide. It worked like a charm for my Nexus 4.
Just a small addition: To resize the system partition automatically I placed a script in /system/addon.d:
Code:
#!/sbin/sh
#
# /system/addon.d/10-resize-system.sh
#
. /tmp/backuptool.functions
case "$1" in
backup)
# Stub
;;
restore)
# Stub
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
/sbin/resize2fs /dev/block/platform/msm_sdcc.1/by-name/system
;;
post-restore)
# Stub
;;
esac

If it doesn't work for you
Thanks for this great guide!
Decided to breath some new life into an old N4 in my family and now it's going (very) strong again with LineageOS 15.1. Still had to clear a bit over 100 MB with .gapps-config from Stock-OpenGapps, but that's no biggie. I always liked to start with the big package and then remove everything that I don't need from it.
Second issue gave me some headaches at first.
"Resize File System" in TWRP apparently worked and Gapps-Install went through (~100 MB free at the end), but boot would fail and crash back to recovery.
(I'm using the daily LOS-nightlies by Milaq and Stock-Package from OpenGapps, maybe it's no problem with other ROMs and/or Gapps-Packages.)
Turns out the fix in TWRP wasn't really working, nevermind what partition size it shows for /system afterwards. It's somehow corrupted and still has the original size -> most of the gapps stuff get's written to nirvana, thus the failing boot.
I found the solution over in the Nexus5-Thread:
JekaPinsk said:
Hello guys!
Try this:
1) Install ROM
2) Backup ROM
3) Enable "Use 'rm -rf' instead of formatting" in TWRP settings
4) Format /system
4.1) Unmount /system and use 'resize2fs -f /dev/block/mmcblk0p21' in terminal (TWRP)
5) Reboot TWRP
5.1) Uncheck "Use 'rm -rf' instead of formatting" in TWRP settings
6) Restore backup
7) Install Stock OpenGapps
8) Done!
The idea behind it is that ROM installation somehow corrupt /system partition thus any write operations above normal data region silently fail.
Click to expand...
Click to collapse
at step 4.1 I already changed the partition number to 21 for Nexus4. In the original post it says mmcblk0p25, because on the Nexus 5 that's /system.
Now it works.
In theory this procedure should also work for updating the ROM without losing data, but haven't tested it yet. (Maybe throw in a wipe of /system as step 0...?)
To be clear: This isn't the fault of the guide to resize system-partition.
Problem is (at least certain) ROMs resetting size of file system to original and then TWRP failing to fix that doing it the easy way as described in OP (-> bug in TWRP?).
EDIT:
Above procedure also works for an update without data loss. Only difference was I did a normal wipe of /system first, "step 0" so to say.
No idea if all this is still necessary with TWRP 3.2.3-0, I'm not willing to risk a full wipe at this point. ^^

i need this...can't even install the smallest gapps package after oreo.... word!! thanks!

Really wanted to thank-you for this!
Two questions:
1. When you printed the partitions, system (21) was ext2. When you recreated it after resizing, you created it as ext4. Was that intentional?
2. You also made the claim that modern ROMs don't need such a big cache partition (your new one was 37MB, I wasn't so brave). Can you justify that claim or provide some technical details? It's not that I don't believe you (I trusted you enough to do this on my device!), just merely curious as to why/how this would be.
Thanks!

X:\xxx\xxx\xxx\xxx\adb>adb push parted /
487 KB/s (346680 bytes in 0.695s)
X:\xxx\xxx\xxx\xxx\adb>adb shell
~ # chmod +x parted
chmod +x parted
~ # ./parted /dev/block/mmcblk0 p
./parted /dev/block/mmcblk0 p
Error: Can't have overlapping partitions.
~ # 
Please Help!!!!!!!!!!!!!!!!!!!

caliban2 said:
Thanks for this great guide!
Decided to breath some new life into an old N4 in my family and now it's going (very) strong again with LineageOS 15.1. Still had to clear a bit over 100 MB with .gapps-config from Stock-OpenGapps, but that's no biggie. I always liked to start with the big package and then remove everything that I don't need from it.
Second issue gave me some headaches at first.
"Resize File System" in TWRP apparently worked and Gapps-Install went through (~100 MB free at the end), but boot would fail and crash back to recovery.
(I'm using the daily LOS-nightlies by Milaq and Stock-Package from OpenGapps, maybe it's no problem with other ROMs and/or Gapps-Packages.)
Turns out the fix in TWRP wasn't really working, nevermind what partition size it shows for /system afterwards. It's somehow corrupted and still has the original size -> most of the gapps stuff get's written to nirvana, thus the failing boot.
I found the solution over in the Nexus5-Thread:
at step 4.1 I already changed the partition number to 21 for Nexus4. In the original post it says mmcblk0p25, because on the Nexus 5 that's /system.
Now it works.
In theory this procedure should also work for updating the ROM without losing data, but haven't tested it yet. (Maybe throw in a wipe of /system as step 0...?)
To be clear: This isn't the fault of the guide to resize system-partition.
Problem is (at least certain) ROMs resetting size of file system to original and then TWRP failing to fix that doing it the easy way as described in OP (-> bug in TWRP?).
EDIT:
Above procedure also works for an update without data loss. Only difference was I did a normal wipe of /system first, "step 0" so to say.
No idea if all this is still necessary with TWRP 3.2.3-0, I'm not willing to risk a full wipe at this point. ^^
Click to expand...
Click to collapse
I'm using TWRP 3.2.3-0 and it has this bug, too. After I followed your steps I was able to install Nitrogen OS and Open Gapps Micro in my phone without erros.
Thanks!

I believe that resize2fs step can be packaged as a flashable zip so we can batch flashing without manual intervention to it (i.e. manually resize fs on system after each rom flash) .

ivanich said:
I believe that resize2fs step can be packaged as a flashable zip so we can batch flashing without manual intervention to it (i.e. manually resize fs on system after each rom flash) .
Click to expand...
Click to collapse
Maybe then more users would dare to use this solution and could calmly install gapps on Pie.
You have a lot of experience. What do you suggest?

Hi all. I only discovered this thread after independently figuring out the partitioning scheme (plain GPT) and process.
Sadly, even after this effort, it seems L-OS upgrades won't work unless L-OS devs modify their upgrade script to make use of resize2fs. Here's what happens as of package 2018-09-11:
L-OS runs backup procedure for all addons found in the existing /system/addon.d/
The above creates files (I guess) in /tmp
The /system is unmounted
The partition is overwritten with the image in the upgrade package
The script in addon.d/ are then run to restore the addons from /tmp
The problem is, the partition image in the upgrade package is for the old partition size, and therefore step 5 fails when the free space runs out. It seems the install or restore scripts don't detect this failure, and just exit without reporting an error, with 0B free space on /system.
I'm guessing the problem can be "solved" by formatting the system partition and installing LOS and all addons from scratch, but that's ridiculous. has anyone tried to raise this issue with devs? I'm about to report this in L-OS's JIRA, as I haven't seen any relevant report there.
EDIT: If anyone wants to track: https://jira.lineageos.org/browse/BUGBASH-2306

myxal said:
Hi all. I only discovered this thread after independently figuring out the partitioning scheme (plain GPT) and process.
Sadly, even after this effort, it seems L-OS upgrades won't work unless L-OS devs modify their upgrade script to make use of resize2fs. Here's what happens as of package 2018-09-11:
L-OS runs backup procedure for all addons found in the existing /system/addon.d/
The above creates files (I guess) in /tmp
The /system is unmounted
The partition is overwritten with the image in the upgrade package
The script in addon.d/ are then run to restore the addons from /tmp
The problem is, the partition image in the upgrade package is for the old partition size, and therefore step 5 fails when the free space runs out. It seems the install or restore scripts don't detect this failure, and just exit without reporting an error, with 0B free space on /system.
I'm guessing the problem can be "solved" by formatting the system partition and installing LOS and all addons from scratch, but that's ridiculous. has anyone tried to raise this issue with devs? I'm about to report this in L-OS's JIRA, as I haven't seen any relevant report there.
EDIT: If anyone wants to track: https://jira.lineageos.org/browse/BUGBASH-2306
Click to expand...
Click to collapse
You may be able to fix that on your own by adding an add-on.d named 00-resize-system (so that's it's ran first) that just does "resize2fs /dev/block/.../system", with maybe an unmount before and a mount after. This way, LOS can just flash the full image when upgrading and the system is resized before the other addons.d scripts run.

Fif_ said:
You may be able to fix that on your own by adding an add-on.d named 00-resize-system (so that's it's ran first) that just does "resize2fs /dev/block/.../system", with maybe an unmount before and a mount after. This way, LOS can just flash the full image when upgrading and the system is resized before the other addons.d scripts run.
Click to expand...
Click to collapse
Thanks for the tip, will give that a try. Any idea where I could find an "authoritative" docs/guide to those scripts? Just looked at the one supplied by open g-apps, and I don't really see the difference between the various commands that the script is supposed to handle (which is executed when?). Also what list_file() is supposed to provide.
backup
restore
pre-backup
pre-restore
post-backup
post-restore

myxal said:
Thanks for the tip, will give that a try. Any idea where I could find an "authoritative" docs/guide to those scripts? Just looked at the one supplied by open g-apps, and I don't really see the difference between the various commands that the script is supposed to handle (which is executed when?). Also what list_file() is supposed to provide.
backup
restore
pre-backup
pre-restore
post-backup
post-restore
Click to expand...
Click to collapse
You want to put the resize2fs call in the pre-restore section.
It should look like this:
Code:
pre-restore)
unmount /system
resize2fs /dev/block/platform/.../system
mount /system
;;
This includes unmounting and remounting /system which I think are needed, but YMMV. You'll need to fill in the full path to system under /dev.
There is no authoritative resource for backup scripts that I know of, but the gapps script is a good example.
P.S.: If you make it work, please post the script for others...

Related

[Dualboot] i9082 {Stock 4.2.2/AOSP 4.4.2 and AOSP 4.4.2} 23032014 V2

Hi guys,
finally I found a way to make dualboot on our beloved i9082 working!!
This way isn't as much easy as on other devices like the desire HD where
you have just to install an app and everything is done by itself, so follow this
guide at your own risk!!
THIS IS WORST RISK YOU TAKE FOR YOUR PHONE>>>>
IT MAY BRICK YOUR PHONE.....
DONT DO IT IF YOU DONT KNOW WHAT YOU DOING...
How to dual boot your I9082...
1. Make a backup of your internal sdcard to your PC!! All your data on the sd card will be gone!
2. Reboot to cwm-recovery
3. connect your phone to your pc.
4, open up cmd or a terminal and type:
PHP:
adb shell
5. type:
PHP:
cd /dev/block
parted mmcblk0
print
This looks like following
Code:
print
Model: MMC M8G1WA (sd/mmc)
Disk /dev/block/mmcblk0: 7818MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 14.7MB 15.7MB 1049kB cal
2 15.7MB 16.0MB 262kB sysparm_dep
3 16.0MB 16.3MB 262kB parm-spml_dep
4 16.3MB 16.5MB 262kB RF_CAL_FILE
5 16.5MB 24.9MB 8389kB KERNEL
6 24.9MB 33.3MB 8389kB RECOVERY
7 33.3MB 53.0MB 19.7MB modem
8 53.0MB 86.2MB 33.3MB reserved
9 86.2MB 88.3MB 2097kB SBL1
10 88.3MB 90.4MB 2097kB SBL2
11 90.4MB 98.8MB 8389kB PARAM
12 98.8MB 99.4MB 524kB DTSBK
13 99.4MB 99.9MB 524kB DTS
14 99.9MB 108MB 8389kB VC-FirmwareBK
15 108MB 117MB 8389kB VC-Firmware
16 117MB 117MB 262kB FOTA_SIG
17 117MB 138MB 21.0MB ext4 efs
18 138MB 1212MB 1074MB ext4 CSC
19 1212MB 2822MB 1611MB ext4 system
20 2822MB 3409MB 587MB ext4 HIDDEN
21 3409MB 7813MB 4404MB ext4 data
The last partiton i.e data partion which is our internal SD card to be re partitioned .
6. Type
PHP:
rm 21
7. Note the start and end of the data partiton. In my case its 3409 and 7813
Firstly we have to create data partition. See the size of system partition i.e 1024 MB. So the new partion will be as follows
PHP:
mkpartfs primary ext2 3409 4433
second is system 2 partition
PHP:
mkpartfs primary ext2 4433 6044
next is cache2 partion
PHP:
mkpartfs primary ext2 6044 6744
next is data2 partion
Code:
mkpartfs primary ext2 6744 7813
Code:
quit
It will say
Code:
quit
Information: You may need to update /etc/fstab.
Ignore the warning Reboot into recovery again on pc type
Code:
adb shell
mke2fs /dev/block/mmcblk0p21
tune2fs -j /dev/block/mmcblk0p21
mke2fs /dev/block/mmcblk0p22
tune2fs -j /dev/block/mmcblk0p22
mke2fs /dev/block/mmcblk0p23
tune2fs -j /dev/block/mmcblk0p23
mke2fs /dev/block/mmcblk0p24
tune2fs -j /dev/block/mmcblk0p24
This will create ext3 partition from ext2
Now convert them to ext4
Code:
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p21
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p22
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p23
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p24
Now lets check everything is ok
Code:
cd /dev/block
parted mmcblk0
print
This should look like following
Code:
print
Model: MMC M8G1WA (sd/mmc)
Disk /dev/block/mmcblk0: 7818MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 14.7MB 15.7MB 1049kB cal
2 15.7MB 16.0MB 262kB sysparm_dep
3 16.0MB 16.3MB 262kB parm-spml_dep
4 16.3MB 16.5MB 262kB RF_CAL_FILE
5 16.5MB 24.9MB 8389kB KERNEL
6 24.9MB 33.3MB 8389kB RECOVERY
7 33.3MB 53.0MB 19.7MB modem
8 53.0MB 86.2MB 33.3MB reserved
9 86.2MB 88.3MB 2097kB SBL1
10 88.3MB 90.4MB 2097kB SBL2
11 90.4MB 98.8MB 8389kB PARAM
12 98.8MB 99.4MB 524kB DTSBK
13 99.4MB 99.9MB 524kB DTS
14 99.9MB 108MB 8389kB VC-FirmwareBK
15 108MB 117MB 8389kB VC-Firmware
16 117MB 117MB 262kB FOTA_SIG
17 117MB 138MB 21.0MB ext4 efs
18 138MB 1212MB 1074MB ext4 CSC
19 1212MB 2822MB 1611MB ext4 system
20 2822MB 3409MB 587MB ext4 HIDDEN
21 3409MB 4433MB 1024MB ext4
22 4433MB 6044MB 1611MB ext4
23 6044MB 6744MB 700MB ext4
24 6744MB 7813MB 1069MB ext4
Then
Code:
quit
Now flash your first stock ROM..ofcource custom one from recovery.
Now You can flash your desired AOSP rom as primary and dualboot enabled secondary rom.
Scripts to switch roms has been updated.
Download following dualboot enabled AOSP rom by me CosmicCm
http://www.androidfilehost.com/?fid=23329332407579496
Download following tool kit and extract on your External sd card for AOSP rom and in Internal SD for your stock rom.
http://www.androidfilehost.com/?w=files&flid=12981
Install smanager (os.tools.scriptmanager-1.apk) in zip.
Instructions on ROM switching:
1. Go to Play Store and install SManager (or included in dualboot-k2wl-V2.zip)
2. Run SManager, browse to your DualBoot folder and select "StockPrimary.sh/AOSPprimary.sh" or "AOSPSecondary.sh". depending upon which rom you want to boot into.
3. Mark favourite and su options and run the script.
4. Optional - SManager has a homescreen widget system. It lets you add buttons in your homescreens that will directly run the linked script (it has to be put in favourites first).
AGAIN this is a nuclear level risky procedure and is for ADVANCE users only....
DO NOT TRY IF YOU DONT KNOW WHAT YOU ARE DOING.......
Bugs:-
Your data partitions will be small about 1 GB.
External SD card not working in stock rom.
More?>..... You telll me...
HAPPY FLASHING.....
Credits:-
dreccon
berni987654321
51dusty
and for best inspiration and beta tester....
xenon92
Reverting
To revert
Boot into recovery
start
Code:
adb shell
Code:
cd /dev/block
parted mmcblk0
print
rm 24
rm 23
rm 22
rm 21
Code:
mkpartfs primary ext2 3409 7813
Code:
quit
Reboot into recovery again
on pc type
Code:
adb shell
mke2fs /dev/block/mmcblk0p21
tune2fs -j /dev/block/mmcblk0p21
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p21
now you reverted back.
another one
Awesome work bro
Thanks man
Sent from my GT-I9082 using Tapatalk
Awsm work bro..keep up the good wrk..stay blessed..
Sent from my GT-I9082 using Tapatalk 2
Does this method works with only cosmiccm ROM or it works with all aosp based ROM ?
Sent from my GT-I9082 using Tapatalk
Right now only CosmicCm but if developers willing for making their dualboot compatible rom, it wil.
k2wl said:
Right now only CosmicCm but if developers willing for making their dualboot compatible rom, it wil.
Click to expand...
Click to collapse
@k2wl
Please update your signature for awesome Rom "CosmicCm":good:
OMG!! REallyy Superb workk man:angel::angel:
good work mate but how to undo ..these all changes ? any procedure?
himuslg123 said:
good work mate but how to undo ..these all changes ? any procedure?
Click to expand...
Click to collapse
Flashing PIT file probably.
Sent from my GT-I9082 using Tapatalk
himuslg123 said:
good work mate but how to undo ..these all changes ? any procedure?
Click to expand...
Click to collapse
akiratoriyama said:
Flashing PIT file probably.
Sent from my GT-I9082 using Tapatalk
Click to expand...
Click to collapse
@himuslg123 @akiratoriyama
Look into the second post...
reverting changes...
thanks for the tutorials k2wl
but I have a doubt
suppose ..I have installed 2 roms
now if I want to flash a mod zip( i.e pagapps or so) file for a specific rom via CWM recovery ...ll they be installed on a specific partition for a specific rom ?
for second rom its a problem, i.e AOSP.
thats why i included gapps core in CosmicCM dual boot rom.
for original primary rom stock, you can flash any mods you want.
Give me links for the mods and gapps you wanted.
i will change them into dual boot...
aahh ..that's all I want ..you rock \m/
k2wl said:
for second rom its a problem, i.e AOSP.
thats why i included gapps core in CosmicCM dual boot rom.
for original primary rom stock, you can flash any mods you want.
Give me links for the mods and gapps you wanted.
i will change them into dual boot...
Click to expand...
Click to collapse
Well ..first thanks for this procedure..the more i thank u , the less it would be mahn!..
Now, as u say that u will help guys for mods to dual boot too, the only thing i flash after ur roms is ur kernel ... I dont think its already in there in cosmic rom,And cant live without evolution kernel mahn :|..but i think kernel flashing will screw things up right??
yes it might screw things up..
bt dont worry i will add option for evaluation dualboot kernel soon.
this is work in progress.
will add more options...
k2wl said:
yes it might screw things up..
bt dont worry i will add option for evaluation dualboot kernel soon.
this is work in progress.
will add more options...
Click to expand...
Click to collapse
general question plss..y kernel is not put as a default in ROM( I mean ur kernel and ur ROM).
Though it will not allow users of RR and carbon to use this kernel. just of curosity
Any possibility for a GUI apps or flashable zip to do all this procedure of dual boot in future development? What I mean is like GUI apps of EFS backup
wiryawang said:
Any possibility for a GUI apps or flashable zip to do all this procedure of dual boot in future development? What I mean is like GUI apps of EFS backup
Click to expand...
Click to collapse
No...not so soon...
firstly this is risky procedure
and second
i like commandline better.
better control and fast..
so i cant help you with this.

[Guide] Repartition Nexus5 to increase system partition - Space for Rom & Stock Gapps

[Guide] Repartition Nexus5 to increase system partition - Space for Rom & Stock Gapps
Before I begin...don't do this if you don't know what you're doing. If you know what you're doing still don't do this. This is dangerous, and in general people don't even make good guides for this likely because it's SUCH a stupid thing to do. Samsung phones support PIT re partitioning, but for something like a Nexus, there is no easy guide. You can and likely will brick your phone...at best you will certainly wipe all data.
I wanted to install a nougat rom on my cracked-screen Nexus5, but in flashing it AND stock gapps would error out since there isn't enough room on the /system partition for both. The Nexus5 comes with a 1GB system partition which was fine way back in the day, but isn't really fine anymore. In order to pull space from the large userdata partition, we need to do some linux trickery. I chose to make /system 2GB, which may be overkill, but this phone is going to be a baby monitor/white noise machine for a 5 month old so who cares.
The prerequisite for this process is a TWRP recovery, and that's pretty much it. Ideally, fdisk would be baked in with busybox or the parted utility would be on the phone and you could use the resize function...every time I tried to use busybox's fdisk led to errors or commands wouldn't work, and parted's resize command can't deal with ext4.
The high-level procedure here is, since filesystems must be contiguous and in order so they can be addressed properly, we need to delete every partition inclusively from system to userdata, then recreate them with new storage offsets. To visualize this, here's the storage layout as it started out on my Nexus 5:
Code:
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 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.7MB 1049kB sbl1
3 68.7MB 69.2MB 524kB rpm
4 69.2MB 69.7MB 524kB tz
5 69.7MB 70.3MB 524kB sdi
6 70.3MB 70.8MB 524kB aboot
7 70.8MB 72.9MB 2097kB pad
8 72.9MB 73.9MB 1049kB sbl1b
9 73.9MB 74.4MB 524kB tzb
10 74.4MB 75.0MB 524kB rpmb
11 75.0MB 75.5MB 524kB abootb
12 75.5MB 78.6MB 3146kB modemst1
13 78.6MB 81.8MB 3146kB modemst2
14 81.8MB 82.3MB 524kB metadata
15 82.3MB 99.1MB 16.8MB misc
16 99.1MB 116MB 16.8MB ext4 persist
17 116MB 119MB 3146kB imgdata
18 119MB 142MB 23.1MB laf
19 142MB 165MB 23.1MB boot
20 165MB 188MB 23.1MB recovery
21 188MB 191MB 3146kB fsg
22 191MB 192MB 524kB fsc
23 192MB 192MB 524kB ssd
24 192MB 193MB 524kB DDR
25 193MB 1267MB 1074MB ext4 system
26 1267MB 1298MB 31.5MB crypto
27 1298MB 2032MB 734MB ext4 cache
28 2032MB 31.3GB 29.2GB ext4 userdata
29 31.3GB 31.3GB 5632B grow
Looking at that, we want to increase system (partition 25), shift crypto (partition 26), shift cache (partition 27), and shrink userdata (partition 28). If you try this on a different phone, you'll have different partitions to move.
I did this from a Debian desktop using adb, but you can use any platform that has adb. You need to download the parted binary linked below, a nexus5 Nougat rom (or any rom I guess), and a gapps package (I chose stock). Here's the commands I used:
Code:
wget http://iwf1.com/iwf-repo/parted.rar
unrar e parted.rar
sudo adb push parted /
sudo adb shell
~ # chmod +x parted
~ # ./parted /dev/block/mmcblk0 p
~ # umount /data
~ # umount /sdcard
~ # umount /cache
~ # ./parted /dev/block/mmcblk0 rm 25
~ # ./parted /dev/block/mmcblk0 rm 26
~ # ./parted /dev/block/mmcblk0 rm 27
~ # ./parted /dev/block/mmcblk0 rm 28
~ # ./parted /dev/block/mmcblk0 mkpart primary 193MB 2291MB
~ # ./parted /dev/block/mmcblk0 mkpart extended 2291MB 2322MB
~ # ./parted /dev/block/mmcblk0 mkpart primary 2322MB 3056MB
~ # ./parted /dev/block/mmcblk0 mkpart primary 3056MB 30.8GB
~ # ./parted /dev/block/mmcblk0 p
~ # ./parted /dev/block/mmcblk0 name 25 system
~ # ./parted /dev/block/mmcblk0 name 26 crypto
~ # ./parted /dev/block/mmcblk0 name 27 cache
~ # ./parted /dev/block/mmcblk0 name 28 userdata
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p25
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p27
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p28
~ # ./parted /dev/block/mmcblk0 p
~ # mount -a
~ # exit
# Download from here: http://www.androiddevs.net/downloads/
sudo adb push aosp_hammerhead-7.1-nougat-*.zip /data/
# Download from here: http://opengapps.org/
sudo adb push open_gapps-arm-7.1-stock-*.zip /data/
sudo adb reboot recovery
# Install the nougat rom through twrp...this will resize the /system partition back to 1GB!
sudo adb shell
~ # umount /system
~ # resize2fs -f /dev/block/mmcblk0p25 2000M
~ # mount -a
# Install opengapps in twrp
~ # exit
# Reboot into system through TWRP GUI
There were some logging errors with the SantoshM nougat rom I tried, but they had no impact. I am unmounting /sdcard and that's where it's trying to stash the logs, hence errors.
You can see that the offsets for the new partitions are 1024MB higher than the originals, meaning the partition will be 1GB bigger. Here's my final partition table:
Code:
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 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.7MB 1049kB sbl1
3 68.7MB 69.2MB 524kB rpm
4 69.2MB 69.7MB 524kB tz
5 69.7MB 70.3MB 524kB sdi
6 70.3MB 70.8MB 524kB aboot
7 70.8MB 72.9MB 2097kB pad
8 72.9MB 73.9MB 1049kB sbl1b
9 73.9MB 74.4MB 524kB tzb
10 74.4MB 75.0MB 524kB rpmb
11 75.0MB 75.5MB 524kB abootb
12 75.5MB 78.6MB 3146kB modemst1
13 78.6MB 81.8MB 3146kB modemst2
14 81.8MB 82.3MB 524kB metadata
15 82.3MB 99.1MB 16.8MB misc
16 99.1MB 116MB 16.8MB ext4 persist
17 116MB 119MB 3146kB imgdata
18 119MB 142MB 23.1MB laf
19 142MB 165MB 23.1MB boot
20 165MB 188MB 23.1MB recovery
21 188MB 191MB 3146kB fsg
22 191MB 192MB 524kB fsc
23 192MB 192MB 524kB ssd
24 192MB 193MB 524kB DDR
25 193MB 2291MB 2098MB ext4 system
26 2291MB 2322MB 31.0MB crypto
27 2322MB 3056MB 734MB ext4 cache
28 3056MB 31.3GB 28.2GB ext4 userdata
29 31.3GB 31.3GB 5632B grow
When we resize /system, we're not quite giving it the whole space...I recommend running "resize2fs /dev/block/mmcblk0p25 2048M" and seeing the error...it's easier to adjust the actual filesystem size than the partition size, so we fudge it a bit here so long as it's safe. If this test is unsuccessful, it will tell you that you're allocating more blocks than you have. If it's successful, it'll tell you to run e2fsck...this is normal, and running the resize2fs command with the -f flag overrides that warning...but it'll also allow you to allocate too many blocks, hence why you run a test first as a sanity check. For this exact procedure, 2000M is the exact maximum size.
All in all, this technique can likely be adapted to other android phones. The key is making sure you resize system by the amount you take from data, and making sure you offset all partitions in between linearly by the correct amount. I'm not sure how updates will work...anything that basically lays down a partition is gonna cause issues since it'll try to resize to the default partition size. Anything just laying down new files should be fine.
Happy hacking!
I was looking for such an option as I wanted to install a bigger gapps package then just pico. But shrinking my userdata partition is not was i had in mind. I also really do not want to loose all my data, as i am leazy
so i was thinking about just resizing /cache to a bare minimum of lets say 128mb or even less. Because as i understand /cache is just used for OTA updates - if i am mistaken here, feel free to update my knowledge.
Has anybody done this? On the Galaxy Nexus this is the way to go afaik and one would not loose things in /data.
It worked, Thank you!
What i essentially did was make a nandroid backup followed by "adb pull /sdcard/" on the computer.
Followed your instructions (just before the flashing section), pushed the sdcard data back and restored the backup.
chowned and chmodded the /sdcard directory:
Code:
chown media_rw:media_rw /sdcard
chmod 755 /sdcard
Resized the /system bit, rebooted and hoped it wouldn't 'bootloop'.
The process was nerve wracking, but now the handset is ready for a future stable ROM (I'm still on stock).
So, we need to do
Code:
resize2fs -f /dev/block/mmcblk0p25 2000M
every time we flash a new ROM?
alexeius said:
So, we need to do
Code:
resize2fs -f /dev/block/mmcblk0p25 2000M
every time we flash a new ROM?
Click to expand...
Click to collapse
surfrock66 said:
All in all, this technique can likely be adapted to other android phones. The key is making sure you resize system by the amount you take from data, and making sure you offset all partitions in between linearly by the correct amount. I'm not sure how updates will work...anything that basically lays down a partition is gonna cause issues since it'll try to resize to the default partition size. Anything just laying down new files should be fine.
Happy hacking!
Click to expand...
Click to collapse
Depends on the ROM you're installing.​
Everyone must pay attention that this guide is for 32gb model........for 16gb commands are different.......pay attention else u brick seriously you phone.....
SoftWord said:
Everyone must pay attention that this guide is for 32gb model........for 16gb commands are different.......pay attention else u brick seriously you phone.....
Click to expand...
Click to collapse
Yes, this...my numbers show the methodology, but for the 16GB nexus 5 (or any other phone) you need to start by looking at the starting state of the partition table, then do the math from start to finish. I hope I've provided enough methodology and warnings that someone will either abort or do it right.
poioq said:
I was looking for such an option as I wanted to install a bigger gapps package then just pico. But shrinking my userdata partition is not was i had in mind. I also really do not want to loose all my data, as i am leazy
so i was thinking about just resizing /cache to a bare minimum of lets say 128mb or even less. Because as i understand /cache is just used for OTA updates - if i am mistaken here, feel free to update my knowledge.
Has anybody done this? On the Galaxy Nexus this is the way to go afaik and one would not loose things in /data.
Click to expand...
Click to collapse
In general I would say that's a very bad idea...however, if you're very careful and are willing to incur some risk, it could possibly work...on the N5, since the cache partition sits between system and userdata (and more importantly doesn't touch recovery) you could theoretically try it, and if it doesn't work, undo it, all while leaving your userdata partition untouched. If preserving your data is your goal...it's probably a bad idea, but that doesn't mean it isn't possible.
How about taking space from cache to userdata? 1-1,5GB'll be unused anyway and on 16gb variant it'll be nice to have some more memory to have
TL;DR
Success: Repartition of a Nexus 5 16GB
Success: Flash cm-14.1-20161028-UNOFFICIAL-hammerhead.zip
Success: Flash open_gapps-arm-7.1-stock-20161217.zip
FAIL: Getting through the Google/CM set up process (Google Play services crashes)
Success: Flash Aroma Gapps
Gapps selections:
Code:
AndroidPay=0
Books=0
CalculatorGoogle=1
CalendarGoogle=1
CalSync=0
CameraGoogle=1
Chrome=1
ClockGoogle=1
CloudPrint=0
ContactsGoogle=1
DialerFramework=1
DialerGoogle=1
DMAgent=0
Docs=0
Drive=0
Earth=0
ExchangeGoogle=0
FaceDetect=0
FaceUnlock=1
Fitness=1
GCS=1
Gmail=0
GoogleNow=0
GooglePlus=0
GoogleTTS=0
Hangouts=0
Hotword=0
Indic=0
Japanese=0
Keep=1
KeyboardGoogle=1
Korean=0
Maps=1
Messenger=0
Movies=0
Music=1
NewsStand=0
NewsWidget=0
PackageInstallerGoogle=0
Pinyin=0
PixelIcons=1
PixelLauncher=1
Photos=1
PlayGames=0
PrintServiceGoogle=0
ProjectFi=0
Sheets=0
Slides=0
Search=1
Speech=0
StorageManagerGoogle=0
Street=0
TagGoogle=0
Talkback=0
Translate=1
VRService=0
Wallpapers=1
WebViewGoogle=1
YouTube=1
Zhuyin=0
inclorexcl=1
Aim
To convert my Nexus 5 16GB into a Pixel using CM14.1 and Stock Open Gapps (I didn't want to keep flashing random pixel-experience.zip files)
Issue (strikethrough issues are with Stock Gapps)
When using Aroma Gapps:
1. Launcher3 crashes everytime the G search bar is clicked on
2. Google Now is not on the left pane despite my chosen packages
1. I couldn't Sign into my WiFi because no soft keyboard would appear (workaround: I created a password-less Hotspot on another phone)
2. I wasn't able to get past through the Google setup process; Google Play Services would crash every time I attempted to skip Tap & Go taking me back to a SIM card missing screen. On skipping this, I get taken to Tap & Go... and repeat
I've wiped all the caches (of course). If anyone has any ideas, it would be great.
Question to @surfrock66
You have a parted command that says:
Code:
~ # ./parted /dev/block/mmcblk0 mkpart primary 3056MB 30.8GB
Should this not be:
Code:
~ # ./parted /dev/block/mmcblk0 mkpart primary 3056MB 31.3GB
I may not have understood this fully
Thanks surfrock66 for the original method; my method varies slightly and is as follows:
Code:
Download and unpack parted.rar via the
# With phone in TWRP Recovery
$ sudo adb push parted /
$ sudo adb shell
~ # chmod +x parted
~ # ./parted /dev/block/mmcblk0 p
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 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.7MB 1049kB sbl1
3 68.7MB 69.2MB 524kB rpm
4 69.2MB 69.7MB 524kB tz
5 69.7MB 70.3MB 524kB sdi
6 70.3MB 70.8MB 524kB aboot
7 70.8MB 72.9MB 2097kB pad
8 72.9MB 73.9MB 1049kB sbl1b
9 73.9MB 74.4MB 524kB tzb
10 74.4MB 75.0MB 524kB rpmb
11 75.0MB 75.5MB 524kB abootb
12 75.5MB 78.6MB 3146kB modemst1
13 78.6MB 81.8MB 3146kB modemst2
14 81.8MB 82.3MB 524kB metadata
15 82.3MB 99.1MB 16.8MB misc
16 99.1MB 116MB 16.8MB ext4 persist
17 116MB 119MB 3146kB imgdata
18 119MB 142MB 23.1MB laf
19 142MB 165MB 23.1MB boot
20 165MB 188MB 23.1MB recovery
21 188MB 191MB 3146kB fsg
22 191MB 192MB 524kB fsc
23 192MB 192MB 524kB ssd
24 192MB 193MB 524kB DDR
25 193MB 1267MB 1074MB ext4 system
26 1267MB 1298MB 31.5MB crypto
27 1298MB 2032MB 734MB ext4 cache
28 2032MB 15.8GB 13.7GB ext4 userdata
29 15.8GB 15.8GB 5632B grow
~ # umount /data
~ # umount /sdcard
~ # umount /cache
~ # ./parted /dev/block/mmcblk0 rm 25
~ # ./parted /dev/block/mmcblk0 rm 26
~ # ./parted /dev/block/mmcblk0 rm 27
~ # ./parted /dev/block/mmcblk0 rm 28
~ # ./parted /dev/block/mmcblk0 mkpart primary 193MB 2291MB
~ # ./parted /dev/block/mmcblk0 mkpart extended 2291MB 2322MB
~ # ./parted /dev/block/mmcblk0 mkpart primary 2322MB 3056MB
~ # ./parted /dev/block/mmcblk0 mkpart primary 3056MB 15.8GB
~ # ./parted /dev/block/mmcblk0 p
~ # ./parted /dev/block/mmcblk0 name 25 system
~ # ./parted /dev/block/mmcblk0 name 26 crypto
~ # ./parted /dev/block/mmcblk0 name 27 cache
~ # ./parted /dev/block/mmcblk0 name 28 userdata
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p25
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p27
~ # mke2fs -b 4096 -T ext4 /dev/block/mmcblk0p28
~ # ./parted /dev/block/mmcblk0 p
~ # mount -a
~ # exit
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 524kB 67.6MB 67.1MB fat16 modem
2 67.6MB 68.7MB 1049kB sbl1
3 68.7MB 69.2MB 524kB rpm
4 69.2MB 69.7MB 524kB tz
5 69.7MB 70.3MB 524kB sdi
6 70.3MB 70.8MB 524kB aboot
7 70.8MB 72.9MB 2097kB pad
8 72.9MB 73.9MB 1049kB sbl1b
9 73.9MB 74.4MB 524kB tzb
10 74.4MB 75.0MB 524kB rpmb
11 75.0MB 75.5MB 524kB abootb
12 75.5MB 78.6MB 3146kB modemst1
13 78.6MB 81.8MB 3146kB modemst2
14 81.8MB 82.3MB 524kB metadata
15 82.3MB 99.1MB 16.8MB misc
16 99.1MB 116MB 16.8MB ext4 persist
17 116MB 119MB 3146kB imgdata
18 119MB 142MB 23.1MB laf
19 142MB 165MB 23.1MB boot
20 165MB 188MB 23.1MB recovery
21 188MB 191MB 3146kB fsg
22 191MB 192MB 524kB fsc
23 192MB 192MB 524kB ssd
24 192MB 193MB 524kB DDR
25 193MB 2291MB 2098MB ext4 system
26 2291MB 2322MB 31.0MB crypto
27 2322MB 3056MB 734MB ext4 cache
28 3056MB 15.8GB 12.7GB ext4 userdata
29 15.8GB 15.8GB 5632B grow
# This didn't work for me
$ sudo adb push cm-14.1-20161028-UNOFFICIAL-hammerhead.zip /
$ sudo adb push open_gapps-arm-7.1-stock-20161217.zip /
$ sudo adb reboot recovery
# So I copied over the files once I reboot into recovery
# I had to reboot into recovery again to see my CM14.1 and Gapps files
# Flashed them using TWRP
$ sudo adb shell
~ # unmount /system/
/sbin/sh: unmount: not found
# I have no idea why this happened
~ # resize2fs -f /dev/block/mmcblk0p25 2000M
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/block/mmcblk0p25 to 512000 (4k) blocks.
The filesystem on /dev/block/mmcblk0p25 is now 512000 blocks long.
~ # mount -a
mount: mounting /dev/block/mmcblk0p1 on /firmware failed: Invalid argument
mount: mounting /usb-otg on vfat failed: No such file or directory
# I have no idea why this happened either
~ # exit
@surfrock66 Hi, is the same way for n7 (2013) 32gb?
Thanks
Sent from my Nexus 7 using XDA-Developers mobile app
jordirpz said:
@surfrock66 Hi, is the same way for n7 (2013) 32gb?
Thanks
Click to expand...
Click to collapse
No, this is not necessarily true. You will need to use Parted to analyse the partitions and then make the relevant modifications. Again, do not try this unless you are willing to potentially brick your device.
@surfrock66
Faied copy parted to //parted : read-only file system
Whats hapend?
Sent from my Nexus 7 using XDA-Developers mobile app
jordirpz said:
@surfrock66
Faied copy parted to //parted : read-only file system
Whats hapend?
Sent from my Nexus 7 using XDA-Developers mobile app
Click to expand...
Click to collapse
In TWRP, you have to choose to mount your system as read/write, for me with TWRP 3.x it's an option right when TWRP starts. If you don't do that, you can't write to / and thus can't copy the file over.
surfrock66 said:
In TWRP, you have to choose to mount your system as read/write, for me with TWRP 3.x it's an option right when TWRP starts. If you don't do that, you can't write to / and thus can't copy the file over.
Click to expand...
Click to collapse
Ok thank you.
Other question please. Adb Shell steps, works in trwp or i need mount system and reboot system for make it? Thank you
Sent from my Nexus 7 using XDA-Developers mobile app
jordirpz said:
Ok thank you.
Other question please. Adb Shell steps, works in trwp or i need mount system and reboot system for make it? Thank you
Sent from my Nexus 7 using XDA-Developers mobile app
Click to expand...
Click to collapse
All done while in twrp.
surfrock66 said:
All done while in twrp.
Click to expand...
Click to collapse
Ok, thanks for you awesome guide.
For me works, now i have 2gb in system?
Sorry for ETA: can you in near future make a reparted file and guide for N7 2013 wifi please?
Sent from my Nexus 7 using XDA-Developers mobile app
jordirpz said:
Ok, thanks for you awesome guide.
For me works, now i have 2gb in system?
Sorry for ETA: can you in near future make a reparted file and guide for N7 2013 wifi please?
Sent from my Nexus 7 using XDA-Developers mobile app
Click to expand...
Click to collapse
I don't have that device, but the original post here should have everything you need to re-create the process for another device. You'll have to re-calculate the offsets based on what you find when you run the original partition query.
souheil said:
Depends on the ROM you're installing.​
Click to expand...
Click to collapse
Just to double check.
Any ideas of what ROMs would need this?
I'm interested of the cyanogenmod in my particular case.
ricardo.adao said:
Just to double check.
Any ideas of what ROMs would need this?
I'm interested of the cyanogenmod in my particular case.
Click to expand...
Click to collapse
CM14.1 fits on the Nexus 5 /system partition WITHOUT repartitioning.
I wanted to try this because I want to flash Stock Gapps (as opposed to Nano), hoping to get a Pixel-like experience as described in my previous post (http://forum.xda-developers.com/showpost.php?p=70145560&postcount=10). However, I had lots of crashes with Stock Gapps.
Instead, I now use CM14.1 with Nano Gapps.
If you want a more Pixel-like experience, that side-loading doesn't provide (no Google Now on the left side of the Homescreen, no Pixel-like animations on clicking the G Search Bar), I have resorted to installing the Pixel Launcher and Wallpaper APKs into /system.
Instructions found: http://android.stackexchange.com/questions/76976/how-to-install-app-as-system-app
Re-flashing a ROM will require you to re-do these steps.

NOOK HD+ (Ovation) repit alternative - manually enlarge system partition

I didn't want to tax myself learning how repit works, so I used techniques that I've used for a long time on kindles.
will update if mistakes or improvements are needed. necessary binaries are in the attached zip.
THIS WILL WIPE YOUR SYSTEM PARTITION AND YOU NEED TO KNOW HOW TO GET TO RECOVERY IN SOME STEPS
THIS REMOVES THE FACTORY PARTITON , IF YOU EVER THINK YOU WILL GO BACK TO STOCK/STOCK RECOVERY BACK IT UP
remove factory partition and enlarge system
(I haven't tried this yet, but you could also remove
/system and /cache, leaving /factory alone and making a smaller /cache partition. Steps would be similar, but not exactly as below. /cache on Oreo is barely used, I think 100mb would suffice, giving 350mb additional for /system)
(these assume you have a folder called sdparted with the binaries in your current folder, otherwise just use the correct path))
adb push ./sdparted/parted /tmp
adb push ./sdparted/e2fsck /tmp
adb push ./sdparted/tune2fs /tmp
adb shell
chmod 755 parted
chmod 755 e2fsck
chmod 755 tune2fs
umount /cache
================= remove factory and system
parted /dev/block/mmcblk0
typing "p will show you partition layout
Before
Number Start End Size File system Name Flags
1 131kB 262kB 131kB xloader
2 262kB 524kB 262kB bootloader
3 524kB 16.3MB 15.7MB recovery
4 16.8MB 33.6MB 16.8MB boot
5 33.6MB 83.9MB 50.3MB fat32 rom
6 83.9MB 134MB 50.3MB fat32 bootdata
7 134MB 604MB 470MB ext4 factory
8 604MB 1309MB 705MB ext2 system
9 1309MB 1795MB 487MB ext4 cache
10 1795MB 31.3GB 29.5GB ext4 userdata msftres
====== remove factory and system partitions ========
rm 7
rm 8
====== make system partition ========
mkpartfs primary ext2
Start? 134
134
End? 1309
name 7 system
quit parted
still in adb shell
tune2fs -j /dev/block/mmcblk0p7
e2fsck -fDp /dev/block/mmcblk0p7
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p7
Number Start End Size File system Name Flags
1 131kB 262kB 131kB xloader
2 262kB 524kB 262kB bootloader
3 524kB 16.3MB 15.7MB recovery
4 16.8MB 33.6MB 16.8MB boot
5 33.6MB 83.9MB 50.3MB fat32 rom
6 83.9MB 134MB 50.3MB fat32 bootdata
7 134MB 1309MB 1174MB ext4 system
9 1309MB 1795MB 487MB ext4 cache
10 1795MB 15.6GB 13.8GB userdata
reboot to recovery
install rom and gapps, I use the patched magisk V2 for root
after rom install, before gapps, repair and resize system partition in recovery (I think it needs two tries)

[DEV][ Expand System Partition To 5GB - MediaPad M3 ]

Hello !
Here you will find the information needed to change the system partition from 2GB to 5GB - this operation is somewhat useful for installing any version of GApps on your device : Huawei MediaPad M3 8.4 Kirin version ( BTV-DL09; BTV-L0J; BTV-W09 )
Thanks to @accerian for his help, and you can also check out this tutorial for more information !
Download mkfs.ext4 and parted from here : https://forum.xda-developers.com/attachments/parted_gdisk_fdisk_mkfs-ext4-arm-zip.4494671/
Warning : the entire data partition will be deleted following this procedure, make sure you have backed up and saved it to a microsd card
Step I : extended system partition from about 2GB to 5GB ( example for a 32GB device, for 64GB devices the procedure is 99% similar, only one operation differs which will be specified at the appropriate time ) - also this example is for BTV-DL09 which is with LTE capabilities.
- extract "mkfs.ext4" and "parted" from previously download archive and put them into a new created tmp directory
- connect the device to the computer via the USB cable and bring the device into TWRP revovery with this command :
> adb reboot recovery
- copy the two executable files from the computer to the device :
> adb push tmp data/local
> adb shell
# cp -r data/local/tmp/mkfs.ext4 sbin/mkfs.ext4
# chmod 0777 sbin/mkfs.ext4
# cp -r data/local/tmp/parted sbin/parted
# chmod 0777 sbin/parted
- launch the "parted" function as follows :
# parted /dev/block/mmcblk0
- display all properties of all partitions : (I wrote what needs to be displayed as a command before pressing enter, so you just have to type "print" and press enter because (parted) is already displayed as promter ... be careful not to type (parted) twice in the following commands)
(parted) print
- go to line 43, which should be the same for all devices :
43 1174MB 3255MB 2080MB ext2 system msftdata
44 3255MB 3456MB 201MB ext4 cust msftdata
45 3456MB 3490MB 33.6MB ext4 version msftdata
46 3490MB 4127MB 638MB ext2 vendor msftdata
47 4127MB 4329MB 201MB ext4 product msftdata
48 4329MB 4333MB 4194kB hisitest2 msftdata
49 4333MB 31.3GB 26.9GB userdata msftdata
Click to expand...
Click to collapse
- if line 43 is not identical to this one here, please stop the process by writing quit and enter, I'm waiting for a private message with what is written on line 43 in the case of your device so that I can guide you correctly .
- assuming that all devices have the same system partition ( the same 43 line ) - approximately 2GB, we go to the next steps:
- access the Mount menu in TWRP and uncheck Data, and follow the steps below step by step :
(parted) rm 49
(parted) rm 48
(parted) rm 47
(parted) rm 46
(parted) rm 45
(parted) rm 44
(parted) rm 43
(parted) mkpart system ext2 1174 6501
(parted) name 43 system
(parted) set 43 msftdata on
(parted) mkpart cust ext4 6501 6702
(parted) name 44 cust
(parted) set 44 msftdata on
(parted) mkpart version ext4 6702 6736
(parted) name 45 version
(parted) set 45 msftdata on
(parted) mkpart vendor ext2 6736 7374
(parted) name 46 vendor
(parted) set 46 msftdata on
(parted) mkpart product ext4 7374 7575
(parted) name 47 product
(parted) set 47 msftdata on
(parted) mkpart hisitest 7575 7579
(parted) name 48 hisitest2
(parted) set 48 msftdata on
- for devices with 32GB :
(parted) mkpart userdata 7579 31.3GB
- for devices with 64GB :
(parted) mkpart userdata 7579 62.5GB
(parted) name 49 userdata
(parted) set 49 msftdata on
(parted) quit
Step II : activating partitions for reuse :
# mkfs.ext4 /dev/block/mmcblk0p43
# mkfs.ext4 /dev/block/mmcblk0p44
# mkfs.ext4 /dev/block/mmcblk0p45
# mkfs.ext4 /dev/block/mmcblk0p46
# mkfs.ext4 /dev/block/mmcblk0p47
# mkfs.ext4 /dev/block/mmcblk0p49
- go to TWRP -> Wipe -> Advanced Wipe -> select System -> Repair or Change File System -> Change File System -> EXT4 -> Swipe to Change
- go to TWRP -> Wipe -> Advanced Wipe -> select Vendor -> Repair or Change File System -> Change File System -> EXT4 -> Swipe to Change
- go to TWRP -> Wipe -> Format Data -> yes
- reboot device from TWRP to TWRP in order to use data again after formated !
- go to TWRP -> Wipe -> Advanced Wipe -> select Dalvik/ART Cache, Cache, Data, Internal Storage, System, Vendor -> Swipe to wipe
- copy the new updated of LOS 17.1 with system partition of 5GB into your device
- copy any GApps arm64 Android 10 to your device
- Install them like always, enjoy !
Mention :
- if your device is WiFi only, you may have fewer partitions .... the above instructions can be easily adapted from case to case !
The main idea is that we must first find out what position the system partition is in, in this case it was at position 43 which corresponds to /dev/block/mmcblk0p43 - then we need to delete all partitions from userdata to system, and recreate them in the same order !
To calculate the start and end position, it is again very easy : for example the system partition starts from the initial position 1174, which is the same as the end position of the previous partition 42 (42 1160MB 1174MB 14.7MB reserved3 msftdata), and the end position was incremented by 5327 in this case (almost 5GB), resulting in 6501. .. the next partition 44 (cust) will have the starting position 6501, and the end position will be incremented by 201 (i.e. 201MB) as shown on line 44 (44 3255MB 3456MB 201MB ext4 cust msftdata)
If really needed, a concrete example will be added here for WiFi only devices !
Thanks for this guide.
Thank you surdu_petru.
The internal storage size of BTV-L0J is 16GB, is the above procedure effective?
Is it possible to restore a partition size back to its original size? I sometimes use a dd command as a way to restore from LineageOS to stock ROM. So I need to restore it to its original size before using a dd command.
According to z3DD3r, who created a tool to resize the Nexus 5 system partition, it is recommended that after changing the partition size, TWRP should also be changed.
z3DD3r said:
Because TWRP includes size of system partition. This size should match the size of system partition on device. Otherwise bad things can happen...
Click to expand...
Click to collapse
Is there any problem without changing TWRP?
I am sorry for asking so many questions. I am cautious about changing the partition size because it is perilous.
Me said:
Thank you surdu_petru.
The internal storage size of BTV-L0J is 16GB, is the above procedure effective?
Is it possible to restore a partition size back to its original size? I sometimes use a dd command as a way to restore from LineageOS to stock ROM. So I need to restore it to its original size before using a dd command.
According to z3DD3r, who created a tool to resize the Nexus 5 system partition, it is recommended that after changing the partition size, TWRP should also be changed.
Is there any problem without changing TWRP?
I am sorry for asking so many questions. I am cautious about changing the partition size because it is perilous.
Click to expand...
Click to collapse
If you still have 49 partitions, and partition 43 (system) shows that in the above tutorial then the procedure is identical, you just have to put a lower value of the user data partition in the last corresponding line of 16GB!
- for devices with 16GB:
(parted) mkpart userdata 7579 ?? GB
Click to expand...
Click to collapse
There is no need to change anything, neither TWRP nor the partition to the initial value ... the most important thing is to pay attention to the Start and End position of system partition to make the calculations as accurate as possible !
I can help you if you can send me a screenshot of what the command below displays on your device (from the system down to the last partition):
> adb shell
# parted /dev/block/mmcblk0 print
surdu_petru said:
If you still have 49 partitions, and partition 43 (system) shows that in the above tutorial then the procedure is identical, you just have to put a lower value of the user data partition in the last corresponding line of 16GB!
There is no need to change anything, neither TWRP nor the partition to the initial value ... the most important thing is to pay attention to the Start and End position of system partition to make the calculations as accurate as possible !
I can help you if you can send me a screenshot of what the command below displays on your device (from the system down to the last partition):
> adb shell
# parted /dev/block/mmcblk0 print
Click to expand...
Click to collapse
Thank you for your reply.
It is good news that if each partition has the same number it is effective.
I am currently not having trouble with the size of system partitions, so I will give it some more thought.
@surdu_petru - many thanks for this guide, I found it very clear and straightforward. I wasn't sure if you were wanting confirmation that these instructions work with other models of the tablet - if so, I can confirm it works perfectly with my (wifi only, 32GB) BTV-W09.
Herby007 said:
@surdu_petru - many thanks for this guide, I found it very clear and straightforward. I wasn't sure if you were wanting confirmation that these instructions work with other models of the tablet - if so, I can confirm it works perfectly with my (wifi only, 32GB) BTV-W09.
Click to expand...
Click to collapse
Thanks for confirmation. I'm not waiting especially confirmation, but it's always better if you can confirm. I'm here to help in case that something goes wrong.
I'm going for the 3rd time as the first I messed up. Second I did it right but I think I have to switch it up a little as I have the WIFI, and I can't do mkfs.ext4 after doing the parted commands. But I'll keep on it to see if all the partitions are exactly correct. I know 43 is the same as the directions said to make sure. 3rd times the charm. Good luck out there
Hey man, things are kinda messed up for me at the moment.
I've followed your steps however my cmd crashed for some reason during the process. Now I can't mount data to start the process again. Using the genuine EMUI Recovery offerd at startup doesn't work because the partitions are messed up and my own recovery points are inaccessible probably due to a currupted ext sd card (you can't make this up )
Do you have any tips on how to regain control? Or are all hopes lost?
I've tried using pro-team multi tool, however their database/website seems to be unavailable at the moment...
Edit: I have it fixed now, using a sd-card I did a force update to stock firmware, that fixed the storage. Had to restart the entire process starting with TWRP installation, device was still unlocked though. Don't be stupid like me and always check your recovery data before and not after you already messed things up
hey guys,
I somehow messed it up and I'm getting this error message
/data is not present!
Failed to mount '/data'
Partitions are formatted:
43 1174MB 6501MB 5327MB ext4 system msftdata
44 6501MB 6702MB 201MB ext4 cust msftdata
45 6702MB 6736MB 33.6MB ext4 version msftdata
46 6736MB 7374MB 638MB ext4 vendor msftdata
47 7374MB 7575MB 201MB ext4 product msftdata
48 7575MB 7579MB 4194kB hisitest2 msftdata
49 7579MB 31.3GB 23.7GB userdata msftdata
Here is an output of "df" command:
~ # df -h
Filesystem Size Used Available Use% Mounted on
tmpfs 1.8G 184.0K 1.8G 0% /dev
tmpfs 1.8G 2.0M 1.8G 0% /tmp
/dev/block/mmcblk0p36 232.0M 756.0K 223.6M 0% /cache
/dev/block/mmcblk0p46 582.4M 468.0K 563.7M 0% /vendor
/dev/block/mmcblk1p1 59.5G 5.0G 54.5G 8% /external_sd
I can't continue with "TWRP -> Wipe"
Any ideas what went wrong?
BlueLife98 said:
Hey man, things are kinda messed up for me at the moment.
I've followed your steps however my cmd crashed for some reason during the process. Now I can't mount data to start the process again. Using the genuine EMUI Recovery offerd at startup doesn't work because the partitions are messed up and my own recovery points are inaccessible probably due to a currupted ext sd card (you can't make this up )
Do you have any tips on how to regain control? Or are all hopes lost?
I've tried using pro-team multi tool, however their database/website seems to be unavailable at the moment...
Edit: I have it fixed now, using a sd-card I did a force update to stock firmware, that fixed the storage. Had to restart the entire process starting with TWRP installation, device was still unlocked though. Don't be stupid like me and always check your recovery data before and not after you already messed things up
Click to expand...
Click to collapse
hey man, how did you install the stock firmware? tried to install these firmware's but didn't work at all https://firmwarefile.com/huawei-mediapad-m3-btv-dl09

[Guide] [Parted] [Noob-Friendly] Decrease /system Partition to Expand /data Partition [Z00L]

Basic Ideas—QnA​Q: Why would You want to extend Your /data (userdata) partition (Internal Memory Storage)
A: Of course to gives You a lot more space for Files, & Apps to be installed.
Q: What's things You will need to do this?
A: Parted, & mkfs.ext4. Parted to edit Your partition, & mkfs.ext4 to formats a partition to EXT4 file system.
Q: Will it works on my Zenfone 2 Laser?
A: Most likely, Yes. But I'm partitioning on Z00L model, maybe there's some adjustment to be made to work on for Your phone model if different.
Before proceeding any further You may want:​a. Do a full backup of Your phone to the data of Your phone including your personal data, & files!
b. Prepare a computer or such
c. Having a good USB Micro-B cable. If Your don't have any or broken, You can use USB Type C cable, & USB OTG Micro-B
d. Be patient, brave, & good luck!
If You so choose to proceed, remember:​
/*
* Your warranty is now void.
*
* I'm not responsible for bricked devices, dead SD cards,
* thermonuclear war, or You getting fired because the alarm app failed. Please
* do some research if You have any concerns about features included in this tools
* before doing it! YOU are choosing to make these modifications, and if
* You point the finger at us for messing up Your device, we will laugh at You.
*
*/
Click to expand...
Click to collapse
Now Let's Get Started​
Spoiler: Good Luck!
I. Download:​- Android SDK Platform Tools HERE Extract it (e.g. C:\adb)
- Parted, & mkfs.ext4 HERE Extract it somewhere, & copy the folder location, we will get back to this later!
- A TWRP backup of 'LineageOS [17.1] [18.1] [Fork]' Z00L compiled by @markkiths with NikGApps Core HERE Extract it somewhere, & copy the TWRP folder location, we will get back to this later! (Note: AOSP Keyboard, WebView. & all Forks Apps is removed. You may want to use adb install command or download the apk to the MicroSD to install Gboard, & WebView to get the virtual keyboard working, & able to login to Your Google account
- Android 6 Marshmallow Fastboot stock ROM in case You Hard Brick Your phone HERE See step III if You encountered this problem
- Latest TWRP Z00L Z00T
II. Things to do, & Commands:​a. Plug Your phone to computer while in TWRP, & MTP Enabled (Mount > Enable MTP). Then open Terminal on a folder that contains the Android SDK Platform Tools:
→ Windows: Command Prompt or Terminal
→ Linux distros: Terminal
→ macOS: Terminal
Click to expand...
Click to collapse
b. Push (Copy) Parted, & mkfs.ext4 to /sbin:
> adb devices
> adb push parted /sbin
> adb push mkfs.ext4 /sbin
c. Now You shell into it, & set 777 permission to get the files working:
> adb shell
~ # chmod 777 /sbin/parted
~ # chmod 777 /sbin/mkfs.ext4
Now Disable MTP & untick all partitions in Mount menu. You may want to adb shell again
d. Parted into partition of the phone's MMC:
~ # parted /dev/block/mmcblk0
e. List current unmodified partitions:
(parted) print
The output would looks like:
Model: MMC R1J96N (sd/mmc)
Disk /dev/block/mmcblk0: 15.8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 1328kB 1311kB sbl1
2 1328kB 2639kB 1311kB sbl1bak msftdata
3 2639kB 3163kB 524kB rpm
4 3163kB 3687kB 524kB rpmbak msftdata
5 3687kB 4212kB 524kB tz
6 4212kB 4736kB 524kB tzbak msftdata
7 4736kB 5260kB 524kB hyp
8 5260kB 5785kB 524kB hypbak msftdata
9 5785kB 5817kB 32.8kB DDR
10 5817kB 5826kB 8192B ssd
11 5826kB 5842kB 16.4kB sec
12 5842kB 11.1MB 5243kB aboot
13 16.8MB 22.0MB 5243kB abootbak msftdata
14 22.0MB 27.3MB 5243kB splash
15 27.3MB 28.3MB 1049kB devinfo
16 33.6MB 35.1MB 1573kB fsg
17 35.1MB 35.1MB 1024B fsc
18 35.1MB 36.7MB 1573kB modemst1
19 36.7MB 38.3MB 1573kB modemst2
20 38.3MB 48.8MB 10.5MB ext4 factory
21 48.8MB 59.2MB 10.5MB factorybak
22 59.2MB 60.3MB 1049kB asuskey
23 60.3MB 61.3MB 1049kB asuskey2
24 61.3MB 62.4MB 1049kB asuskey3
25 62.4MB 63.4MB 1049kB asuskey4
26 63.4MB 64.5MB 1049kB asuskey5
27 64.5MB 65.5MB 1049kB asusgpt
28 65.5MB 66.6MB 1049kB asusgpt1
29 66.6MB 67.6MB 1049kB asusgpt2
30 67.6MB 68.7MB 1049kB misc
31 68.7MB 69.2MB 524kB keystore
32 69.2MB 69.2MB 32.8kB config
33 69.2MB 103MB 33.6MB ext4 asdf
34 103MB 105MB 2097kB abootdebug
35 105MB 106MB 1049kB persistent
36 117MB 151MB 33.6MB oem
37 151MB 185MB 33.6MB boot
38 185MB 218MB 33.6MB recovery
39 218MB 252MB 33.6MB ext4 persist
40 252MB 268MB 16.8MB asusfw
41 268MB 336MB 67.1MB fat16 modem msftdata
42 336MB 369MB 33.6MB ext4 ADF msftdata
43 369MB 587MB 218MB ext4 APD msftdata
44 587MB 621MB 33.6MB ext4 cache
45 621MB 3842MB 3221MB ext4 system
46 3842MB 15.8GB 11.9GB ext4 userdata
Click to expand...
Click to collapse
f. Change the unit to byte:
(parted) unit b
You could list the partitions again by typing print to see in bytes
Model: MMC R1J96N (sd/mmc)
Disk /dev/block/mmcblk0: 15758000128B
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17408B 1328127B 1310720B sbl1
2 1328128B 2638847B 1310720B sbl1bak msftdata
3 2638848B 3163135B 524288B rpm
4 3163136B 3687423B 524288B rpmbak msftdata
5 3687424B 4211711B 524288B tz
6 4211712B 4735999B 524288B tzbak msftdata
7 4736000B 5260287B 524288B hyp
8 5260288B 5784575B 524288B hypbak msftdata
9 5784576B 5817343B 32768B DDR
10 5817344B 5825535B 8192B ssd
11 5825536B 5841919B 16384B sec
12 5841920B 11084799B 5242880B aboot
13 16777216B 22020095B 5242880B abootbak msftdata
14 22020096B 27262975B 5242880B splash
15 27262976B 28311551B 1048576B devinfo
16 33554432B 35127295B 1572864B fsg
17 35127296B 35128319B 1024B fsc
18 35128320B 36701183B 1572864B modemst1
19 36701184B 38274047B 1572864B modemst2
20 38274048B 48759807B 10485760B ext4 factory
21 48759808B 59245567B 10485760B factorybak
22 59245568B 60294143B 1048576B asuskey
23 60294144B 61342719B 1048576B asuskey2
24 61342720B 62391295B 1048576B asuskey3
25 62391296B 63439871B 1048576B asuskey4
26 63439872B 64488447B 1048576B asuskey5
27 64488448B 65537023B 1048576B asusgpt
28 65537024B 66585599B 1048576B asusgpt1
29 66585600B 67634175B 1048576B asusgpt2
30 67634176B 68682751B 1048576B misc
31 68682752B 69207039B 524288B keystore
32 69207040B 69239807B 32768B config
33 69239808B 102794239B 33554432B ext4 asdf
34 102794240B 104891391B 2097152B abootdebug
35 104891392B 105939967B 1048576B persistent
36 117440512B 150994943B 33554432B oem
37 150994944B 184549375B 33554432B boot
38 184549376B 218103807B 33554432B recovery
39 218103808B 251658239B 33554432B ext4 persist
40 251658240B 268435455B 16777216B asusfw
41 268435456B 335544319B 67108864B fat16 modem msftdata
42 335544320B 369098751B 33554432B ext4 ADF msftdata
43 369098752B 587202559B 218103808B ext4 APD msftdata
44 587202560B 620756991B 33554432B ext4 cache
45 620756992B 3841982463B 3221225472B ext2 system
46 3841982464B 15757983231B 11916000768B ext4 userdata
Click to expand...
Click to collapse
From this point onward DO NOT do stupid stuffs, like delete unmentioned partitions! You have been warned!
g. Remove partition of userdata, & system:
(parted) rm 46
(parted) rm 45
h. Create, name, & set flag for the new system partition: You could use this tool to convert from Gigabytes to Bytes for more precise result
(parted) mkpart system ext4 620756992 2365985773 Remember: It now only have 2 MB left on Your /system partition. You may either can't really tinker much with the bootanimation.zip nor the Media sounds on /system/product/media to Your liking
Here's You realized there are 2 values. The 620756992 as Start Address, & 2365985773 as End Address. Here's some explanation to specify each address:
→ By adding 1 byte from previous partition: 620756991+1=620756992 ← You got Your Start Address for system partition!
→ By adding Start Address + Your decided value (In my case I just want 1.69 GB or 1,745,228,781 Bytes): 620756992+1745228781=2365985773 ← You got Your End Address for system partition!
Click to expand...
Click to collapse
(parted) name 45 system
(parted) set 45 msftdata on
i. List the Free Space:
(parted) p free
The output would looks like:
Model: MMC R1J96N (sd/mmc)
Disk /dev/block/mmcblk0: 15758000128B
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
7168B 17407B 10240B Free Space
1 17408B 1328127B 1310720B sbl1
2 1328128B 2638847B 1310720B sbl1bak msftdata
3 2638848B 3163135B 524288B rpm
4 3163136B 3687423B 524288B rpmbak msftdata
5 3687424B 4211711B 524288B tz
6 4211712B 4735999B 524288B tzbak msftdata
7 4736000B 5260287B 524288B hyp
8 5260288B 5784575B 524288B hypbak msftdata
9 5784576B 5817343B 32768B DDR
10 5817344B 5825535B 8192B ssd
11 5825536B 5841919B 16384B sec
12 5841920B 11084799B 5242880B aboot
11084800B 16777215B 5692416B Free Space
13 16777216B 22020095B 5242880B abootbak msftdata
14 22020096B 27262975B 5242880B splash
15 27262976B 28311551B 1048576B devinfo
28311552B 33554431B 5242880B Free Space
16 33554432B 35127295B 1572864B fsg
17 35127296B 35128319B 1024B fsc
18 35128320B 36701183B 1572864B modemst1
19 36701184B 38274047B 1572864B modemst2
20 38274048B 48759807B 10485760B ext4 factory
21 48759808B 59245567B 10485760B factorybak
22 59245568B 60294143B 1048576B asuskey
23 60294144B 61342719B 1048576B asuskey2
24 61342720B 62391295B 1048576B asuskey3
25 62391296B 63439871B 1048576B asuskey4
26 63439872B 64488447B 1048576B asuskey5
27 64488448B 65537023B 1048576B asusgpt
28 65537024B 66585599B 1048576B asusgpt1
29 66585600B 67634175B 1048576B asusgpt2
30 67634176B 68682751B 1048576B misc
31 68682752B 69207039B 524288B keystore
32 69207040B 69239807B 32768B config
33 69239808B 102794239B 33554432B ext4 asdf
34 102794240B 104891391B 2097152B abootdebug
35 104891392B 105939967B 1048576B persistent
105939968B 117440511B 11500544B Free Space
36 117440512B 150994943B 33554432B oem
37 150994944B 184549375B 33554432B boot
38 184549376B 218103807B 33554432B recovery
39 218103808B 251658239B 33554432B ext4 persist
40 251658240B 268435455B 16777216B asusfw
41 268435456B 335544319B 67108864B fat16 modem msftdata
42 335544320B 369098751B 33554432B ext4 ADF msftdata
43 369098752B 587202559B 218103808B ext4 APD msftdata
44 587202560B 620756991B 33554432B ext4 cache
45 620756992B 2365985773B 1016468480B ext4 system msftdata
2365985774B 15757993471B 14120768000B Free Space
Click to expand...
Click to collapse
j. Create, name, & set flag for the new userdata partition:
(parted) mkpart userdata ext4 2365985774 15757993471
More or less to specify Start Address, & End Address for userdata partition is same as before. Here's quick sums up:
→ 2365985773 is added 1 byte to the End Address of system partition (2365985773+1)
→ 15757993471 is just the maximum MMC range
Click to expand...
Click to collapse
You may get this warning just answer it with y, & i:
Warning: You requested a partition from 2389054446B to 15757992960B (sectors
3197706..30777330).
The closest location we can manage is 2389054446B to 15757982720B (sectors
3197706..30777310).
Is this still acceptable to you?
Yes/No? y
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
Click to expand...
Click to collapse
(parted) name 46 userdata
(parted) set 46 msftdata on
k. Now quit parted, & format system partition using EXT2 file system, & userdata partition using EXT4 file system:
(parted) quit
~ # mkfs.ext2 /dev/block/mmcblk0p45
Why not format system partition with EXT4? I'm just follows phone's default file system!
~ # mkfs.ext4 /dev/block/mmcblk0p46
Now remount the partitions by typing: mount /dev/block/mmcblk0p45 /system_root, & mount /dev/block/mmcblk0p46 /data
l. Now exit out the adb shell, & push (Copy) a gigs or more file to Your Internal Memory to prevent system partition from messing up: Your phone may restart near the completion of pushing 'system.ext4.win000' file, Calm down it's normal!
~ # exit
> adb push "YourExtractionLocation\TWRP" /sdcard
m. If Your phone rebooted into Fastboot Mode by itself just pulled out the battery, & get back to TWRP by pressing Down Volume Button with Power Button (Note: If You immediately see the screen just go blank, while the phone being turned on, & when plugged into the computer there are many partitions mounted. That means You unfortunately Hard Brick Your phone. See step III below to Unbrick it), & push the TWRP folder once more: Most likely it will be copied successfully without errors!
> adb push "YourExtractionLocation\TWRP" /sdcard
Now You can re-enable MTP in TWRP > Mount, & do adb kill-server then eject Your phone from the computer
n. Now Restore in TWRP menu or flash a new ROM that You may want to modify it with Jancox Tool Unpack Repack ROMs. Done! You now can setup Your phone. To check if You actually expand Your /data partition:
TWRP or Terminal: df -h
Android: Link2SD or DiskInfo
​III. Unbrick Your Phone:​a. Boot into Fastboot Mode (Pressing Volume Up + Power Button), & plug Your phone to the computer
b. Extract the Fastboot ROM zip, & run the flashall_AFT.cmd then wait until it completes (Note: For some reason it still have Bootloader Unlocked. So no need to reunlock it!)
c. When completes, just open Terminal then type fastboot flash recovery twrp-x.x.x_x-x-Z00x.img
d. Then boot into TWRP fastboot boot recovery
e. Now you get Your TWRP back, up & running again!
​IV. Extras:​a. Want custom accent color? Use Accent Colour Creator
b. Want custom Dark Theme Color Bucket other than Pitch Black & Android 12 Dark? Use APK Editor Studio & copy the SystemDark12Overlay.apk from /system/product/overlay/SystemDark12. Edit it on APK Editor Studio then modify the colors.xml & style.xml in /res/values-night folder. Lastly change the package="com.custom.dtcb.name" in AndroidManifest.xml then Save the APK & install it on to Your phone
Spoiler: ⚠️ For Specific¹ Purpose Only
¹ Finding the exact start-end address for extreme storage saving on specific ROM. The free space that'll be available is 20.48 kB.
You may not run this multiple lines of codes without knowing their real function is. If you're running this codes, & your phone got hard bricked that's aren't my problems! That's your typos, miscopied problem!
Code:
adb push mkfs.ext4 /sbin
adb push parted /sbin
adb shell
chmod 777 /sbin/parted
chmod 777 /sbin/mkfs.ext4
parted /dev/block/mmcblk0
unit b
p free
rm 46
rm 45
mkpart system ext4 620756992 2352082431
name 45 system
set 45 msftdata on
mkpart userdata ext4 2352082432 15757983231
y
i
name 46 userdata
set 46 msftdata on
quit
mkfs.ext2 /dev/block/mmcblk0p45
mkfs.ext4 /dev/block/mmcblk0p46
mount /dev/block/mmcblk0p45 /system_root
mount /dev/block/mmcblk0p46 /data
exit
If you're facing 1 of this problem while you Restore Backup in TWRP:
extractTarFork() process ended with ERORR; 255 Then the way to fix it to extend /system by repartition your EMMC with value of the subtraction from the Progress Value that shown just right before it's outputs the error message by the Total Backup Size of /system Partition.
extractTarFork() process ended with ERORR; 9 Then you must recreate the backup. It's caused by formatting the /data partition using TWRP's built in EXT4 formatter especially after you reboot & after partitioned the EMMC, or you didn't answer the last mounted on question after the 21ˢᵗ command has been executed.
Credits:​Thanks to Hovatek for being the first to actually demonstrate it on physical device, & providing the necessary files
Thanks to @markkiths for compiles, & providing LineageOS/Fork 18.1
Thanks to NikGApps for providing GApps for Android 11
Run into problem? Write it down below! I'll try my best to help You out.​

Categories

Resources