[Xiaomi Mi Pad 5] maverick_jia:
This guide was first written by serdeliuk, and I rewrote it from my records at the time.

You can download xiaomi-nabu-orangefox.img blew, also by serdeliuk:

xiaomi-nabu-orangefox.img

drive.google.com

enter fastboot mode

I:\platform-tools>fastboot devices
e36212f4 fastboot

load OrangeFOX image(don't flash it to ufs)

fastboot boot xiaomi-nabu-orangefox.img

After loading, the system will restart and enter OrangeFOX. You can see a blue screen because the display is not quite normal, but it does not affect use.

I:\platform-tools>adb devices
List of devices attached
e36212f4 recovery

enter adb shell

I:\platform-tools>adb shell
sh-5.0#

Get the location of the userdata partition:

sh-5.0# ls -l /dev/block/bootdevice/by-name/ | grep userdata
lrwxrwxrwx 1 root root 16 1971-06-22 05:04 userdata -> /dev/block/sda31

The userdata partition is in the 31st partition of the sda device.

Use the 'parted' tool to resize the userdata partition

sh-5.0# parted /dev/block/sda
GNU Parted 3.3
Using /dev/block/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

Enter 'print' command to list all partitions for /dev/block/sda

(parted) print
print
Model: SAMSUNG KLUDG4UHDC-B0E1 (scsi)
Disk /dev/block/sda: 126GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 32.8kB 8192B switch
2 32.8kB 65.5kB 32.8kB ssd
3 65.5kB 98.3kB 32.8kB dbg
4 98.3kB 131kB 32.8kB bk01
5 131kB 262kB 131kB bk02
6 262kB 524kB 262kB bk03
7 524kB 1049kB 524kB bk04
8 1049kB 1573kB 524kB keystore
9 1573kB 2097kB 524kB frp
10 2097kB 4194kB 2097kB countrycode
11 4194kB 8389kB 4194kB misc
12 8389kB 12.6MB 4194kB vm-data
13 12.6MB 16.8MB 4194kB bk06
14 16.8MB 25.2MB 8389kB logfs
15 25.2MB 33.6MB 8389kB ffu
16 33.6MB 50.3MB 16.8MB oops
17 50.3MB 67.1MB 16.8MB devinfo
18 67.1MB 83.9MB 16.8MB oem_misc1
19 83.9MB 101MB 16.8MB ext4 metadata
20 101MB 134MB 32.9MB bk08
21 134MB 168MB 34.2MB splash
22 168MB 201MB 33.6MB bk09
23 201MB 9328MB 9127MB super
24 9328MB 9328MB 131kB vbmeta_system_a
25 9328MB 9328MB 131kB vbmeta_system_b
26 9328MB 9396MB 67.1MB logdump
27 9396MB 9530MB 134MB minidump
28 9530MB 9664MB 134MB rawdump
29 9664MB 10.7GB 1074MB ext4 cust
30 10.7GB 10.9GB 134MB ext4 rescue
31 10.9GB 126GB 115GB userdata

Delete partition 31 and again make sure it is not deleted incorrectly.

(parted) rm 31
rm 31

Check the results:

(parted) print
print
Model: SAMSUNG KLUDG4UHDC-B0E1 (scsi)
Disk /dev/block/sda: 126GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 32.8kB 8192B switch
2 32.8kB 65.5kB 32.8kB ssd
3 65.5kB 98.3kB 32.8kB dbg
4 98.3kB 131kB 32.8kB bk01
5 131kB 262kB 131kB bk02
6 262kB 524kB 262kB bk03
7 524kB 1049kB 524kB bk04
8 1049kB 1573kB 524kB keystore
9 1573kB 2097kB 524kB frp
10 2097kB 4194kB 2097kB countrycode
11 4194kB 8389kB 4194kB misc
12 8389kB 12.6MB 4194kB vm-data
13 12.6MB 16.8MB 4194kB bk06
14 16.8MB 25.2MB 8389kB logfs
15 25.2MB 33.6MB 8389kB ffu
16 33.6MB 50.3MB 16.8MB oops
17 50.3MB 67.1MB 16.8MB devinfo
18 67.1MB 83.9MB 16.8MB oem_misc1
19 83.9MB 101MB 16.8MB ext4 metadata
20 101MB 134MB 32.9MB bk08
21 134MB 168MB 34.2MB splash
22 168MB 201MB 33.6MB bk09
23 201MB 9328MB 9127MB super
24 9328MB 9328MB 131kB vbmeta_system_a
25 9328MB 9328MB 131kB vbmeta_system_b
26 9328MB 9396MB 67.1MB logdump
27 9396MB 9530MB 134MB minidump
28 9530MB 9664MB 134MB rawdump
29 9664MB 10.7GB 1074MB ext4 cust
30 10.7GB 10.9GB 134MB ext4 rescue

Note the end of the last partition in the above list, 10.9GB, this number will be used as the start of the new userdata partition, followed by the end of the partition. Let say that we want to make an approx 40GB userdata partititon using the following command: NOTE, between userdata and 10.9GB are 3 spaces, one of them replace the partition type flag, it is important to use 3 spaces at this step.

(parted) mkpart userdata 10.9GB 50GB
mkpart userdata 10.9GB 50GB

Run print again to see the results:

(parted) print
print
Model: SAMSUNG KLUDG4UHDC-B0E1 (scsi)
Disk /dev/block/sda: 126GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 32.8kB 8192B switch
2 32.8kB 65.5kB 32.8kB ssd
3 65.5kB 98.3kB 32.8kB dbg
4 98.3kB 131kB 32.8kB bk01
5 131kB 262kB 131kB bk02
6 262kB 524kB 262kB bk03
7 524kB 1049kB 524kB bk04
8 1049kB 1573kB 524kB keystore
9 1573kB 2097kB 524kB frp
10 2097kB 4194kB 2097kB countrycode
11 4194kB 8389kB 4194kB misc
12 8389kB 12.6MB 4194kB vm-data
13 12.6MB 16.8MB 4194kB bk06
14 16.8MB 25.2MB 8389kB logfs
15 25.2MB 33.6MB 8389kB ffu
16 33.6MB 50.3MB 16.8MB oops
17 50.3MB 67.1MB 16.8MB devinfo
18 67.1MB 83.9MB 16.8MB oem_misc1
19 83.9MB 101MB 16.8MB ext4 metadata
20 101MB 134MB 32.9MB bk08
21 134MB 168MB 34.2MB splash
22 168MB 201MB 33.6MB bk09
23 201MB 9328MB 9127MB super
24 9328MB 9328MB 131kB vbmeta_system_a
25 9328MB 9328MB 131kB vbmeta_system_b
26 9328MB 9396MB 67.1MB logdump
27 9396MB 9530MB 134MB minidump
28 9530MB 9664MB 134MB rawdump
29 9664MB 10.7GB 1074MB ext4 cust
30 10.7GB 10.9GB 134MB ext4 rescue
31 10.9GB 50.0GB 39.1GB userdata

Exit the parted tool:

(parted) quit
quit
Information: You may need to update /etc/fstab.
Reboot to Android and let the OS do the job fixing and formatting the userdata on the new size, will take a while to boot first time after resize, so grab a coffee, a beer, or else, note, it is important to keep the original partition name "userdata".

[CODE]sh-5.0# reboot

You need to clear the data as prompted and restart the system.

Allocate space:

Enter fastboot mode and repeat the previous steps

fastboot boot xiaomi-nabu-orangefox.img
adb devices
adb shell
parted /dev/block/sda

Use the last end as the start of the new partition and for end the desired extra size for your partition, let pretend we want a 20GB pmos partition as ext4 (minimum partition size is 4GB)

(parted) mkpart pmos ext4 50.0GB 70GB
mkpart pmos ext4 50.0GB 70GB

After each command you can check the free/available space with following command

(parted) print free
print free
Model: SAMSUNG KLUDG4UHDC-B0E1 (scsi)
Disk /dev/block/sda: 126GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
12.3kB 24.6kB 12.3kB Free Space
1 24.6kB 32.8kB 8192B switch
2 32.8kB 65.5kB 32.8kB ssd
3 65.5kB 98.3kB 32.8kB dbg
4 98.3kB 131kB 32.8kB bk01
5 131kB 262kB 131kB bk02
6 262kB 524kB 262kB bk03
7 524kB 1049kB 524kB bk04
8 1049kB 1573kB 524kB keystore
9 1573kB 2097kB 524kB frp
10 2097kB 4194kB 2097kB countrycode
11 4194kB 8389kB 4194kB misc
12 8389kB 12.6MB 4194kB vm-data
13 12.6MB 16.8MB 4194kB bk06
14 16.8MB 25.2MB 8389kB logfs
15 25.2MB 33.6MB 8389kB ffu
16 33.6MB 50.3MB 16.8MB oops
17 50.3MB 67.1MB 16.8MB devinfo
18 67.1MB 83.9MB 16.8MB oem_misc1
19 83.9MB 101MB 16.8MB ext4 metadata
20 101MB 134MB 32.9MB bk08
21 134MB 168MB 34.2MB splash
22 168MB 201MB 33.6MB bk09
23 201MB 9328MB 9127MB super
24 9328MB 9328MB 131kB vbmeta_system_a
25 9328MB 9328MB 131kB vbmeta_system_b
26 9328MB 9396MB 67.1MB logdump
27 9396MB 9530MB 134MB minidump
28 9530MB 9664MB 134MB rawdump
29 9664MB 10.7GB 1074MB ext4 cust
30 10.7GB 10.9GB 134MB ext4 rescue
10.9GB 10.9GB 786kB Free Space
31 10.9GB 50.0GB 39.1GB userdata
32 50.0GB 70.0GB 20.0GB ext4 pmos
70.0GB 126GB 55.6GB Free Space

Exit the parted tool:

(parted) quit
quit

Information: You may need to update /etc/fstab.

Restart the system and enter fastboot again

sh-5.0# reboot

Check which slot android is written in:

I:\platform-tools>fastboot getvar current-slot
current-slot: b
Finished. Total time: 0.004s

android uses slot 'b', and we burn ubuntu into slot 'a'

active slot 'a'

I:\platform-tools>fastboot set_active a
Setting current slot to 'a' OKAY [ 0.049s]
Finished. Total time: 0.064s

Burn images

Flash the new vbmeta with disabled verified boot, more info in PostmarketOS Wiki at Android_Verified_Boot_(AVB)

I:\platform-tools>fastboot flash vbmeta_a vbmeta_disabled.img
Sending 'vbmeta_a' (4 KB) OKAY [ 0.007s]
Writing 'vbmeta_a' OKAY [ 0.003s]
Finished. Total time: 0.048s

Erase Android DTBO partition, we do not need it, but if present will be loaded and will prevent our boot

I:\platform-tools>fastboot erase dtbo_a
Erasing 'dtbo_a' OKAY [ 0.007s]
Finished. Total time: 0.022s

Flash boot.img

I:\platform-tools>fastboot flash boot_a boot.img
Sending 'boot_a' (13052 KB) OKAY [ 0.327s]
Writing 'boot_a' OKAY [ 0.052s]
Finished. Total time: 0.663s

Flash rootfs image, please use the partition name you created, this process will takew a while, grab another beer

I:\platform-tools>fastboot flash pmos xiaomi-nabu.img
Sending sparse 'pmos' 1/4 (785030 KB) OKAY [ 20.059s]
Writing 'pmos' OKAY [ 0.002s]
Sending sparse 'pmos' 2/4 (699215 KB) OKAY [ 26.711s]
Writing 'pmos' OKAY [ 0.002s]
Sending sparse 'pmos' 3/4 (786381 KB) OKAY [ 20.436s]
Writing 'pmos' OKAY [ 0.001s]
Sending sparse 'pmos' 4/4 (274999 KB) OKAY [ 47.325s]
Writing 'pmos' OKAY [ 0.002s]
Finished. Total time: 162.295s

reboot

I:\platform-tools>fastboot reboot
Rebooting OKAY [ 0.002s]
Finished. Total time: 0.006s