GNU bug report logs -
#24215
command=`rm`: how to script responses?
Previous Next
To reply to this bug, email your comments to 24215 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-parted <at> gnu.org
:
bug#24215
; Package
parted
.
(Fri, 12 Aug 2016 23:22:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
bug-parted <at> gnu.org, Tom Roche <Tom_Roche <at> pobox.com>
:
New bug report received and forwarded. Copy sent to
bug-parted <at> gnu.org
.
(Fri, 12 Aug 2016 23:22:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[footnotes after .sig]
I am learning how to script `parted`, successfully insofar as the following scriptlet WFM[1]:
ORIG_DRIVE_LABEL='D078BBB478BB97A4'
ORIG_DRIVE_MOUNTPATH="/media/$(whoami)/${ORIG_DRIVE_LABEL}"
DRIVE_DEV='/dev/sdb'
date
du -hs "${ORIG_DRIVE_MOUNTPATH}"
df -h "${ORIG_DRIVE_MOUNTPATH}"
sudo parted ${DRIVE_DEV} --script -- print
# note following fails without specified ${DRIVE_DEV} ?!?
sudo parted ${DRIVE_DEV} --script -- print devices
However I am unable to avoid--or, better yet, to script so as to satisfy--prompts from
$ sudo parted ${DRIVE_DEV} --script -- rm 1
> Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?
This seems wrong to me, in 2 ways:
1. The manual[2] says quite clearly
> ‘-s’
> ‘--script’
> never prompt the user
So ISTM[3] either something is wrong with the code or with the manual. Am I missing something?
2. I can't find a way to script a response to the prompt. I have tried various permutations of
echo 'yes' | sudo parted ${DRIVE_DEV} --script -- rm 1
yes | sudo parted ${DRIVE_DEV} --script -- rm 1
yes Y | sudo parted ${DRIVE_DEV} --script -- rm 1
sudo sh -c "yes yes | sudo parted ${DRIVE_DEV} --script -- rm 1"
So ISTM one of 2 cases applies here:
1. `rm` is (deliberately) unscriptable. If so, ISTM this should be duly noted in the manual, e.g. here[4]
2. `rm` is scriptable, or the user needs to make some configuration change if s/he wants to script `rm`. If so, how? and again, the necessary instructions should also be provided in the manual (same place[4]), since it's obviously non-trivial.
In case it matters, I'm running Debian 8 with up-to-date (for that distro) `bash` and `parted`, particularly
$ date; sudo parted --version | head -1
> Fri Aug 12 15:42:45 MST 2016
> parted (GNU parted) 3.2
TIA, Tom Roche <Tom_Roche <at> pobox.com>
[1]: https://en.wiktionary.org/wiki/WFM
[2]: https://www.gnu.org/software/parted/manual/parted.html#Invoking-Parted
[3]: https://en.wiktionary.org/wiki/ISTM
[4]: https://www.gnu.org/software/parted/manual/parted.html#rm
Information forwarded
to
bug-parted <at> gnu.org
:
bug#24215
; Package
parted
.
(Wed, 31 Aug 2016 21:08:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 24215 <at> debbugs.gnu.org (full text, mbox):
On 8/12/2016 7:21 PM, Tom Roche wrote:
> $ sudo parted ${DRIVE_DEV} --script -- rm 1
>> Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?
>
> This seems wrong to me, in 2 ways:
>
> 1. The manual[2] says quite clearly
>> ‘-s’
>> ‘--script’
>> never prompt the user
That is correct; it does not prompt the user. You do still get the
warning that something is wrong though, and then parted exits with an error.
> So ISTM[3] either something is wrong with the code or with the manual. Am I missing something?
>
> 2. I can't find a way to script a response to the prompt. I have tried various permutations of
>
> echo 'yes' | sudo parted ${DRIVE_DEV} --script -- rm 1
> yes | sudo parted ${DRIVE_DEV} --script -- rm 1
> yes Y | sudo parted ${DRIVE_DEV} --script -- rm 1
> sudo sh -c "yes yes | sudo parted ${DRIVE_DEV} --script -- rm 1"
Leave off the --script so that it prompts for a response, and then you
can give it the yes response on the command line, probably followed by
the ignore response to the error that is going to follow.
I've know about this class of problem for some time now but can't come
up with a satisfactory way to deal with it. Something along the lines
of --yes-i-know-it-is-in-use to automatically answer that particular
response with a yes, if and only if it comes up would be ideal, but due
to the way the libparted api is designed, implementing such a thing is
difficult.
Information forwarded
to
bug-parted <at> gnu.org
:
bug#24215
; Package
parted
.
(Mon, 03 Apr 2017 15:29:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 24215 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 24215 + patch
tags 22167 + patch
Hello,
The attached patches should fix these issues where interactive prompts
are shown when one tries to perform 'rm' or 'resizepart' operations with
mounted partitions. This avoid workarounds[1].
The proposal is to not ask for confirmation during 'rm' and 'resizepart'
operations when run in script mode. The answer is assumed to be 'yes'
in both cases.
Links:
1) https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203
--
Sunil
[0001-parted-Don-t-warn-partition-busy-in-script-mode.patch (text/x-patch, attachment)]
[0002-tests-t1701-rescue-fs.sh-Wait-for-device-to-appear.patch (text/x-patch, attachment)]
[0003-tests-t1101-busy-partition.sh-Update-tests-for-scrip.patch (text/x-patch, attachment)]
[0004-tests-t6002-Fix-expectation-of-rm-on-mounted-partiti.patch (text/x-patch, attachment)]
[0005-tests-t9041-Fix-expectation-of-rm-on-mounted-partiti.patch (text/x-patch, attachment)]
[0006-tests-t1102-Fix-expectation-of-rm-on-mounted-partiti.patch (text/x-patch, attachment)]
[signature.asc (application/pgp-signature, attachment)]
Added tag(s) patch.
Request was from
Sunil Mohan Adapa <sunil <at> medhas.org>
to
control <at> debbugs.gnu.org
.
(Mon, 03 Apr 2017 15:29:02 GMT)
Full text and
rfc822 format available.
Merged 22167 24215.
Request was from
Phil Susi <psusi <at> ubuntu.com>
to
control <at> debbugs.gnu.org
.
(Wed, 19 Apr 2017 18:10:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-parted <at> gnu.org
:
bug#24215
; Package
parted
.
(Wed, 01 Jan 2020 01:22:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 24215 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello,
Any updates on this bug or comments on the patches? I believe the fix is
straight forward and correct.
Thanks,
--
Sunil
[signature.asc (application/pgp-signature, attachment)]
Information forwarded
to
bug-parted <at> gnu.org
:
bug#24215
; Package
parted
.
(Mon, 06 Jan 2020 22:41:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 24215 <at> debbugs.gnu.org (full text, mbox):
On Tue, Dec 31, 2019 at 05:21:11PM -0800, Sunil Mohan Adapa wrote:
> Hello,
>
> Any updates on this bug or comments on the patches? I believe the fix is
> straight forward and correct.
Do you mean these?
https://lists.gnu.org/archive/html/bug-parted/2017-04/msg00000.html
I really cannot think of a good reason to remove or resize a mounted
partition. Why not unmount it first and avoid the issue completely?
--
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart
Information forwarded
to
bug-parted <at> gnu.org
:
bug#24215
; Package
parted
.
(Tue, 07 Jan 2020 23:06:02 GMT)
Full text and
rfc822 format available.
Message #24 received at 24215 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 06/01/20 2:40 pm, Brian C. Lane wrote:
> On Tue, Dec 31, 2019 at 05:21:11PM -0800, Sunil Mohan Adapa wrote:
>> Hello,
>>
>> Any updates on this bug or comments on the patches? I believe the fix is
>> straight forward and correct.
>
> Do you mean these?
>
> https://lists.gnu.org/archive/html/bug-parted/2017-04/msg00000.html
Indeed, it seems likes the original implementation simply missed out on
these checks judging by how other cases were handled and how --script
option is documented.
Some of the updates to test cases included in these patches may have
been handled with recent changes.
>
> I really cannot think of a good reason to remove or resize a mounted
> partition. Why not unmount it first and avoid the issue completely?
>
This is a very common scenario when running on single board computers.
Disk images from the OS vendors are downloaded and written to SD cards
(or eMMC) instead of a typical installation wizard process. These images
are of a fixed size, say 4GiB, and when the OS boots for the first time,
the last partition is expanded to take up the full size of the disk
(typically more than 32GB). After this the users get to use the full
storage capacity of the disk.
This operation is done by many OS images meant for Raspberry Pi. In my
case it is FreedomBox[1], a pure blend of Debian for home servers
running on cheap hardware. It is likely that all of these users are
avoiding parted for this operation or working around the problem.
Since online expansion is supported by many file systems including ext4
and btrfs, when using the underlying tools, I don't see a reason for
parted to refuse to do this. Also, since the operation is currently
allowed to be performed manually, scripts should have ability to do the
same, given that they know that it is safe.
Links:
1) https://freedombox.org
--
Sunil
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 5 years and 161 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.