<?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>3155</bug_id>
          
          <creation_ts>2012-09-21 14:27:18 +0000</creation_ts>
          <short_desc>init-live.sh should clean up temporary mounts</short_desc>
          <delta_ts>2013-01-31 07:47:39 +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>core</component>
          <version>1.2.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>1.4 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marc Ferland">marc.ferland</reporter>
          <assigned_to name="Chen Qi">Qi.Chen</assigned_to>
          <cc>liezhi.yang</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>Qi.Chen</cc>
    
    <cc>sgw</cc>
    
    <cc>yi.zhao</cc>
    
    <cc>zhenfeng.zhao</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>25534</commentid>
    <comment_count>0</comment_count>
    <who name="Marc Ferland">marc.ferland</who>
    <bug_when>2012-09-21 14:27:18 +0000</bug_when>
    <thetext>A live system currently has to following mounted filesystems at boot:

&gt;rootfs on / type rootfs (rw)
&gt;proc on /proc type proc (rw,relatime)
&gt;sysfs on /sys type sysfs (rw,relatime)
&gt;/dev/sda on /media/sda type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
&gt;/dev/loop0 on / type ext3 (rw,noatime,nodiratime,barrier=1,data=ordered)
&gt;devtmpfs on /dev type devtmpfs (rw,relatime,size=439740k,nr_inodes=109935,mode=755)
&gt;proc on /proc type proc (rw,relatime)
&gt;tmpfs on /mnt/.psplash type tmpfs (rw,relatime,size=40k)
&gt;sysfs on /sys type sysfs (rw,relatime)
&gt;devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
&gt;tmpfs on /var/volatile type tmpfs (rw,relatime)
&gt;tmpfs on /media/ram type tmpfs (rw,relatime)

I think the recipes-core/initrdscripts/files/init-live.sh script should cleanup the temporary /proc and /sys mounts before it calls switch_root.

Something like:
&gt;# Clean up temporary mounts
&gt;umount /proc
&gt;umount /sys
&gt;
&gt;cd $ROOT_MOUNT
&gt;exec switch_root -c /dev/console $ROOT_MOUNT /sbin/init</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25535</commentid>
    <comment_count>1</comment_count>
    <who name="Marc Ferland">marc.ferland</who>
    <bug_when>2012-09-21 14:29:35 +0000</bug_when>
    <thetext>This would get rid of the duplicate /proc and /sys mounts. The thing I&apos;m not sure is if something else would depend on these mounts...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26050</commentid>
    <comment_count>2</comment_count>
    <who name="Marc Ferland">marc.ferland</who>
    <bug_when>2012-10-02 15:55:36 +0000</bug_when>
    <thetext>After looking at this a little closer, I found out that switch_root already moves the /proc and /sys file systems. It is actually the init-boot.sh script that unconditionally remounts the /proc and /sys file systems even if there already mounted.

Based on this, the solution would be to at least check if these two file systems are already mounted.

BTW, the sysfs.sh script in recipe-core/initscripts also tries to mount /sys and proc... this might be a little redundant with the content of init-boot.sh.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26172</commentid>
    <comment_count>3</comment_count>
    <who name="Marc Ferland">marc.ferland</who>
    <bug_when>2012-10-03 17:57:35 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; After looking at this a little closer, I found out that switch_root already
&gt; moves the /proc and /sys file systems.

Actually busybox&apos;s switch_root does _not_ move /proc and /sys but util-linux&apos;s one does. This means init-live.sh should manually move them. Sorry for the confusion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27244</commentid>
    <comment_count>4</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2012-11-06 03:27:51 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; After looking at this a little closer, I found out that switch_root already
&gt; &gt; moves the /proc and /sys file systems.
&gt; 
&gt; Actually busybox&apos;s switch_root does _not_ move /proc and /sys but
&gt; util-linux&apos;s one does. This means init-live.sh should manually move them.
&gt; Sorry for the confusion.

