[oe-commits] [openembedded-core] 14/43: wic/engine: use up all free space when expanding partitions

git at git.openembedded.org git at git.openembedded.org
Tue Jul 17 08:14:10 UTC 2018


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 03401b4346c2865cc4ee7f668ba332b4bfe2c510
Author: Anuj Mittal <anuj.mittal at intel.com>
AuthorDate: Thu Jul 12 10:05:25 2018 +0800

    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.
    
    Signed-off-by: Anuj Mittal <anuj.mittal at intel.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 scripts/lib/wic/engine.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py
index fe036f6..f0c5ff0 100644
--- a/scripts/lib/wic/engine.py
+++ b/scripts/lib/wic/engine.py
@@ -416,6 +416,7 @@ class Disk:
 
             # calculate expanded partitions sizes
             sizes = {}
+            num_auto_resize = 0
             for num, part in enumerate(parts['partitiontable']['partitions'], 1):
                 if num in expand:
                     if expand[num] != 0: # don't resize partition if size is set to 0
@@ -425,10 +426,11 @@ class Disk:
                         sizes[num] = sectors
                 elif part['type'] != 'f':
                     sizes[num] = -1
+                    num_auto_resize += 1
 
             for num, part in enumerate(parts['partitiontable']['partitions'], 1):
                 if sizes.get(num) == -1:
-                    part['size'] += free // len(sizes)
+                    part['size'] += free // num_auto_resize
 
             # write resized partition table to the target
             write_ptable(parts, target)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list