To support the above feature I found out a way to update GPT via approach mentioned by me in the code section. But in the approach if there is any power failure during sgdisk command execution then paritition table may be corrupted. And I dont have external storage where i can connect the device. And also I am using update.zip which i need to download on userdata partition and later i can trigger the OTA. Now is there any other solution which prpl community is using to support above PR? I mean some solution must be there to support above PR. You can find this PR on prplfoundation.
#!/bin/sh
set -e # Exit on error
# Variables
USERDATA_PART="/dev/mmcblk0p3" # Adjust based on your partition layout
NEW_PART_SIZE="4G" # Size of the new partition
USERDATA_NEW_SIZE="8G" # New size of userdata after shrinking
echo "Starting partition resizing..."
# Step 1: Unmount userdata echo "Unmounting userdata..."
umount /data || echo "Userdata not mounted"
# Step 2: Check and resize filesystem echo "Checking and resizing userdata filesystem..."
e2fsck -f $USERDATA_PART
resize2fs $USERDATA_PART $USERDATA_NEW_SIZE
# Step 3: Modify GPT Partition Table
echo "Updating GPT partition table..."
sgdisk --delete=3 /dev/mmcblk0
sgdisk --new=3:0:+$USERDATA_NEW_SIZE --typecode=3:8300 /dev/mmcblk0
sgdisk --new=4:0:+$NEW_PART_SIZE --typecode=4:8300 /dev/mmcblk0
partprobe
# Step 4: Format the partitions echo "Formatting partitions..."
mkfs.ext4 /dev/mmcblk0p3
mkfs.ext4 /dev/mmcblk0p4
# Step 5: Mount and update fstab
echo "Mounting new partition..."
mkdir -p /new_partition mount /dev/mmcblk0p4 /new_partition
echo "/dev/mmcblk0p4 /new_partition ext4 defaults 0 2" >> /etc/fstab
echo "Partition resizing completed successfully!"
reboot