Bug 11790 - WIC creates wrong partition number
Summary: WIC creates wrong partition number
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: Scripts and Tools (show other bugs)
Version: 2.4
Hardware: x86 Multiple
: Medium normal
Target Milestone: 2.4 M2
Assignee: Ed Bartosh
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2017-07-14 12:56 UTC by Racemouse
Modified: 2018-02-28 12:32 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Racemouse 2017-07-14 12:56:45 UTC
Hi,

I could of course be wrong, but with the wks file here:
part /boot      --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot     --active --align 4096 --size 40
part /          --source rootfs            --ondisk mmcblk0 --fstype=ext4 --label root_a            --align 4096 --size 300
part /rescue                               --ondisk mmcblk0 --fstype=ext4 --label root_b            --align 4096 --size 300
part /usr/local                            --ondisk mmcblk0 --fstype=ext4 --label userdata          --align 4096 --size 100

I get the following entries in /dev:
sh-4.3# ls -l /dev/mmc*
brw-rw----    1 root     disk      179,   0 Jul 11 07:18 /dev/mmcblk0
brw-rw----    1 root     disk      179,   1 Jul 11 07:18 /dev/mmcblk0p1
brw-rw----    1 root     disk      179,   2 Jul 11 07:18 /dev/mmcblk0p2
brw-rw----    1 root     disk      179,   3 Jul 11 07:18 /dev/mmcblk0p3
brw-rw----    1 root     disk      179,   4 Jul 11 07:18 /dev/mmcblk0p4
- which is as expected.

The problem:
My /etc/fstab looks like this:
sh-4.3# cat /etc/fstab
# stock fstab - you probably want to override this with a machine specific one

/dev/root            /                    auto       defaults              1  1
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,gid=5       0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1       /media/card          auto       defaults,sync,noauto  0  0

/dev/mmcblk0p3  /rescue ext4    defaults        0       0
/dev/mmcblk0p5  /usr/local      ext4    defaults        0       0


Please look at the last line: I would expect that /etc/fstab would refer to /dev/mmcblk0p4 instead /dev/mmcblk0p5 for the /usr/local partition !?!?

Is it me doing something wrong or is this a bug?

BR
RaceMouse of Denmark
Comment 1 Ed Bartosh 2017-07-14 14:43:44 UTC
Looks like a bug to me. Can you try if it's fixed by this patch?

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index f2e6127..31d07ba 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -312,7 +312,7 @@ class PartitionedImage():
                 part.realnum = 0
             else:
                 realnum += 1
-                if self.ptable_format == 'msdos' and realnum > 3:
+                if self.ptable_format == 'msdos' and realnum > 3 and len(partitions) > 4:
                     part.realnum = realnum + 1
                     continue
                 part.realnum = realnum


BTW, you've specified Yocto version 2.3.2. this version doesn't exist yet, I believe. Can you tell which Yocto version do you use?
Comment 2 Racemouse 2017-07-14 19:24:10 UTC
(In reply to comment #1)
> Looks like a bug to me. Can you try if it's fixed by this patch?
> 
> diff --git a/scripts/lib/wic/plugins/imager/direct.py
> b/scripts/lib/wic/plugins/imager/direct.py
> index f2e6127..31d07ba 100644
> --- a/scripts/lib/wic/plugins/imager/direct.py
> +++ b/scripts/lib/wic/plugins/imager/direct.py
> @@ -312,7 +312,7 @@ class PartitionedImage():
>                  part.realnum = 0
>              else:
>                  realnum += 1
> -                if self.ptable_format == 'msdos' and realnum > 3:
> +                if self.ptable_format == 'msdos' and realnum > 3 and
> len(partitions) > 4:
>                      part.realnum = realnum + 1
>                      continue
>                  part.realnum = realnum
> 
> 
Hi,
Damn, you are fast !! :-)

Well, it seems to have cured my issue. Now fstab correctly shows mmcblk0p4 on the right spot. From my point of view this can be closed.

Again: Thanks a lot for the prompt reply :-)


> BTW, you've specified Yocto version 2.3.2. this version doesn't exist yet, I
> believe. Can you tell which Yocto version do you use?
I-m using "YP Core - Pyro 2.3", so I assumed 2.3.2 was that. I was obviously wrong, then. Should I change the field into something else? Please advise :-)

BR
RaceMouse of Denmark
Comment 4 Ed Bartosh 2017-07-24 07:33:45 UTC
The fix has been merged into poky master. Commit id 8fb8a21b7d4f1fb69f0407f03fd5907d861f7d42
Comment 5 Kai Ruhnau 2018-02-28 12:32:02 UTC
I have just tested this patch on my ARM platform and it doesn't work as intended:
The `len(partitions) > 4` also counts those with the --no-table flag so my u-boot "partition" is counted as well. Although there are only 4 real partitions in my wks, the fstab still ends up with mmcblk1p5 for the fourth partition.