sfdisk: add option to use maximum partition size
Based on patch from Alex Bligh <alex@alex.org.uk>, Alex wrote: By default, omitting a size parameter means that the maximum sized partition is used. However, this option is not available in conjunction with the -N flag, as under such circumstances the default is the current size of the partition. This patch allows a size to be specified as "+" in which case the maximum sized partition is used, irrespective of the setting of the -N flag. This allows partitions to be programatically resized to their maximum size, by (for instance): echo ",+," | sfdisk -N1 /dev/sda This is non-trivial to do without the patch, as -N makes the default size the existing size. As there is (without this patch) no way of reading the maximum size, the only option is to delete the partition and recreate it. This is undesirable for a number of reasons (e.g. errors between delete and recreate). Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/686124 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
8aa5046647
commit
f30f2bbc81
|
@ -428,7 +428,9 @@ the defaults are: Linux partition, Extended partition, Empty, Empty.
|
|||
.LP
|
||||
But when the \-N option (change a single partition only) is given,
|
||||
the default for each field is its previous value.
|
||||
|
||||
.LP
|
||||
A '+' can be specified instead of a number for size, which means
|
||||
as much as possible. This is useful with the \-N option.
|
||||
.SH EXAMPLE
|
||||
The command
|
||||
.RS
|
||||
|
|
|
@ -2100,6 +2100,8 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive,
|
|||
def = orig ? orig->size : (pno > 4 && pct > 1) ? 0 : ml1;
|
||||
if (fno < 2 || !*(fields[1]))
|
||||
p.size = def;
|
||||
else if (!strcmp(fields[1], "+"))
|
||||
p.size = ml1;
|
||||
else {
|
||||
if (get_ul(fields[1], &ul, def / unitsize(0), 0))
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue