[Android General] hikari_calyx:
This guide should be generic for all of Qualcomm A/B devices came with Android 9 or older out of box - in other words, devices with "super" partition are not applicable.

For some reason, if you prefer custom ROM rather than stock, or you want to get more storage space especially for 32GB or fewer devices, this should be a good start point.

I have never tested MediaTek or Unisoc devices, but for Qualcomm devices, this should work properly.

The point is, simply rename, eliminate and resize partitions so it will behave like A-only devices.

Devices with AVB1 need to repurpose these partitions:

boot_a -> boot
boot_b -> recovery
modem_a -> modem
modem_b -> (whatever you want)
bluetooth_a -> bluetooth
bluetooth_b -> (whatever you want)
dsp_a -> dsp
dsp_b -> dsp
mdtp_a -> mdtp
mdtp_b -> (whatever you want)
system_a -> system
vendor_a -> vendor
system_b -> (eliminated)
vendor_b -> (eliminated)
userdata -> enlarged

Devices with AVB2 need to repurpose these partitions additionally:

dtbo_a -> dtbo
dtbo_b -> (whatever you want)
vbmeta_a -> vbmeta
vbmeta_b -> (whatever you want)

MediaTek and Unisoc devices may have few more different partitions, may need to take care of them individually.

Few OEMs may have minor differences on few partitions - for example, HTC renamed modem to radio.

I know there's one device with such paranoid partition layout, that is Blackberry Key 2 (BBF100). I was wondering if using such paranoid partition layout on other A/B devices will make it behave like A-only devices, and the answer is yes.

To readers who want to check partition table of Blackberry Key 2, please unhide following content.

Sector size (logical): 512 bytes
Disk identifier (GUID): 85AF7333-4C28-063E-1A0A-A25F7F0A55C7
Partition table holds up to 80 entries
Main partition table begins at sector 2 and ends at sector 21
First usable sector is 34, last usable sector is 122142686
Partitions will be aligned on 8-sector boundaries
Total free space is 27642 sectors (13.5 MiB)

Number Start (sector) End (sector) Size Code Name
1 40 16383 8.0 MiB FFFF padding0
2 16384 18431 1024.0 KiB FFFF traceability
3 18432 32767 7.0 MiB FFFF padding1
4 32768 40959 4.0 MiB A02A fsg
5 40960 43007 1024.0 KiB FFFF dip
6 43008 43015 4.0 KiB A021 devinfo
7 43016 43527 256.0 KiB A022 apdp
8 43528 44039 256.0 KiB A023 msadp
9 44040 44041 1024 bytes A024 dpo
10 44048 110895 32.6 MiB FFFF splash
11 110896 110903 4.0 KiB A040 limits
12 110904 112951 1024.0 KiB FFFF toolsfv
13 112952 114999 1024.0 KiB A01A ddr
14 115000 115031 16.0 KiB A01D sec
15 115032 115287 128.0 KiB FFFF storsec
16 115288 123479 4.0 MiB FFFF tunning
17 123480 123983 252.0 KiB FFFF prdid
18 123984 124487 252.0 KiB FFFF boardid
19 124488 124615 64.0 KiB FFFF vbmeta
20 124616 126663 1024.0 KiB FFFF bluetooth
21 126664 159431 16.0 MiB FFFF dsp
22 159432 224967 32.0 MiB FFFF mdtp
23 224968 356039 64.0 MiB A036 boot
24 356040 581319 110.0 MiB 0700 modem
25 581320 581327 4.0 KiB FFFF bootsig
26 581328 589823 4.1 MiB FFFF padding2
27 589824 596991 3.5 MiB A012 xbl_a
28 596992 605183 4.0 MiB A016 tz_a
29 605184 606207 512.0 KiB A018 rpm_a
30 606208 607231 512.0 KiB A017 hyp_a
31 607232 608255 512.0 KiB A01E pmic_a
32 608256 610303 1024.0 KiB FFFF keymaster_a
33 610304 612351 1024.0 KiB FFFF cmnlib_a
34 612352 614399 1024.0 KiB FFFF cmnlib64_a
35 614400 622591 4.0 MiB FFFF mdtpsecapp_a
36 622592 624639 1024.0 KiB FFFF devcfg_a
37 624640 626687 1024.0 KiB FFFF abl_a
38 626688 638975 6.0 MiB FFFF padding3
39 638976 646143 3.5 MiB FFFF xbl_b
40 646144 654335 4.0 MiB FFFF tz_b
41 654336 655359 512.0 KiB FFFF rpm_b
42 655360 656383 512.0 KiB FFFF hyp_b
43 656384 657407 512.0 KiB FFFF pmic_b
44 657408 659455 1024.0 KiB FFFF keymaster_b
45 659456 661503 1024.0 KiB FFFF cmnlib_b
46 661504 663551 1024.0 KiB FFFF cmnlib64_b
47 663552 671743 4.0 MiB FFFF mdtpsecapp_b
48 671744 673791 1024.0 KiB FFFF devcfg_b
49 673792 675839 1024.0 KiB FFFF abl_b
50 688128 704511 8.0 MiB FFFF logfs
51 704512 704513 1024 bytes A029 fsc
52 704520 704535 8.0 KiB A02C ssd
53 704536 770071 32.0 MiB A026 persist
54 770072 772119 1024.0 KiB A01F misc
55 772120 773143 512.0 KiB A02D keystore
56 773144 774167 512.0 KiB FFFF frp
57 774168 905231 64.0 MiB A025 recovery
58 905232 905239 4.0 KiB FFFF recoverysig
59 905240 946199 20.0 MiB FFFF hdcp
60 946200 1048599 50.0 MiB FFFF oempersist
61 1048600 1179671 64.0 MiB FFFF logdump
62 1179672 1183767 2.0 MiB FFFF sti
63 1183768 1445911 128.0 MiB A01C rawdump
64 1445912 1454103 4.0 MiB A027 modemst1
65 1454104 1462295 4.0 MiB A028 modemst2
66 1462296 1462807 256.0 KiB FFFF perm
67 1462808 1463319 256.0 KiB FFFF nvuser
68 1463320 1465367 1024.0 KiB FFFF metadata
69 1465368 1498135 16.0 MiB FFFF rcause
70 1498136 1522711 12.0 MiB FFFF bcota
71 1522712 1524759 1024.0 KiB FFFF blog
72 1524760 1565719 20.0 MiB FFFF bbpersist
73 1572864 9142271 3.6 GiB FFFF system
74 9142272 10780671 800.0 MiB FFFF vendor
75 10780672 13033471 1.1 GiB FFFF oem
76 13041664 15138815 1024.0 MiB A039 cache
77 15138816 122142686 51.0 GiB A03A userdata

