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

Sean Warner <[email protected]> Wed, 26 Jun 2024 23:51:38 +0100
Newsgroups gmane.comp.gnu.parted.bugs
Message-ID <[email protected]>
--=-hxiPDR//ZKkisTxcIxzU
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I am also having this bug reported in 2017:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D879555

$ parted -v
parted (GNU parted) 3.6
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+
Written by
<http://git.debian.org/?p=3Dparted/parted.git;a=3Dblob_plain;f=3DAUTHORS>.

$=C2=A0cat /etc/lsb-release=C2=A0
DISTRIB_ID=3D"ManjaroLinux"
DISTRIB_RELEASE=3D"24.0.2"
DISTRIB_CODENAME=3D"Wynsdey"

-- If increasing the size of a partition the following command works
but if shrinking a partition it=C2=A0gives 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?

According to the Parted Man page:
-s, --script
never prompts for user intervention

Is this a bug or am I misunderstanding something?

From researching the interweb this might be a bug that for many years
has never been addressed.

Previous parted versions apparently allowed for something like:

sudo parted -s /dev/loop0 resizepart 1 yes 46280703s
or
sudo parted -s /dev/loop0 resizepart 1 46280703s yes

But in parted 3.6 there appears to be no way to make this work with
parted -s. The only option is to resort to the undocumented ---pretend-
input-tty <-- But is this safe to keep using if not documented? Any
plans to make ---pretend-input-tty an official "thing" in Parted?

Example that will work whether increasing or reducing the partition
size:

echo -e "resizepart 1 46280703s\nyes\nunit s\nprint\nquit" | sudo
parted /dev/loop0 ---pretend-input-tty

Any help much appreciated,

Flex

--=-hxiPDR//ZKkisTxcIxzU
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html><head><style>pre,code,address {
  margin: 0px;
}
h1,h2,h3,h4,h5,h6 {
  margin-top: 0.2em;
  margin-bottom: 0.2em;
}
ol,ul {
  margin-top: 0em;
  margin-bottom: 0em;
}
blockquote {
  margin-top: 0em;
  margin-bottom: 0em;
}
</style></head><body><div>I am also having this bug reported in 2017:</div>=
<div><a href=3D"https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D879555"=
 title=3D"Click to open https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=
=3D879555">https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D879555</a></=
div><div><br></div><div>$ parted -v</div><div><div>parted (GNU parted) 3.6<=
/div><div>Copyright (C) 2023 Free Software Foundation, Inc.</div><div>Licen=
se GPLv3+</div><div>Written by &lt;<a href=3D"http://git.debian.org/?p=3Dpa=
rted/parted.git;a=3Dblob_plain;f=3DAUTHORS" title=3D"Click to open http://g=
it.debian.org/?p=3Dparted/parted.git;a=3Dblob_plain;f=3DAUTHORS">http://git=
.debian.org/?p=3Dparted/parted.git;a=3Dblob_plain;f=3DAUTHORS</a>&gt;.</div=
></div><div><br></div><div>$&nbsp;<span style=3D"font-family: monospace;">c=
at /etc/lsb-release&nbsp;</span></div><div><div><span style=3D"font-family:=
 monospace;">DISTRIB_ID=3D"ManjaroLinux"<br>DISTRIB_RELEASE=3D"24.0.2"<br>D=
ISTRIB_CODENAME=3D"Wynsdey"<br></span></div></div><div><br></div><div>-- If=
 increasing the size of a partition the following command works but if shri=
nking a partition it&nbsp;gives a warning "Warning: Shrinking a partition c=
an cause data loss, are you sure you want to continue?" and the command jus=
t exits back to the command prompt and no changes are made to the partition=
.</div><div><br></div><div>sudo parted -s /dev/loop0 resizepart 1 46280703s=
</div><div><br></div><div><div>I assumed that parted -s would automatically=
 supply a default value of 'Yes' in this instance?</div></div><div><br></di=
v><div>According to the Parted Man page:</div><div>-s, --script</div><div>n=
ever prompts for user intervention</div><div><br></div><div>Is this a bug o=
r am I misunderstanding something?</div><div><br></div><div>From researchin=
g the interweb this might be a bug that for many years has never been addre=
ssed.</div><div><br></div><div>Previous parted versions apparently allowed =
for something like:</div><div><div><br></div><div>sudo parted -s /dev/loop0=
 resizepart 1 yes 46280703s</div></div><div>or</div><div><div>sudo parted -=
s /dev/loop0 resizepart 1 46280703s yes</div></div><div><br></div><div>But =
in parted 3.6 there appears to be no way to make this work with parted -s. =
The only option is to resort to the undocumented ---pretend-input-tty &lt;-=
- But is this safe to keep using if not documented? Any plans to make ---pr=
etend-input-tty an official "thing" in Parted?</div><div><br></div><div>Exa=
mple that will work whether increasing or reducing the partition size:</div=
><div><br></div><div>echo -e "resizepart 1 46280703s\nyes\nunit s\nprint\nq=
uit" | sudo parted /dev/loop0 ---pretend-input-tty</div><div><br></div><div=
>Any help much appreciated,</div><div><br></div><div>Flex</div><div><span><=
/span></div></body></html>

--=-hxiPDR//ZKkisTxcIxzU--