Guidelines

This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes
1.1k views
1.1k views

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.

in Sysadmin
by (115)
2 18 33
edit history

Please log in or register to answer this question.

1 Answer

0 votes
 

I don't know why the parted developers think it's a good idea to make admins jump through hoops, but they need to stop that.

Anyway, your original commandline is still kind of the way to go, but there is another confirmation dialog now, that you must respond to as well. Basically echo "yes" into parted twice, and the partition resize should work:

root@server:~# echo -e 'yes\nyes' | parted ---pretend-input-tty /dev/sda resizepart 1 10GiB
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? yes                                                               
Information: You may need to update /etc/fstab.
by (115)
2 18 33
edit history
...