Hi Marc:
It seems that currently Yocto only supports the &quot;live&quot; feature for core-image-mininal and only for x86 archs. I searched in current project and the result is as following.

~/poky$ grep -R COMPATIBLE_HOST meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb
# on the COMPATIBLE_HOST below, which needs to take precedence
COMPATIBLE_HOST = &quot;(i.86|x86_64).*-linux&quot;
~/poky$ find meta* -name *image*.bb | grep init
meta/recipes-core/images/core-image-minimal-initramfs.bb

Is it right? Or maybe I missed something?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27254</commentid>
    <comment_count>5</comment_count>
    <who name="Marc Ferland">marc.ferland</who>
    <bug_when>2012-11-06 13:52:44 +0000</bug_when>
    <thetext>Hi Chen,

I realize the problem description could have been a little bit clearer! Sorry about that! Let me re-explain the problem.

When I boot a machine that uses the poky/meta/recipes-core/initrdscripts/files/init-live.sh script to perform a live bootup I see duplicated /proc and /sys in mounted filesystems (look at the bug description for an example).

This is caused by a missing &apos;mount -n --move&apos; inside the boot_live_root function (from init-live.sh).

So the problem could be fixed by adding something like:
 # Move virtual filesystems over to the real filesystem
 mount -n --move /sys $ROOT_MOUNT/sys
 mount -n --move /proc $ROOT_MOUNT/proc

just before calling switch_root.

One other thing that surprised me, is that busybox&apos;s implementation of switch_root does _not_ move /proc and /sys _but_ the util-linux&apos;s one does. Guess we should be careful which version we package along with this script.

Hope this helps!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27283</commentid>
    <comment_count>6</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2012-11-07 10:39:45 +0000</bug_when>
    <thetext>Thanks Marc!

BTW, I&apos;m wondering whether there&apos;s any way to boot an iso image with runqemu?
I just built an image: core-image-minimal-qemux86-20121107085353.iso, but I can&apos;t boot it up. Any suggestion?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27298</commentid>
    <comment_count>7</comment_count>
    <who name="Marc Ferland">marc.ferland</who>
    <bug_when>2012-11-07 15:58:11 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Thanks Marc!
&gt; 
&gt; BTW, I&apos;m wondering whether there&apos;s any way to boot an iso image with runqemu?
&gt; I just built an image: core-image-minimal-qemux86-20121107085353.iso, but I
&gt; can&apos;t boot it up. Any suggestion?

I usually just use ext3 files with runqemu. I know it is possible to boot from an iso using straight qemu but I&apos;ve never tried with runqemu.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28499</commentid>
    <comment_count>8</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2012-12-31 02:29:13 +0000</bug_when>
    <thetext>Problem reproduced, and the patch will be sent in a day or two.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28614</commentid>
    <comment_count>9</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2013-01-08 06:55:46 +0000</bug_when>
    <thetext>merged in poky/master: 14649c003550ee08b73b1d8dbf51343087295e7b

http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/live-image</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29377</commentid>
    <comment_count>10</comment_count>
    <who name="Yi Zhao">yi.zhao</who>
    <bug_when>2013-01-31 07:47:39 +0000</bug_when>
    <thetext>Verified with master branch: 27c8af1e3a9092caa19bd813c4dd0747de766dc5

Steps:
###########
1. Add line IMAGE_FSTYPES = &quot;live&quot; to conf/local.conf
2. Build the qemux86 minimal image
3. Run command: runqemu qemux86 iso
###########

################
root@qemux86:~# mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
none on /dev type devtmpfs (rw,relatime,size=55400k,nr_inodes=13850,mode=755)
/dev/hdc on /media/realroot type iso9660 (ro,relatime)
/dev/loop0 on / type ext3 (ro,noatime,nodiratime,barrier=1,data=ordered)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /var/volatile type tmpfs (rw,relatime)
tmpfs on /media/ram type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
#################</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>