<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>11790</bug_id>
          
          <creation_ts>2017-07-14 12:56:45 +0000</creation_ts>
          <short_desc>WIC creates wrong partition number</short_desc>
          <delta_ts>2018-02-28 12:32:02 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>Scripts and Tools</component>
          <version>2.4</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.4 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Racemouse">fink</reporter>
          <assigned_to name="Ed Bartosh">eduard.bartosh</assigned_to>
          <cc>kai.ruhnau</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>75032</commentid>
    <comment_count>0</comment_count>
    <who name="Racemouse">fink</who>
    <bug_when>2017-07-14 12:56:45 +0000</bug_when>
    <thetext>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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75036</commentid>
    <comment_count>1</comment_count>
    <who name="Ed Bartosh">eduard.bartosh</who>
    <bug_when>2017-07-14 14:43:44 +0000</bug_when>
    <thetext>Looks like a bug to me. Can you try if it&apos;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 == &apos;msdos&apos; and realnum &gt; 3:
+                if self.ptable_format == &apos;msdos&apos; and realnum &gt; 3 and len(partitions) &gt; 4:
                     part.realnum = realnum + 1
                     continue
                 part.realnum = realnum


BTW, you&apos;ve specified Yocto version 2.3.2. this version doesn&apos;t exist yet, I believe. Can you tell which Yocto version do you use?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75048</commentid>
    <comment_count>2</comment_count>
    <who name="Racemouse">fink</who>
    <bug_when>2017-07-14 19:24:10 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Looks like a bug to me. Can you try if it&apos;s fixed by this patch?
&gt; 
&gt; diff --git a/scripts/lib/wic/plugins/imager/direct.py
&gt; b/scripts/lib/wic/plugins/imager/direct.py
&gt; index f2e6127..31d07ba 100644
&gt; --- a/scripts/lib/wic/plugins/imager/direct.py
&gt; +++ b/scripts/lib/wic/plugins/imager/direct.py
&gt; @@ -312,7 +312,7 @@ class PartitionedImage():
&gt;                  part.realnum = 0
&gt;              else:
&gt;                  realnum += 1
&gt; -                if self.ptable_format == &apos;msdos&apos; and realnum &gt; 3:
&gt; +                if self.ptable_format == &apos;msdos&apos; and realnum &gt; 3 and
&gt; len(partitions) &gt; 4:
&gt;                      part.realnum = realnum + 1
&gt;                      continue
&gt;                  part.realnum = realnum
&gt; 
&gt; 
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 :-)


&gt; BTW, you&apos;ve specified Yocto version 2.3.2. this version doesn&apos;t exist yet, I
&gt; believe. Can you tell which Yocto version do you use?
I-m using &quot;YP Core - Pyro 2.3&quot;, 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75054</commentid>
    <comment_count>3</comment_count>
    <who name="Ed Bartosh">eduard.bartosh</who>
    <bug_when>2017-07-17 07:53:12 +0000</bug_when>
    <thetext>Please review fixes for master, pyro and morty:
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/139683.html
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/139684.html
http://lists.openembedded.org/pipermail/openembedded-core/2017-July/139685.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75240</commentid>
    <comment_count>4</comment_count>
    <who name="Ed Bartosh">eduard.bartosh</who>
    <bug_when>2017-07-24 07:33:45 +0000</bug_when>
    <thetext>The fix has been merged into poky master. Commit id 8fb8a21b7d4f1fb69f0407f03fd5907d861f7d42</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79626</commentid>
    <comment_count>5</comment_count>
    <who name="Kai Ruhnau">kai.ruhnau</who>
    <bug_when>2018-02-28 12:32:02 +0000</bug_when>
    <thetext>I have just tested this patch on my ARM platform and it doesn&apos;t work as intended:
The `len(partitions) &gt; 4` also counts those with the --no-table flag so my u-boot &quot;partition&quot; 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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>