summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/wic/utils/partitionedfs.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index fb95cc790e..9df93dca2f 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -156,6 +156,13 @@ class Image:
156 # Skip one sector required for the partitioning scheme overhead 156 # Skip one sector required for the partitioning scheme overhead
157 d['offset'] += overhead 157 d['offset'] += overhead
158 158
159 elif d['numpart'] > 3:
160 # Reserve a sector for EBR for every logical partition
161 # before alignment is performed.
162 if ptable_format == "msdos":
163 d['offset'] += 1
164
165
159 if p['align']: 166 if p['align']:
160 # If not first partition and we do have alignment set we need 167 # If not first partition and we do have alignment set we need
161 # to align the partition. 168 # to align the partition.
@@ -185,14 +192,6 @@ class Image:
185 p['num'] = d['numpart'] 192 p['num'] = d['numpart']
186 193
187 if d['ptable_format'] == "msdos": 194 if d['ptable_format'] == "msdos":
188 if d['numpart'] > 2:
189 # Every logical partition requires an additional sector for
190 # the EBR, so steal the last sector from the end of each
191 # partition starting from the 3rd one for the EBR. This
192 # will make sure the logical partitions are aligned
193 # correctly.
194 p['size'] -= 1
195
196 if d['numpart'] > 3: 195 if d['numpart'] > 3:
197 p['type'] = 'logical' 196 p['type'] = 'logical'
198 p['num'] = d['numpart'] + 1 197 p['num'] = d['numpart'] + 1
@@ -259,13 +258,20 @@ class Image:
259 for p in self.partitions: 258 for p in self.partitions:
260 d = self.disks[p['disk_name']] 259 d = self.disks[p['disk_name']]
261 if d['ptable_format'] == "msdos" and p['num'] == 5: 260 if d['ptable_format'] == "msdos" and p['num'] == 5:
262 # The last sector of the 3rd partition was reserved for the EBR 261 # Create an extended partition (note: extended
263 # of the first _logical_ partition. This is why the extended 262 # partition is described in MBR and contains all
264 # partition should start one sector before the first logical 263 # logical partitions). The logical partitions save a
265 # partition. 264 # sector for an EBR just before the start of a
265 # partition. The extended partition must start one
266 # sector before the start of the first logical
267 # partition. This way the first EBR is inside of the
268 # extended partition. Since the extended partitions
269 # starts a sector before the first logical partition,
270 # add a sector at the back, so that there is enough
271 # room for all logical partitions.
266 self.__create_partition(d['disk'].device, "extended", 272 self.__create_partition(d['disk'].device, "extended",
267 None, p['start'] - 1, 273 None, p['start'] - 1,
268 d['offset'] - p['start']) 274 d['offset'] - p['start'] + 1)
269 275
270 if p['fstype'] == "swap": 276 if p['fstype'] == "swap":
271 parted_fs_type = "linux-swap" 277 parted_fs_type = "linux-swap"
@@ -338,14 +344,6 @@ class Image:
338 344
339 for p in self.partitions: 345 for p in self.partitions:
340 d = self.disks[p['disk_name']] 346 d = self.disks[p['disk_name']]
341 if d['ptable_format'] == "msdos" and p['num'] == 5:
342 # The last sector of the 3rd partition was reserved for the EBR
343 # of the first _logical_ partition. This is why the extended
344 # partition should start one sector before the first logical
345 # partition.
346 self.__write_partition(p['num'], p['source_file'],
347 p['start'] - 1,
348 d['offset'] - p['start'])
349 347
350 self.__write_partition(p['num'], p['source_file'], 348 self.__write_partition(p['num'], p['source_file'],
351 p['start'], p['size']) 349 p['start'], p['size'])