CLI or command linux after resize disk on kvm virtual machine, OS Ubuntu 22.04

This command is posible can be applied to another OS other than ubuntu. after resize disk images using qemu-img resize, we can login to VM and do update the disk partition table using growpart, just choose number of partition that need to update, pros on growpart command is can be use on first, in beetween or last partition of disk. you can see the partition using fdisk -l or lsblk. and then you can resize disk to fill unallocated space with resize2fs, xfs_growfs depend on disk filesystem.

Explanation :

The most problem on this issue is the position of disk Operating System partition on partition table not always on last of partition sometimes the partition is on the first or in beetween of disk partition, so command like resize2fs or xfs_growfs is not always solve this issue.

To solve resize disk issue is we need to know the number of partition that contain Operating System data. luckily if we use this partition is on last part so we can directly use resize2fs to expand disk space, but it would be problem if this partition is on first or in beetween partition because we need to move the partitions so we can extend the Operating System data partition and then using resize2fs to use unallocated disk space.