diff options
Diffstat (limited to 'scripts/lib/wic/plugins/imager/direct.py')
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 37 |
1 files changed, 26 insertions, 11 deletions
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" |
