summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/wic/ksparser.py2
-rw-r--r--scripts/lib/wic/partition.py1
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py37
3 files changed, 29 insertions, 11 deletions
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 3e670033ba..6a643ba3af 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -151,6 +151,8 @@ class KickStart():
151 part.add_argument('--part-name') 151 part.add_argument('--part-name')
152 part.add_argument('--part-type') 152 part.add_argument('--part-type')
153 part.add_argument('--rootfs-dir') 153 part.add_argument('--rootfs-dir')
154 part.add_argument('--type', default='primary',
155 choices = ('primary', 'logical'))
154 156
155 # --size and --fixed-size cannot be specified together; options 157 # --size and --fixed-size cannot be specified together; options
156 # ----extra-space and --overhead-factor should also raise a parser 158 # ----extra-space and --overhead-factor should also raise a parser
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 01466b258d..f427c8101b 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -50,6 +50,7 @@ class Partition():
50 self.use_uuid = args.use_uuid 50 self.use_uuid = args.use_uuid
51 self.uuid = args.uuid 51 self.uuid = args.uuid
52 self.fsuuid = args.fsuuid 52 self.fsuuid = args.fsuuid
53 self.type = args.type
53 54
54 self.lineno = lineno 55 self.lineno = lineno
55 self.source_file = "" 56 self.source_file = ""
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 91fc5e70f6..3ce6ad55b8 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -300,6 +300,10 @@ class PartitionedImage():
300 self.path = path # Path to the image file 300 self.path = path # Path to the image file
301 self.numpart = 0 # Number of allocated partitions 301 self.numpart = 0 # Number of allocated partitions
302 self.realpart = 0 # Number of partitions in the partition table 302 self.realpart = 0 # Number of partitions in the partition table
303 self.primary_part_num = 0 # Number of primary partitions (msdos)
304 self.extendedpart = 0 # Create extended partition before this logical partition (msdos)
305 self.extended_size_sec = 0 # Size of exteded partition (msdos)
306 self.logical_part_cnt = 0 # Number of total logical paritions (msdos)
303 self.offset = 0 # Offset of next partition (in sectors) 307 self.offset = 0 # Offset of next partition (in sectors)
304 self.min_size = 0 # Minimum required disk size to fit 308 self.min_size = 0 # Minimum required disk size to fit
305 # all partitions (in bytes) 309 # all partitions (in bytes)
@@ -391,12 +395,16 @@ class PartitionedImage():
391 # Skip one sector required for the partitioning scheme overhead 395 # Skip one sector required for the partitioning scheme overhead
392 self.offset += overhead 396 self.offset += overhead
393 397
394 if self.realpart > 3 and num_real_partitions > 4: 398 if self.ptable_format == "msdos":
399 if self.primary_part_num > 3 or \
400 (self.extendedpart == 0 and self.primary_part_num >= 3 and num_real_partitions > 4):
401 part.type = 'logical'
395 # Reserve a sector for EBR for every logical partition 402 # Reserve a sector for EBR for every logical partition
396 # before alignment is performed. 403 # before alignment is performed.
397 if self.ptable_format == "msdos": 404 if part.type == 'logical':
398 self.offset += 1 405 self.offset += 1
399 406
407 align_sectors = 0
400 if part.align: 408 if part.align:
401 # If not first partition and we do have alignment set we need 409 # If not first partition and we do have alignment set we need
402 # to align the partition. 410 # to align the partition.
@@ -422,18 +430,25 @@ class PartitionedImage():
422 part.start = self.offset 430 part.start = self.offset
423 self.offset += part.size_sec 431 self.offset += part.size_sec
424 432
425 part.type = 'primary'
426 if not part.no_table: 433 if not part.no_table:
427 part.num = self.realpart 434 part.num = self.realpart
428 else: 435 else:
429 part.num = 0 436 part.num = 0
430 437
431 if self.ptable_format == "msdos": 438 if self.ptable_format == "msdos" and not part.no_table:
432 # only count the partitions that are in partition table 439 if part.type == 'logical':
433 if num_real_partitions > 4: 440 self.logical_part_cnt += 1
434 if self.realpart > 3: 441 part.num = self.logical_part_cnt + 4
435 part.type = 'logical' 442 if self.extendedpart == 0:
436 part.num = self.realpart + 1 443 # Create extended partition as a primary partition
444 self.primary_part_num += 1
445 self.extendedpart = part.num
446 else:
447 self.extended_size_sec += align_sectors
448 self.extended_size_sec += part.size_sec + 1
449 else:
450 self.primary_part_num += 1
451 part.num = self.primary_part_num
437 452
438 logger.debug("Assigned %s to %s%d, sectors range %d-%d size %d " 453 logger.debug("Assigned %s to %s%d, sectors range %d-%d size %d "
439 "sectors (%d bytes).", part.mountpoint, part.disk, 454 "sectors (%d bytes).", part.mountpoint, part.disk,
@@ -483,7 +498,7 @@ class PartitionedImage():
483 if part.num == 0: 498 if part.num == 0:
484 continue 499 continue
485 500
486 if self.ptable_format == "msdos" and part.num == 5: 501 if self.ptable_format == "msdos" and part.num == self.extendedpart:
487 # Create an extended partition (note: extended 502 # Create an extended partition (note: extended
488 # partition is described in MBR and contains all 503 # partition is described in MBR and contains all
489 # logical partitions). The logical partitions save a 504 # logical partitions). The logical partitions save a
@@ -497,7 +512,7 @@ class PartitionedImage():
497 # room for all logical partitions. 512 # room for all logical partitions.
498 self._create_partition(self.path, "extended", 513 self._create_partition(self.path, "extended",
499 None, part.start - 1, 514 None, part.start - 1,
500 self.offset - part.start + 1) 515 self.extended_size_sec)
501 516
502 if part.fstype == "swap": 517 if part.fstype == "swap":
503 parted_fs_type = "linux-swap" 518 parted_fs_type = "linux-swap"