Hello Brian,

Thank you for your helpful reply.

There are many threads on various sites where people, like me, have
incorrectly assumed that parted -s will let you do whatever you want
and are left confused. It makes sense to apply the philosophy of do-no-
harm with the parted --script option but perhaps the man page needs to
clarify the intended behavior.

Currently it simply says: "-s --script never prompts for user
intervention" instead maybe something like: "Will default safe answers
to user prompts such as 'No' when parted checks if it is OK to shrink a
partition." OK that sounds wordy but I think better to have verbose man
pages that don't leave any doubt as to what the intended functionality
is.

This bug
report https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27204 (Norman
Shulman) proposes a patch to really make parted -s "never prompt for
user intervention" even if shrinking a partition. I tried it out and it
works, at least I have the option now!

--- a/parted/parted.c   2014-06-15 15:16:33.000000000 -0400
+++ b/parted/parted.c   2017-05-24 17:27:02.093371079 -0400
@@ -1551,7 +1551,7 @@ do_resizepart (PedDevice** dev, PedDisk*
                                           start, end))
                 goto error_destroy_constraint;
         /* warn when shrinking partition - might lose data */
-        if (part->geom.end < oldend)
+        if (part->geom.end < oldend && !opt_script_mode)
                 if (ped_exception_throw (
                             PED_EXCEPTION_WARNING,
                             PED_EXCEPTION_YES_NO,

Cheers,

Sean 

-----Original Message-----
From: Brian C. Lane <b...@redhat.com>
To: Sean Warner <plica2...@gmail.com>
Cc: 71...@debbugs.gnu.org
Subject: Re: bug#71790: parted -s emits a warning when shrinking a
partition
Date: 27/06/24 16:28:55

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

Reply via email to