On Ubuntu Xenial I used the following command for resizing the root partition of new VMs:
echo 'yes' | parted ---pretend-input-tty /dev/sda resizepart 1 yes 10GiB
However, on Ubuntu Jammy this doesn't seem to work anymore. Instead I'm getting the following output:
root@server:~# echo 'yes' | parted ---pretend-input-tty /dev/sda resizepart 1 yes 10GiB
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? yes
Error: Invalid number.
I have found recommendations to move the "yes" to the end, but even though I don't get the above error anymore:
root@server:~# echo 'yes' | parted ---pretend-input-tty /dev/sda resizepart 1 10GiB yes
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? yes
Warning: Shrinking a partition can cause data loss, are you sure you want to continue?
Yes/No?
the partition is not being resized either.
I also tried
parted /dev/sda --script resizepart 1 10GiB
and
parted /dev/sda --script resizepart 1 10GiB yes
without success.