Subject: Re: bug#71790: parted -s emits a warning when shrinking a partition

From: "Brian C. Lane" <[email-masked]>
Date: Thu, 27 Jun 2024 08:28:55 -0700

On Wed, Jun 26, 2024 at 11:51:38PM +0100, Sean Warner wrote:
> I am also having this bug reported in 2017:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879555
> 
> $ parted -v
> parted (GNU parted) 3.6
> Copyright (C) 2023 Free Software Foundation, Inc.
> License GPLv3+
> Written by
> <http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.
> 
> $ cat /etc/lsb-release 
> DISTRIB_ID="ManjaroLinux"
> DISTRIB_RELEASE="24.0.2"
> DISTRIB_CODENAME="Wynsdey"
> 
> -- If increasing the size of a partition the following command works
> but if shrinking a partition it gives a warning "Warning: Shrinking a
> partition can cause data loss, are you sure you want to continue?" and
> the command just exits back to the command prompt and no changes are
> made to the partition.
> 
> sudo parted -s /dev/loop0 resizepart 1 46280703s
> 
> I assumed that parted -s would automatically supply a default value of
> 'Yes' in this instance?

No, in script mode parted defaults to the safe option. Automatically
saying yes will lead to data loss so it defaults to know. I admit the
message is misleading, this is because of how parted handles warnings
like this and it could use some improvement.

I don't really have any suggestion for working around this other than
doing it in interactive mode.

> input-tty <-- But is this safe to keep using if not documented? Any
> plans to make ---pretend-input-tty an official "thing" in Parted?

No, it's there for the tests. But there's no plan to remove it since the
tests depend on it. But I really don't recommend automating things that
could lose data.

Brian

-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart