Bug 9824

Summary: WIC images fail to boot
Product: [Build System, Metadata & Runtime] BSPs Reporter: Alexandru Roman <alexandru.costinx.roman>
Component: bsps-meta-yoctoAssignee: Ed Bartosh <eduard.bartosh>
Status: RESOLVED NOTABUG QA Contact:
Severity: normal    
Priority: Undecided CC: eduard.bartosh
Version: 2.0   
Target Milestone: ---   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: Regression (Used to work)
Verified: Documentation change: No (bug/feature does not impact docs)

Description Alexandru Roman 2016-06-24 12:58:47 UTC
Appears on 2.2_M1.rc2 : 6f0c5537e02c59e1c8f3b08f598dc049ff8ee098
Image: core-image-sato -  WIC image
MACHINE: genericx86, genericx86-64
HW: MMAX32bit, MMAX64bit, NUC

After the nightly-wic step from our AB finished I downloaded the images from:
http://10.237.112.85/wic-images/genericx86-64/mkefidisk/core-image-sato/build/
and tried to boot them on the hardware mentioned above.

From the uefi I tried to access bootx.efi and wait for the image to boot but instead of booting the grub interface appears.

Then I tried to create the image with the command: 'wic create mkefidisk -e core-image-sato' and I got the same result.
Comment 1 Ed Bartosh 2016-06-28 09:22:51 UTC
I'll try to look at this. Do you remember when they're working last time?
Comment 2 Ed Bartosh 2016-06-28 10:36:43 UTC
I was able to boot core-image-minimal on my Minnowboard MAX just fine. Will try core-image-sato now.
Comment 3 Ed Bartosh 2016-06-28 11:06:55 UTC
btw, you saw grub menu because mkefidisk.wks sets grub as a bootloader:
part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024

I think it's always been like that.
Comment 4 Ed Bartosh 2016-06-28 11:29:43 UTC
I've just built core-image-sato and booted it to the shell. Here is what I see on the console:

Poky (Yocto Project Reference Distro) 2.1+snapshot-20160628 intel-corei7-64 /de0

intel-corei7-64 login: root
root@intel-corei7-64:~# rpm -qa | wc -l
1676
root@intel-corei7-64:~# 

I can't see graphical UI though as I'm using serial console. However, the fact that image is booting to the shell is enough to prove that wic creates bootable image.
Comment 5 Ed Bartosh 2016-06-28 12:59:11 UTC
Built core-image-sato from revision 6f0c5537e02c59e1c8f3b08f598dc049ff8ee098
It booted to the shell.

I'm using intel-corei7-64 machine. 
I'm going to build the image for genericx86-64 and try again.
Comment 6 Ed Bartosh 2016-06-28 13:40:58 UTC
Built and booted core-image-minimal genericx86-64
building core-image-sato
Comment 7 Ed Bartosh 2016-06-28 14:00:10 UTC
built and successfully booted core-image-sato genericx86-64:
Poky (Yocto Project Reference Distro) 2.1+snapshot-20160628 genericx86-64 /dev/ttyS0

genericx86-64 login: root
root@genericx86-64:~#
Comment 8 Ed Bartosh 2016-06-28 14:39:33 UTC
This image http://10.237.112.85/wic-images/genericx86-64/mkefidisk/core-image-sato/build/mkefidisk-core-image-sato-genericx86-64.direct is definitely broken. An attempt to mount root partition causes mount to fail with this error:
$ sudo mount /dev/sdb2 /mnt/
mount: wrong fs type, bad option, bad superblock on /dev/sdb2,
       missing codepage or helper program, or other error

and this line in dmesg:
[686485.983900] EXT4-fs (sdb2): bad geometry: block count 166400 exceeds size of device (118019 blocks)
Comment 9 Ed Bartosh 2016-06-28 15:07:09 UTC
The amount of packages in both images(broken AB image and the image i've built) are the same, but the size of rootfs partition image for AB image is much bigger (650Mb vs 462Mb)

Could someone point me out to the ab code that builds wic image?
Comment 10 Ed Bartosh 2016-06-28 15:45:24 UTC
Can we try to build mkefidisk image on official ab?
This configuration change should be enough to do it I hope:
diff --git a/buildset-config.controller/nightly-wic.conf b/buildset-config.controller/nightly-wic.conf
index 680ac16..7d2ae88 100644
--- a/buildset-config.controller/nightly-wic.conf
+++ b/buildset-config.controller/nightly-wic.conf
@@ -18,7 +18,8 @@ steps: [{'SetDest':{}},
         {'BuildImages':{'images':'syslinux syslinux-native parted-native gptfdisk-native dosfstools-native mtools-native'}},
         {'BuildImages':{'images':'core-image-sato'}},
         {'CreateWicImages':{'wic_img_type':'directdisk', 'target_img':'core-image-sato'}},
-        {'CreateWicImages':{'wic_img_type':'directdisk-gpt', 'target_img':'core-image-sato'}}]
+        {'CreateWicImages':{'wic_img_type':'directdisk-gpt', 'target_img':'core-image-sato'}},
+        {'CreateWicImages':{'wic_img_type':'mkefidisk', 'target_img':'core-image-sato'}}]
Comment 11 Ed Bartosh 2016-06-29 11:37:58 UTC
I've checked 4 images produced by one of official AB workers and they're good. I'm still not able to reproduce the issue in my environment.
Comment 12 Ed Bartosh 2016-06-29 13:20:02 UTC
taking this bug as I'm working on it anyway
Comment 13 Ed Bartosh 2016-06-29 14:53:17 UTC
We worked with Alexandru on this. He created a core-image-sato mkefidisk image and I was able to boot it without changing anything. So, the issue is not reproducible anymore on his machine.
Comment 14 Ed Bartosh 2016-06-29 15:51:02 UTC
I think I found the real reason for this bug. The .wks file was modified pointing to sdb device. The result of this change is 'root=/dev/sdb2' was added to the kernel command line in bootloader configuration.

I was able to boot the image from http://10.237.112.85/wic-images/genericx86-64/mkefidisk/core-image-sato/build/ after I changed /dev/sdb2 to /dev/sda2.