From 233b631ece5ee14d057932c146327065064b5196 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sun, 8 Feb 2015 23:52:00 +0100 Subject: wic: allow creation of partitions not in table For some architectures it is necessary to reserve space on disk without it being present in the partition table. For example, u-boot on i.mx is placed at an offset of 1kB on the sdcard. While it would be possible to create a partition at that offset and place u-boot there, it would then be necessary to update the default u-boot environment to use partition 2 on the mmc instead of partition 1. Signed-off-by: Alexandre Belloni Signed-off-by: Ross Burton --- scripts/lib/wic/utils/partitionedfs.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'scripts/lib/wic/utils/partitionedfs.py') diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py index c72bb29b02..87d2929f6c 100644 --- a/scripts/lib/wic/utils/partitionedfs.py +++ b/scripts/lib/wic/utils/partitionedfs.py @@ -61,6 +61,7 @@ class Image: self.disks[disk_name] = \ { 'disk': None, # Disk object 'numpart': 0, # Number of allocate partitions + 'realpart': 0, # Number of partitions in the partition table 'partitions': [], # Indexes to self.partitions 'offset': 0, # Offset of next partition (in sectors) # Minimum required disk size to fit all partitions (in bytes) @@ -85,7 +86,7 @@ class Image: self.__add_disk(part['disk_name']) def add_partition(self, size, disk_name, mountpoint, source_file = None, fstype = None, - label=None, fsopts = None, boot = False, align = None, + label=None, fsopts = None, boot = False, align = None, no_table=False, part_type = None): """ Add the next partition. Prtitions have to be added in the first-to-last order. """ @@ -109,6 +110,7 @@ class Image: 'num': None, # Partition number 'boot': boot, # Bootable flag 'align': align, # Partition alignment + 'no_table' : no_table, # Partition does not appear in partition table 'part_type' : part_type } # Partition type self.__add_partition(part) @@ -147,6 +149,8 @@ class Image: # Get the disk where the partition is located d = self.disks[p['disk_name']] d['numpart'] += 1 + if not p['no_table']: + d['realpart'] += 1 d['ptable_format'] = ptable_format if d['numpart'] == 1: @@ -156,7 +160,7 @@ class Image: # Skip one sector required for the partitioning scheme overhead d['offset'] += overhead - elif d['numpart'] > 3: + if d['realpart'] > 3: # Reserve a sector for EBR for every logical partition # before alignment is performed. if ptable_format == "msdos": @@ -189,12 +193,15 @@ class Image: d['offset'] += p['size'] p['type'] = 'primary' - p['num'] = d['numpart'] + if not p['no_table']: + p['num'] = d['realpart'] + else: + p['num'] = 0 if d['ptable_format'] == "msdos": - if d['numpart'] > 3: + if d['realpart'] > 3: p['type'] = 'logical' - p['num'] = d['numpart'] + 1 + p['num'] = d['realpart'] + 1 d['partitions'].append(n) msger.debug("Assigned %s to %s%d, sectors range %d-%d size %d " @@ -256,6 +263,9 @@ class Image: msger.debug("Creating partitions") for p in self.partitions: + if p['num'] == 0: + continue + d = self.disks[p['disk_name']] if d['ptable_format'] == "msdos" and p['num'] == 5: # Create an extended partition (note: extended -- cgit 1.2.3-korg