如何在脚本模式下使用parted?

如何在脚本模式下使用parted?

我正在尝试对以前在某些情况下工作的脚本进行故障排除。如果我替换脚本变量,我要运行的是:

parted -s /dev/sdb unit MiB resizepart 1 307199

这会产生:

Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?

但在此之后,操作系统会出现没有任何更改的提示,以向parted提供答案。更重要的是,如果我运行它时没有-s

parted /dev/sdb unit MiB resizepart 1 307199

我得到这个:

Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?
Yes/No? Yes
End?  [102399MiB]?

我不知道为什么我被问到 End,如果上面的命令行已经提供了,你能解释一下吗?

以下是更多诊断命令:

# parted -v
parted (GNU parted) 3.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by <http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.

# parted /dev/sdb unit MiB print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 307200MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start    End        Size       File system  Name     Flags
 1      1.00MiB  102399MiB  102398MiB  ext4         primary

最终目标是能够在脚本中继续使用它,即在运行时无需人工输入。

相关内容