Now let's get started with the modding procedure.

Step 1: Get the gpt_both0.bin

This can be found from your stock firmware. If it doesn't exist, you have to dump it. Take the phone with eMMC storage for example:

dd if=/dev/block/mmcblk0 of=/storage/emulated/0/gpt_both0.bin bs=512 count=67

For devices with UFS storage, you have to get gpt_both0.bin - gpt_both5.bin from stock firmware or dump from /dev/block/sda ~ /dev/block/sdf.

If it's dumped from the phone, save it to a safe place to ensure we can restore partition table anytime we want.

Step 2: Hack the gpt_both0.bin (or gpt_both*.bin for UFS storage) - rename partitions

Make a copy of the gpt_both0.bin and use Hex Editor to open the gpt_both0.bin.

The actual partition table is separated into 2 parts, one is main partition table, another is backup.

main partition table is located between these offsets: 0x400~0x43FF

backup partition table is located between these offsets: 0x4400~0x83FF

As contents of 0x400~0x43FF and 0x4400~0x83FF are identical, we just need to edit the content between 0x400~0x43FF, then copy what we have done between 0x400~0x43FF and overwrite into 0x4400~0x83FF.

Every 0x7F content between 0x400~0x43FF is information of a partition. Take this for example:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000 D4 6C 03 77 D5 03 BB 42 8E D1 37 E5 A8 8B AA 34 Ôl.wÕ.»BŽÑ7å¨‹ª4
00000010 E7 1F 76 6E 50 DA DC 52 E6 6E 63 D4 6C 4D 06 C5 ç.vnPÚÜRæncÔlM.Å
00000020 00 10 10 00 00 00 00 00 FF 0F 12 00 00 00 00 00 ........ÿ.......
00000030 00 00 00 00 00 00 00 00 62 00 6F 00 6F 00 74 00 ........b.o.o.t.
00000040 5F 00 62 00 00 00 00 00 00 00 00 00 00 00 00 00 _.b.............
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

0x0~0x1F - GUID of the partition.

0x20~0x27 - Begin offset in reversed order. The unit is KiB. In this case, the begin offset is 0x0000000000101000.

0x28~0x2F - End offset in reversed order. In this case, the end offset is 0x0000000000120FFF.

0x38~0x7F - Partition label. Every character of the partition label need to be separated with 0x00.

Always remember to use the calculator came with BASE-N function (including Windows Calculator and many high-end scientific calculator) to calculate the length of partitions, so we can resize in the next step.

In this part, we will need to rename few partitions.

Take the boot_a and boot_b partitions for example. Just simply rename the partition label.

Before:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00001D80 86 7F 11 20 85 E9 57 43 B9 EE 37 4B C1 D8 48 7D †.. …éWC¹î7KÁØH}
00001D90 12 B0 CE 25 F6 D5 85 67 BC 87 81 4E 99 D2 CD 24 .°Î%öÕ…g¼‡.N™ÒÍ$
00001DA0 00 10 0E 00 00 00 00 00 FF 0F 10 00 00 00 00 00 ........ÿ.......
00001DB0 00 00 00 00 00 00 00 00 62 00 6F 00 6F 00 74 00 ........b.o.o.t.
00001DC0 5F 00 61 00 00 00 00 00 00 00 00 00 00 00 00 00 _.a.............
00001DD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001DE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001DF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001E00 D4 6C 03 77 D5 03 BB 42 8E D1 37 E5 A8 8B AA 34 Ôl.wÕ.»BŽÑ7å¨‹ª4
00001E10 E7 1F 76 6E 50 DA DC 52 E6 6E 63 D4 6C 4D 06 C5 ç.vnPÚÜRæncÔlM.Å
00001E20 00 10 10 00 00 00 00 00 FF 0F 12 00 00 00 00 00 ........ÿ.......
00001E30 00 00 00 00 00 00 00 00 62 00 6F 00 6F 00 74 00 ........b.o.o.t.
00001E40 5F 00 62 00 00 00 00 00 00 00 00 00 00 00 00 00 _.b.............
00001E50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001E60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001E70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

After:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00001D80 86 7F 11 20 85 E9 57 43 B9 EE 37 4B C1 D8 48 7D †.. …éWC¹î7KÁØH}
00001D90 12 B0 CE 25 F6 D5 85 67 BC 87 81 4E 99 D2 CD 24 .°Î%öÕ…g¼‡.N™ÒÍ$
00001DA0 00 10 0E 00 00 00 00 00 FF 0F 10 00 00 00 00 00 ........ÿ.......
00001DB0 00 00 00 00 00 00 00 00 62 00 6F 00 6F 00 74 00 ........b.o.o.t.
00001DC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001DD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001DE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001DF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001E00 D4 6C 03 77 D5 03 BB 42 8E D1 37 E5 A8 8B AA 34 Ôl.wÕ.»BŽÑ7å¨‹ª4
00001E10 E7 1F 76 6E 50 DA DC 52 E6 6E 63 D4 6C 4D 06 C5 ç.vnPÚÜRæncÔlM.Å
00001E20 00 10 10 00 00 00 00 00 FF 0F 12 00 00 00 00 00 ........ÿ.......
00001E30 00 00 00 00 00 00 00 00 72 00 65 00 63 00 6F 00 ........r.e.c.o.
00001E40 76 00 65 00 72 00 79 00 00 00 00 00 00 00 00 00 v.e.r.y.........
00001E50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001E60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00001E70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

As for modem_a and modem_b, here's what I did. You should do the same for bluetooth, dsp and mdtp partitions.

Before:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000800 A2 A0 D0 EB E5 B9 33 44 87 C0 68 B6 B7 26 99 C7 ¢*Ðëå¹3D‡Àh¶·&™Ç
00000810 2B 1D C0 46 24 90 83 B6 96 0B B5 1F 35 4B 61 FF +.ÀF$.ƒ¶–.µ.5Kaÿ
00000820 00 10 02 00 00 00 00 00 FF 7F 05 00 00 00 00 00 ........ÿ.......
00000830 00 00 00 00 00 00 00 10 6D 00 6F 00 64 00 65 00 ........m.o.d.e.
00000840 6D 00 5F 00 61 00 00 00 00 00 00 00 00 00 00 00 m._.a...........
00000850 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000860 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000870 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000880 D4 6C 03 77 D5 03 BB 42 8E D1 37 E5 A8 8B AA 34 Ôl.wÕ.»BŽÑ7å¨‹ª4
00000890 E7 52 D4 C9 31 F9 55 9D F6 A4 56 78 36 07 85 99 çRÔÉ1ùU.ö¤Vx6.…™
000008A0 00 80 05 00 00 00 00 00 FF EF 08 00 00 00 00 00 .€......ÿï......
000008B0 00 00 00 00 00 00 00 10 6D 00 6F 00 64 00 65 00 ........m.o.d.e.
000008C0 6D 00 5F 00 62 00 00 00 00 00 00 00 00 00 00 00 m._.b...........
000008D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000008E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000008F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

After:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000800 A2 A0 D0 EB E5 B9 33 44 87 C0 68 B6 B7 26 99 C7 ¢*Ðëå¹3D‡Àh¶·&™Ç
00000810 2B 1D C0 46 24 90 83 B6 96 0B B5 1F 35 4B 61 FF +.ÀF$.ƒ¶–.µ.5Kaÿ
00000820 00 10 02 00 00 00 00 00 FF 7F 05 00 00 00 00 00 ........ÿ.......
00000830 00 00 00 00 00 00 00 10 6D 00 6F 00 64 00 65 00 ........m.o.d.e.
00000840 6D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 m...............
00000850 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000860 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000870 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000880 D4 6C 03 77 D5 03 BB 42 8E D1 37 E5 A8 8B AA 34 Ôl.wÕ.»BŽÑ7å¨‹ª4
00000890 E7 52 D4 C9 31 F9 55 9D F6 A4 56 78 36 07 85 99 çRÔÉ1ùU.ö¤Vx6.…™
000008A0 00 80 05 00 00 00 00 00 FF EF 08 00 00 00 00 00 .€......ÿï......
000008B0 00 00 00 00 00 00 00 10 65 00 6C 00 69 00 6D 00 ........e.l.i.m.
000008C0 69 00 6E 00 61 00 74 00 65 00 64 00 5F 00 6D 00 i.n.a.t.e.d._.m.
000008D0 6F 00 64 00 65 00 6D 00 5F 00 62 00 00 00 00 00 o.d.e.m._.b.....
000008E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000008F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

For devices with AVB2 enabled, you should know how to repurpose dtbo and vbmeta partitions.

Step 3: Eliminate system_b, vendor_b, and repurpose remaining partitions

This depends on how your phone originally partitioned. In many cases for devices with eMMC storage, system_a, system_b, vendor_a, vendor_b and userdata are 5 last partitions of the phone.

