Skip to content

Instantly share code, notes, and snippets.

@fahad15090
Forked from Systemad/modify dynamic
Created July 13, 2023 19:38
Show Gist options
  • Select an option

  • Save fahad15090/d5e81b05355f38c011e150ef68633804 to your computer and use it in GitHub Desktop.

Select an option

Save fahad15090/d5e81b05355f38c011e150ef68633804 to your computer and use it in GitHub Desktop.
Make Dynamic Partition Read/Write
NOTE: I have only tested this on my OnePlus 7T Pro running OxygenOS11 Beta (Android 11).
Be sure to know what you're doing and proceed at your own risk.
Below are two guides on how to make dynamic partition R/W, this also works for stock.
Unlike some other guides out there, this is without the need of unpacking/repacking the super partitions.
Although, the second guide does require (a properly) TWRP.
Note: If you get qualcomm crash dump complaining about dm-verity, flash magisk.
For Guide 2, you need to use a personal ***test*** TWRP build of mine. Only tested on 7T Pro running OOS11.
It should be unified with 7T but I cannot test that since I do not own that device.
https://github.com/Systemad/android_device_oneplus_hotdog/releases
-----------------------------------------------------------------------------------------------------
NOTE: Untested. But you are basically doing same thing as Guide 2, just in a different way.
### Modify manually on PC from Payload bin ###
1. Extract full UNMODIFIED IMAGE with from payload.bin with payload_dumper
2. Check the image, required before resizing
e2fsck -f <logical partition.img>
3. Resize - Recommended size, depending on the partition, is 2-3GB.
resize2fs <logical partition.img> <size> # can be define 3G for 3GB
4. Make the partition R/W by unsharing its blocks
e2fsck -E unshare_blocks <logical partition.img>
5. Mount the image to a location, default is /mnt (sudo required)
mount -t ext4 -o loop,rw <logical partition.img> <location>
6. Remove bloat or modify files (sudo required).
OPTIONAL: Since you make the image R/W you can just do it on the device later
cd <mount location>
7. When finished, unmount the image (sudo required)
umount <mount location>
8. Check the image again before resizing (required)
e2fsck -f <logical partition.img>
9. Now since the partition is bigger than its original size, you need to resize
the logical partition with fastbootd.
adb reboot fastboot # in OS
OR
fastboot reboot fastboot # in bootloader inferface
fastboot resize-logical-partition <parition_slot> $((3*1024*1024*1024)) # replace '3' with desired size
10. Flash slot partition on slot A OR B, depending on what slot you are on, and YOU NEED specify that
fastboot flash <logical partition_a OR _b> <logical partition.img>
You might see a warning regarding sparse filesystem, but you can ignore that.
------------------------------------------------------------------------------------------------------------------
Reference: https://twitter.com/phhusson/status/1260577424418488324
### Make dynamic partition R/W with fastbootd and TWRP
For some reason I have only managed to do this on Slot A.
Booot into TWRP, and execute 'adb shell'.
X = Partition. To find out what block partition is, mount it in twrp then run 'df -h'.
e2fsck -f /dev/block/dm-x
resize2fs /dev/block/dm-x 3G
e2fsck -E unshare_blocks /dev/block/dm-x
Now reboot to fastbootd and execute:
fastboot resize-logical-partition <partition_slot> $((3*1024*1024*1024))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment