I have created wic image having extended partitions with below *.wks file content. wks file: part /mnt/boot --ondisk mmcblk0 --label edgeos-boot --active --fixed-size=100M --fstype=vfat --align 4096 --source bootimg-partition part /mnt/krn1 --ondisk mmcblk0 --label edgeos-krn1 --fstype=vfat --align 4096 --fixed-size=64M --source rawcopy --sourceparams="file=kernel.vfat" part /mnt/krn2 --ondisk mmcblk0 --label edgeos-krn2 --fstype=vfat --align 4096 --fixed-size=64M part /mnt/rootfs-container --ondisk mmcblk0 --label edgeos-cntnr --fstype=ext3 --align 4096 --fixed-size=512M --source rootfs --rootfs-dir=rootfs-image-dir part /mnt/conf --ondisk mmcblk0 --label edgeos-conf --fstype=ext3 --align 4096 --fixed-size=16M part /mnt/data --ondisk mmcblk0 --label edgeos-data --fstype=ext3 --align 4096 --fixed-size=512M fdisk output: # fdisk -l /dev/mmcblk0 Disk /dev/mmcblk0: 14.9 GiB, 15987638272 bytes, 31225856 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x6f201fb9 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 * 8192 212991 204800 100M c W95 FAT32 (LBA) /dev/mmcblk0p2 212992 344063 131072 64M c W95 FAT32 (LBA) /dev/mmcblk0p3 344064 475135 131072 64M c W95 FAT32 (LBA) /dev/mmcblk0p4 483327 2629631 2146305 1G f W95 Ext'd (LBA) /dev/mmcblk0p5 483328 1531903 1048576 512M 83 Linux /dev/mmcblk0p6 1540096 1572863 32768 16M 83 Linux /dev/mmcblk0p7 1581056 2629631 1048576 512M 83 Linux When performing resizing of extended partition using 'parted' tool after booting wic image (or at boot time via systemd service file), it is giving error "Unable to satisfy all constraints on the partition." command: "parted /dev/mmcblk0 resizepart 4 -1s" This error "Unable to satisfy all constraints on the partition." is coming due to invalid created msdos partition table via wic. There are the basic partition rules for msdos partition table and need to be followed while creating wic image for extended partition. Refer link https://gparted.org/h2-fix-msdos-pt.php. According to rule, atleast 2 unallocated sectors are required in front of a logical partition. This space is required for the Extended Boot Record (EBR). But the generated wic image having only one sector gap between extended partition (start: 483327) and 1st logical partition (start: 483328). There is bug in imager file direct.py. (https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/imager/direct.py?h=master) at line 406, 449 and 514. line 403-406: # Reserve a sector for EBR for every logical partition # before alignment is performed. if part.type == 'logical': self.offset += 1 line 449: self.extended_size_sec += part.size_sec + 1 line 514-516: self._create_partition(self.path, "extended", None, part.start - 1, self.extended_size_sec) In above mentioned line, it is keeping 1 sector gap between extended partition and 1st logical partition instead of keeping minimum 2 sector gap. Please look into this issue. Thanks and Regards Preeti Sachan
Is this simply a case of changing the += 1 to +=2 ? Could someone send a patch please if so?
Created attachment 4594 [details] patch file applicable to poky, sumo and thud branch
I have tested on poky sumo and thud branch and having patch for same. This patch file is applicable to poky sumo and thud branch. $ cat fix-parted-unable-to-satisfy-all-constraints.patch diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 1fa6b91..57f6f4a 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py @@ -416,7 +416,7 @@ class PartitionedImage(): # Reserve a sector for EBR for every logical partition # before alignment is performed. if self.ptable_format == "msdos": - self.offset += 1 + self.offset += 2 if part.align: # If not first partition and we do have alignment set we need @@ -517,8 +517,8 @@ class PartitionedImage(): # add a sector at the back, so that there is enough # room for all logical partitions. self._create_partition(self.path, "extended", - None, part.start - 1, - self.offset - part.start + 1) + None, part.start - 2, + self.offset - part.start + 2) if part.fstype == "swap": parted_fs_type = "linux-swap"
this should work for master branch https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=590555e3b8ccbd94b628aa6778adea7f4538d966