Take this one for example. Before:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00002C00 11 B0 D7 97 DA 54 35 48 B3 C4 91 7A D6 E7 3D 74 .°×—ÚT5H³Ä‘zÖç=t
00002C10 42 C8 9A 2C 46 11 33 9D C7 90 B8 74 F4 FC F6 4B BÈš,F.3.Ç.¸tôüöK
00002C20 18 EC 1F 00 00 00 00 00 17 EC 6F 00 00 00 00 00 .ì.......ìo.....
00002C30 00 00 00 00 00 00 00 00 73 00 79 00 73 00 74 00 ........s.y.s.t.
00002C40 65 00 6D 00 5F 00 61 00 00 00 00 00 00 00 00 00 e.m._.a.........
00002C50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C80 D4 6C 03 77 D5 03 BB 42 8E D1 37 E5 A8 8B AA 34 Ôl.wÕ.»BŽÑ7å¨‹ª4
00002C90 D2 4C 63 24 6E 37 13 6F 57 5B 73 4A B3 8A 93 EC ÒLc$n7.oW[sJ³Š“ì
00002CA0 18 EC 6F 00 00 00 00 00 17 EC BF 00 00 00 00 00 .ìo......ì¿.....
00002CB0 00 00 00 00 00 00 00 00 73 00 79 00 73 00 74 00 ........s.y.s.t.
00002CC0 65 00 6D 00 5F 00 62 00 00 00 00 00 00 00 00 00 e.m._.b.........
00002CD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002CE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002CF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D00 11 B0 D7 97 DA 54 35 48 B3 C4 91 7A D6 E7 3D 74 .°×—ÚT5H³Ä‘zÖç=t
00002D10 87 4C 96 DB C8 A9 3F 76 E8 BF FF 62 5B A4 42 20 ‡L–ÛÈ©?vè¿ÿb[¤B
00002D20 00 00 C0 00 00 00 00 00 FF FF CF 00 00 00 00 00 ..À.....ÿÿÏ.....
00002D30 00 00 00 00 00 00 00 10 76 00 65 00 6E 00 64 00 ........v.e.n.d.
00002D40 6F 00 72 00 5F 00 61 00 00 00 00 00 00 00 00 00 o.r._.a.........
00002D50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D80 D4 6C 03 77 D5 03 BB 42 8E D1 37 E5 A8 8B AA 34 Ôl.wÕ.»BŽÑ7å¨‹ª4
00002D90 21 A8 AB 40 79 5E 89 16 78 16 A6 B6 17 D7 EA 01 !¨«@y^‰.x.¦¶.×ê.
00002DA0 00 00 D0 00 00 00 00 00 FF FF DF 00 00 00 00 00 ..Ð.....ÿÿß.....
00002DB0 00 00 00 00 00 00 00 10 76 00 65 00 6E 00 64 00 ........v.e.n.d.
00002DC0 6F 00 72 00 5F 00 62 00 00 00 00 00 00 00 00 00 o.r._.b.........
00002DD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E00 E6 E7 81 1B 0D F5 9B 41 A7 39 2A EE F8 DA 33 35 æç...õ›A§9*îøÚ35
00002E10 9C 19 0C DB 03 B2 D8 DB 79 62 74 EB F6 88 6D C7 œ..Û.²ØÛybtëöˆmÇ
00002E20 00 00 E0 00 00 00 00 00 FF FF DF 00 00 00 00 00 ..à.....ÿÿß.....
00002E30 00 00 00 00 00 00 00 00 75 00 73 00 65 00 72 00 ........u.s.e.r.
00002E40 64 00 61 00 74 00 61 00 00 00 00 00 00 00 00 00 d.a.t.a.........
00002E50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

We need to move 0x2D00~0x2D7F to 0x2C80~0x2CFF, and 0x2E00~0x2E7F to 0x2D00~0x2D7F, then fill 0x2D80~2E70 with 0x00.

And of course, rename system_a to system, vendor_a to vendor.

And here's the result:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00002C00 11 B0 D7 97 DA 54 35 48 B3 C4 91 7A D6 E7 3D 74 .°×—ÚT5H³Ä‘zÖç=t
00002C10 42 C8 9A 2C 46 11 33 9D C7 90 B8 74 F4 FC F6 4B BÈš,F.3.Ç.¸tôüöK
00002C20 18 EC 1F 00 00 00 00 00 17 EC 6F 00 00 00 00 00 .ì.......ìo.....
00002C30 00 00 00 00 00 00 00 00 73 00 79 00 73 00 74 00 ........s.y.s.t.
00002C40 65 00 6D 00 00 00 00 00 00 00 00 00 00 00 00 00 e.m.............
00002C50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C80 11 B0 D7 97 DA 54 35 48 B3 C4 91 7A D6 E7 3D 74 .°×—ÚT5H³Ä‘zÖç=t
00002C90 87 4C 96 DB C8 A9 3F 76 E8 BF FF 62 5B A4 42 20 ‡L–ÛÈ©?vè¿ÿb[¤B
00002CA0 00 00 C0 00 00 00 00 00 FF FF CF 00 00 00 00 00 ..À.....ÿÿÏ.....
00002CB0 00 00 00 00 00 00 00 10 76 00 65 00 6E 00 64 00 ........v.e.n.d.
00002CC0 6F 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 o.r.............
00002CD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002CE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002CF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D00 E6 E7 81 1B 0D F5 9B 41 A7 39 2A EE F8 DA 33 35 æç...õ›A§9*îøÚ35
00002D10 9C 19 0C DB 03 B2 D8 DB 79 62 74 EB F6 88 6D C7 œ..Û.²ØÛybtëöˆmÇ
00002D20 00 00 E0 00 00 00 00 00 FF FF DF 00 00 00 00 00 ..à.....ÿÿß.....
00002D30 00 00 00 00 00 00 00 00 75 00 73 00 65 00 72 00 ........u.s.e.r.
00002D40 64 00 61 00 74 00 61 00 00 00 00 00 00 00 00 00 d.a.t.a.........
00002D50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

You might have noticed, there're two huge gaps between system and vendor, vendor and userdata, so we need to edit the offset of vendor and userdata to eliminate the huge gaps.

In this case, the end offset of system partition is 0x00000000006FEC17. Therefore, the begin offset of vendor partition should be at least 0x00000000006FEC18. Just take note.

The original offset of vendor partition is 0x0000000000C00000~0x0000000000CFFFFF. It's not hard to get the length of vendor partition is 0xFFFFF.

With the help of calculator, we can get the new end offset of vendor partition is 0x00000000007FEC17.

As for userdata partition, the begin offset need to be at least 0x00000000007FEC18, but for end offset need to be the same to vendor partition. Therefore, bootloader will use allocate all of remaining storage space to userdata.

(This is for the most of cases, if userdata is the last partition of your phone)

Now we get new offset of vendor and userdata partition:

vendor: 0x00000000006FEC18~0x00000000007FEC17

userdata: 0x00000000007FEC18~0x00000000007FEC17

Input them into the partition table.

So the result is:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00002C00 11 B0 D7 97 DA 54 35 48 B3 C4 91 7A D6 E7 3D 74 .°×—ÚT5H³Ä‘zÖç=t
00002C10 42 C8 9A 2C 46 11 33 9D C7 90 B8 74 F4 FC F6 4B BÈš,F.3.Ç.¸tôüöK
00002C20 18 EC 1F 00 00 00 00 00 17 EC 6F 00 00 00 00 00 .ì.......ìo.....
00002C30 00 00 00 00 00 00 00 00 73 00 79 00 73 00 74 00 ........s.y.s.t.
00002C40 65 00 6D 00 00 00 00 00 00 00 00 00 00 00 00 00 e.m.............
00002C50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002C80 11 B0 D7 97 DA 54 35 48 B3 C4 91 7A D6 E7 3D 74 .°×—ÚT5H³Ä‘zÖç=t
00002C90 87 4C 96 DB C8 A9 3F 76 E8 BF FF 62 5B A4 42 20 ‡L–ÛÈ©?vè¿ÿb[¤B
00002CA0 18 EC 6F 00 00 00 00 00 17 EC 7F 00 00 00 00 00 .ìo......ì......
00002CB0 00 00 00 00 00 00 00 10 76 00 65 00 6E 00 64 00 ........v.e.n.d.
00002CC0 6F 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 o.r.............
00002CD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002CE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002CF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D00 E6 E7 81 1B 0D F5 9B 41 A7 39 2A EE F8 DA 33 35 æç...õ›A§9*îøÚ35
00002D10 9C 19 0C DB 03 B2 D8 DB 79 62 74 EB F6 88 6D C7 œ..Û.²ØÛybtëöˆmÇ
00002D20 7F EC 18 00 00 00 00 00 7F EC 17 00 00 00 00 00 .ì.......ì......
00002D30 00 00 00 00 00 00 00 00 75 00 73 00 65 00 72 00 ........u.s.e.r.
00002D40 64 00 61 00 74 00 61 00 00 00 00 00 00 00 00 00 d.a.t.a.........
00002D50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002D90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DA0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DB0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DC0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DD0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DE0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002DF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00002E70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

Step 4: Copy what we have done to backup partition table, and save it as "gpt_main0.mod.bin"

Pretty simple. Copy the content between 0x400~0x43FF and overwrite it from 0x4400, so the backup partition table will get the same result.

Now save it as "gpt_main0.mod.bin".

Step 5: Flash it to your phone and check result

This may require your phone get critical unlocked (fastboot flashing unlock_critical).

Before you flash, you can use this command to check what are the partitions originally be:

For macOS / Linux distro:

fastboot getvar all|grep partition-size

For Windows:

fastboot getvar all 2>&1|findstr partition-size

Flash it with this command:

fastboot flash partition /path/to/gpt_main0.mod.bin
fastboot reboot-bootloader

For devices with UFS storage (take partition table of lun3 for example):

fastboot flash partition:3 /path/to/gpt_main3.mod.bin
fastboot reboot-bootloader

After that, you can use this command to check the result:

For macOS / Linux distro:

fastboot getvar all|grep partition-size

For Windows:

fastboot getvar all 2>&1|findstr partition-size

If values changed to what you have expected (unit is bytes), then the modification is successful.

From what I have tested, flash existing TWRP to recovery partition and boot it with recovery mode combination key will make the phone boot to TWRP successfully, and it can still mount system/vendor partitions - no modifications need to be done.

However, the phone will not boot with unmodified boot image, may need to modify fstab and init.rc to ensure it will boot on such environment, and this is up to developers.

That wraps up the entire guide, and I hope it could be helpful for custom ROM development.