diff options
author | Anuj Mittal <anuj.mittal@intel.com> | 2018-07-12 10:05:25 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-07-30 00:02:52 +0100 |
commit | 2919a89054c00e3d688ad8cb70b200283dd373d2 (patch) | |
tree | a1c01431eac65f25e2f26ee37baaee146740d75f | |
parent | 19c1d1f902d73428fce27945def8e9b681378829 (diff) | |
download | poky-2919a89054c00e3d688ad8cb70b200283dd373d2.tar.gz |
wic/engine: use up all free space when expanding partitions
Currently we just divide up the free space by the number of partitions
that need to be re-sized. This leads to problems when a user has
explicitly specified a subset of partitions (but not all) that need
to re-sized along with the sizes. As an example, for an image with 3
partitions, if we use:
wic write image.wic /dev/sdb --expand 1:10G
This would lead to paritions 2 and 3 each being re-sized to one thirds
of the free space instead of half.
Change the behavior to use up all the free space.
(From OE-Core rev: a88f1b5d88dbc5fb28be24b9787d73b9e0cdf183)
(From OE-Core rev: 167d0c4a9f45e3b8172fc34bf80f3fa587513b0a)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/wic/engine.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index fe036f60e9..f0c5ff0aaf 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -416,6 +416,7 @@ class Disk: | |||
416 | 416 | ||
417 | # calculate expanded partitions sizes | 417 | # calculate expanded partitions sizes |
418 | sizes = {} | 418 | sizes = {} |
419 | num_auto_resize = 0 | ||
419 | for num, part in enumerate(parts['partitiontable']['partitions'], 1): | 420 | for num, part in enumerate(parts['partitiontable']['partitions'], 1): |
420 | if num in expand: | 421 | if num in expand: |
421 | if expand[num] != 0: # don't resize partition if size is set to 0 | 422 | if expand[num] != 0: # don't resize partition if size is set to 0 |
@@ -425,10 +426,11 @@ class Disk: | |||
425 | sizes[num] = sectors | 426 | sizes[num] = sectors |
426 | elif part['type'] != 'f': | 427 | elif part['type'] != 'f': |
427 | sizes[num] = -1 | 428 | sizes[num] = -1 |
429 | num_auto_resize += 1 | ||
428 | 430 | ||
429 | for num, part in enumerate(parts['partitiontable']['partitions'], 1): | 431 | for num, part in enumerate(parts['partitiontable']['partitions'], 1): |
430 | if sizes.get(num) == -1: | 432 | if sizes.get(num) == -1: |
431 | part['size'] += free // len(sizes) | 433 | part['size'] += free // num_auto_resize |
432 | 434 | ||
433 | # write resized partition table to the target | 435 | # write resized partition table to the target |
434 | write_ptable(parts, target) | 436 | write_ptable(parts, target) |