bug#71790: parted -s emits a warning when shrinking a partition
Sean Warner <[email protected]> Thu, 27 Jun 2024 22:54:08 +0100
| Newsgroups | gmane.comp.gnu.parted.bugs |
|---|---|
| Message-ID | <[email protected]> |
--=-IYIVgAHG8uq2uwZw5b6N
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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=C2=A0https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D27204=C2=A0(Nor=
man
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=C2=A0
-----Original Message-----
From: Brian C. Lane <[email protected]>
To: Sean Warner <[email protected]>
Cc: [email protected]
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=3D879555
>=20
> $ 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>=
.
>=20
> $=C2=A0cat /etc/lsb-release=C2=A0
> DISTRIB_ID=3D"ManjaroLinux"
> DISTRIB_RELEASE=3D"24.0.2"
> DISTRIB_CODENAME=3D"Wynsdey"
>=20
> -- 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.
>=20
> sudo parted -s /dev/loop0 resizepart 1 46280703s
>=20
> 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
--=-IYIVgAHG8uq2uwZw5b6N
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>Hello Brian,</div><div><br></div><div>Thank you f=
or your helpful reply.</div><div><br></div><div>There are many threads on v=
arious 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 per=
haps the man page needs to clarify the intended behavior.</div><div><br></d=
iv><div>Currently it simply says: "-s --script <i>never prompts for user in=
tervention</i>" instead maybe something like: "Will default safe answers to=
user prompts such as 'No' when parted checks if it is OK to shrink a parti=
tion." OK that sounds wordy but I think better to have verbose man pages th=
at don't leave any doubt as to what the intended functionality is.</div><di=
v><br></div><div>This bug report <a href=3D"https://debbugs.gnu.org/cg=
i/bugreport.cgi?bug=3D27204">https://debbugs.gnu.org/cgi/bugreport.cgi?bug=
=3D27204</a> (Norman Shulman) proposes a patch to really make parted -=
s "never prompt for user intervention" even if shrinking a partition. I tri=
ed it out and it works, at least I have the option now!</div><div><br></div=
><pre style=3D"color: rgb(0, 0, 0); font-style: normal; font-variant-ligatu=
res: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: n=
ormal; orphans: 2; text-align: start; text-indent: 0px; text-transform: non=
e; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decor=
ation-thickness: initial; text-decoration-style: initial; text-decoration-c=
olor: initial; overflow-wrap: break-word; white-space: pre-wrap;">--- a/par=
ted/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,</pre><div><br></div><div=
>Cheers,</div><div><br></div><div>Sean </div><div><br></div><div>-----=
Original Message-----</div><div><b>From</b>: Brian C. Lane <<a href=3D"m=
ailto:%22Brian%20C.%20Lane%22%20%[email protected]%3e">[email protected]</a>>=
;</div><div><b>To</b>: Sean Warner <<a href=3D"mailto:Sean%20Warner%20%3=
[email protected]%3e">[email protected]</a>></div><div><b>Cc</b>: <=
a href=3D"mailto:[email protected]">[email protected]</a></div><div=
><b>Subject</b>: Re: bug#71790: parted -s emits a warning when shrinking a =
partition</div><div><b>Date</b>: 27/06/24 16:28:55</div><div><br></div><div=
>On Wed, Jun 26, 2024 at 11:51:38PM +0100, Sean Warner wrote:<br></div><blo=
ckquote type=3D"cite" style=3D"margin:0 0 0 .8ex; border-left:2px #729fcf s=
olid;padding-left:1ex"><div>I am also having this bug reported in 2017:<br>=
</div><div><a href=3D"https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D8=
79555">https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D879555</a><br></=
div><div><br></div><div>$ parted -v<br></div><div>parted (GNU parted) 3.6<b=
r></div><div>Copyright (C) 2023 Free Software Foundation, Inc.<br></div><di=
v>License GPLv3+<br></div><div>Written by<br></div><div><<a href=3D"http=
://git.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>>.<=
br></div><div><br></div><div>$ cat /etc/lsb-release <br></div><di=
v>DISTRIB_ID=3D"ManjaroLinux"<br></div><div>DISTRIB_RELEASE=3D"24.0.2"<br><=
/div><div>DISTRIB_CODENAME=3D"Wynsdey"<br></div><div><br></div><div>-- If i=
ncreasing the size of a partition the following command works<br></div><div=
>but if shrinking a partition it gives a warning "Warning: Shrinking a=
<br></div><div>partition can cause data loss, are you sure you want to cont=
inue?" and<br></div><div>the command just exits back to the command prompt =
and no changes are<br></div><div>made to the partition.<br></div><div><br><=
/div><div>sudo parted -s /dev/loop0 resizepart 1 46280703s<br></div><div><b=
r></div><div>I assumed that parted -s would automatically supply a default =
value of<br></div><div>'Yes' in this instance?<br></div></blockquote><div><=
br></div><div>No, in script mode parted defaults to the safe option. Automa=
tically<br></div><div>saying yes will lead to data loss so it defaults to k=
now. I admit the<br></div><div>message is misleading, this is because of ho=
w parted handles warnings<br></div><div>like this and it could use some imp=
rovement.<br></div><div><br></div><div>I don't really have any suggestion f=
or working around this other than<br></div><div>doing it in interactive mod=
e.<br></div><div><br></div><blockquote type=3D"cite" style=3D"margin:0 0 0 =
.8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>input-tty <--=
But is this safe to keep using if not documented? Any<br></div><div>plans =
to make ---pretend-input-tty an official "thing" in Parted?<br></div></bloc=
kquote><div><br></div><div>No, it's there for the tests. But there's no pla=
n to remove it since the<br></div><div>tests depend on it. But I really don=
't recommend automating things that<br></div><div>could lose data.<br></div=
><div><br></div><div>Brian<br></div><div><br></div></body></html>
--=-IYIVgAHG8uq2uwZw5b6N--