<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>175243</bug_id>
          
          <creation_ts>2007-04-19 16:27 0000</creation_ts>
          <short_desc>/proc/mounts references /dev/root for / but /dev/root does not exist</short_desc>
          <delta_ts>2007-11-19 20:42:30 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Ebuilds</component>
          <version>2006.1</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>cardoe@gentoo.org</reporter>
          <assigned_to>udev-bugs@gentoo.org</assigned_to>
          <cc>brebs@sent.com</cc>
    
    <cc>cgwaldman@gmail.com</cc>
    
    <cc>gentopia@gentoo.org</cc>
    
    <cc>ikelos@gentoo.org</cc>
    
    <cc>kernel@gentoo.org</cc>
    
    <cc>nospam@dolney.com</cc>
    
    <cc>teidakankan@gmail.com</cc>

      

      
          <long_desc isprivate="0">
            <who>cardoe@gentoo.org</who>
            <bug_when>2007-04-19 16:27:33 0000</bug_when>
            <thetext>Basically if you look at /proc/mounts on a system booted with or without our initramfs, you will see that in /proc/mounts that the kernel says /dev/root is mounted as the / device. However there is no /dev/root device.

Straight from the mount(8) man page...

When the proc filesystem is mounted (say at /proc), the files /etc/mtab
       and /proc/mounts have very similar contents. The  former  has  somewhat
       more  information, such as the mount options used, but is not necessar-
       ily up-to-date (cf. the -n option below). It  is  possible  to  replace
       /etc/mtab  by  a symbolic link to /proc/mounts, and especially when you
       have very large numbers of mounts things will be much faster with  that
       symlink, but some information is lost that way, and in particular work-
       ing with the loop device will be less convenient, and using the  &quot;user&quot;
       option will fail.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zzam@gentoo.org</who>
            <bug_when>2007-04-19 16:57:12 0000</bug_when>
            <thetext>my suggestions are:

A: In hal init-script (or before: like end of udev-start): read major/minor of dir &quot;/&quot; and mknod /dev/root if it does not exist

B: let code search inside /dev for the device with that major/minor and link to it.

getting major/minor cannot use program stat (at least not in udev) as stat is in /usr.
We need a small helper call syscall stat and extract the info from there.

C: Adding a udev rule similar to this:
SUBSYSTEM==&quot;block&quot;, PROGRAM==&quot;check_if_i_am_root&quot;, SYMLINK=&quot;root&quot;
and that program (check_if_i_am_root) compares major/minor of the device to that of &quot;/&quot; directory.

something like:

major=getenv(&quot;MAJOR&quot;);
minor=getenv(&quot;MINOR&quot;);
dev_t dev=stat(&quot;/&quot;);
if (major/minor == dev)
  return EXIT_SUCCESS;
else
  return EXIT_FAILURE;



D: Patching hal to do this:
if (device==&quot;/dev/root&quot;) {
 device=lookup_real_name;
}

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dsd@gentoo.org</who>
            <bug_when>2007-04-19 17:11:32 0000</bug_when>
            <thetext>I feel that hal shouldn&apos;t be relying on the devices listed in /proc/mounts existing. As /proc/mounts is kernel-space but filesystem contents are controlled in userspace (and operations are not really filtered by the kernel), there&apos;s no way consistency can be guaranteed.

Some examples for when these devices nodes might not exist:

 1. When the kernel mounts the root filesystem during boot. There is no userspace here and no /dev. The kernel has to choose a name for the node, or not list it at all. There is no guarantee that userspace will create the same name later.

 2. When a mounted usb flash drive is unplugged, the device goes away but the mount does not.

 3. The user could remove a mounted node, or /dev might be replaced by another layout entirely (this happens during initramfs pivot, for example).

 4. Many things in /proc/mounts don&apos;t correspond to device nodes anyway, e.g. sysfs

The kernel documentation does not comment on the accuracy of the device nodes listed in /proc/mounts. Neither does the mount documentation. FWIW, I also think a kernel documentation patch would be accepted to add some comments pointing out the obvious that device nodes referred to in /proc/mounts may not actually exist in userspace (because what userspace does in this sense is not kernel business). Maybe this would change your views on the solution here.

IMO hal should do something different. Even though creating /dev/root would workaround the majority of problems, I don&apos;t feel that it is a solution, and given our crazy user-base you&apos;ll probably get that one guy who files an obscure bug later for a different device node.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zzam@gentoo.org</who>
            <bug_when>2007-04-19 17:28:54 0000</bug_when>
            <thetext>Created an attachment (id=116745)
blockdev_is_root.c

calling the attached program from that udev-rule will create /dev/root:
SUBSYSTEM==&quot;block&quot;, PROGRAM==&quot;blockdev_is_root&quot;, SYMLINK+=&quot;root&quot;</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>wolf31o2@gentoo.org</who>
            <bug_when>2007-04-19 18:28:52 0000</bug_when>
            <thetext>I&apos;m just curious why genkernel is on here.  We don&apos;t use udev (anymore) at all in our initramfs stuff, as we&apos;ve replaced it with mdev from busybox to reduce size and complexity.  Of course, I might just be missing something important.  ;]</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>cardoe@gentoo.org</who>
            <bug_when>2007-04-19 21:01:51 0000</bug_when>
            <thetext>Because the initramfs needs to create the proper node as well.. whatever that&apos;s getting populated as. SuSE and RedHat&apos;s initramfs is doing the right thing and mounting the device for the kernel so it&apos;s a non-issue. But I don&apos;t know if your initramfs does this...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>brebs@sent.com</who>
            <bug_when>2007-04-20 02:51:27 0000</bug_when>
            <thetext>Arch Linux creates /dev/root by calling root-link.sh in /etc/udev/rules.d/udev.rules

$ grep root /etc/udev/rules.d/*
/etc/udev/rules.d/udev.rules:# fix /dev/root symlink
/etc/udev/rules.d/udev.rules:SUBSYSTEM==&quot;block&quot;, RUN+=&quot;/lib/udev/root-link.sh&quot;

The script and udev patches are at:
http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/base/udev/?cvsroot=Current&amp;only_with_tag=CURRENT</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>christophe@saout.de</who>
            <bug_when>2007-04-20 22:02:31 0000</bug_when>
            <thetext>My system doesn&apos;t show /dev/root in /proc/mount (because in my case it&apos;s mounted by initramfs, not the kernel itself), so the warning is bogus on my machine.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>cgwaldman@gmail.com</who>
            <bug_when>2007-04-20 22:17:39 0000</bug_when>
            <thetext>    An even better way to get the root device, rather than getting it from
    /proc/cmdline (which may not work, since if you use LILO the root device gets
    turned into a number), is to do 

    mount -fv / | cut -d&apos; &apos; -f1

    or equivalently,

    mount -fv / | awk { print $1 ; }

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zzam@gentoo.org</who>
            <bug_when>2007-04-21 06:24:28 0000</bug_when>
            <thetext>Discussion on hotplug-ML about that topic/suggested udev patch can be found 
here:
http://thread.gmane.org/gmane.linux.hotplug.devel/11277</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>kfirufk@gmail.com</who>
            <bug_when>2007-04-21 11:13:41 0000</bug_when>
            <thetext>thanks for your comments.

i added this to /etc/conf.d/local.start
ROOT_DEVICE=`mount -fv / | cut -d&apos; &apos; -f1`
ln -s ${ROOT_DEVICE} /dev/root

do i need to create the device before hal is started, or is this a good method ?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>cardoe@gentoo.org</who>
            <bug_when>2007-04-21 17:28:30 0000</bug_when>
            <thetext>I personally feel this is a kernel bug. Since we&apos;re instructing the kernel via root= what dev device it should use. It should respect that, after all it does for initramfs so why not for root=.

Attached is a patch to do such with the kernel.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>cardoe@gentoo.org</who>
            <bug_when>2007-04-21 17:29:36 0000</bug_when>
            <thetext>Created an attachment (id=116919)
use root= rather then hardcoding to /dev/root

The other advantage of this is that we don&apos;t have to search and compare every block device. It&apos;s also not a userspace hack to fix a kernel space bug.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>mycroes@zonnet.nl</who>
            <bug_when>2007-04-27 19:37:16 0000</bug_when>
            <thetext>I was just wondering... What&apos;s the exact goal of this /dev/root thing? Because if I&apos;m using an initrd, my kernel command line option will be root=/dev/ram0, if I&apos;m not, it will be /dev/sda6. I don&apos;t see the use for a /dev/root that is based on the way I boot, but I guess I&apos;m missing something...

For me the warning is bogus too right now, there&apos;s no /dev/root in my /proc/mounts, the only references are:
rootfs / rootfs rw 0 0
/dev/sda6 / reiserfs rw,noatime 0 0

Please enlighten me...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>cardoe@gentoo.org</who>
            <bug_when>2007-04-27 20:40:43 0000</bug_when>
            <thetext>Michael,

When you use an initramfs (initrd), the kernel does the right thing. As you can see there, your device for / is /dev/sda6.

This bug is for when there is no initramfs.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>agaffney@gentoo.org</who>
            <bug_when>2007-11-17 02:59:32 0000</bug_when>
            <thetext>Since this bug is for behavior that occurs when there is *not* an initramfs, I&apos;m removing genkernel.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>zzam@gentoo.org</who>
            <bug_when>2007-11-19 20:42:30 0000</bug_when>
            <thetext>This is fixed. udev handles it fine now so /dev/root will exist.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>116745</attachid>
            <date>2007-04-19 17:28 0000</date>
            <desc>blockdev_is_root.c</desc>
            <filename>blockdev_is_root.c</filename>
            <type>text/plain</type>
            <data encoding="base64">Ly8gY29tcGFyZSBNQUpPUi9NSU5PUiBpbiBlbnZpcm9ubWVudCB3aXRoIHRoZSBkZXZpY2UKLy8g
LyBpcyBtb3VudGVkIG9uCi8vCi8vIEF1dGhvcjogTWF0dGhpYXMgU2Nod2Fyem90dCA8enphbUBn
ZW50b28ub3JnPgoKI2luY2x1ZGUgPHN5cy90eXBlcy5oPgojaW5jbHVkZSA8c3lzL3N0YXQuaD4K
I2luY2x1ZGUgPHVuaXN0ZC5oPgo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V2X21pbm9yKSkKCQlyZXR1cm4gRVhJVF9TVUNDRVNTOwoKCXJl
dHVybiBFWElUX0ZBSUxVUkU7Cn0KCg==
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>116919</attachid>
            <date>2007-04-21 17:29 0000</date>
            <desc>use root= rather then hardcoding to /dev/root</desc>
            <filename>dev-root-real-root.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGxpbnV4LTIuNi4yMC1nZW50b28tcjYvaW5pdC9kb19tb3VudHMuYwkyMDA3LTA0LTE3IDAx
OjI3OjI3LjAwMDAwMDAwMCAtMDQwMAorKysgbGludXgtZGV2LXJvb3QvaW5pdC9kb19tb3VudHMu
YwkyMDA3LTA0LTIxIDEzOjAwOjMyLjAwMDAwMDAwMCAtMDQwMApAQCAtMzU0LDcgKzM1NCwxMCBA
QAogCXZhX3N0YXJ0KGFyZ3MsIGZtdCk7CiAJdnNwcmludGYoYnVmLCBmbXQsIGFyZ3MpOwogCXZh
X2VuZChhcmdzKTsKLQlmZCA9IHN5c19vcGVuKCIvZGV2L3Jvb3QiLCBPX1JEV1IgfCBPX05ERUxB
WSwgMCk7CisJaWYgKHNhdmVkX3Jvb3RfbmFtZVswXSkKKwkJZmQgPSBzeXNfb3BlbihzYXZlZF9y
b290X25hbWUsIE9fUkRXUiB8IE9fTkRFTEFZLCAwKTsKKwllbHNlCisJCWZkID0gc3lzX29wZW4o
Ii9kZXYvcm9vdCIsIE9fUkRXUiB8IE9fTkRFTEFZLCAwKTsKIAlpZiAoZmQgPj0gMCkgewogCQlz
eXNfaW9jdGwoZmQsIEZERUpFQ1QsIDApOwogCQlzeXNfY2xvc2UoZmQpOwpAQCAtMzk3LDggKzQw
MCwxMyBAQAogCX0KICNlbmRpZgogI2lmZGVmIENPTkZJR19CTE9DSwotCWNyZWF0ZV9kZXYoIi9k
ZXYvcm9vdCIsIFJPT1RfREVWKTsKLQltb3VudF9ibG9ja19yb290KCIvZGV2L3Jvb3QiLCByb290
X21vdW50ZmxhZ3MpOworCWlmIChzYXZlZF9yb290X25hbWVbMF0pIHsKKwkJY3JlYXRlX2Rldihz
YXZlZF9yb290X25hbWUsIFJPT1RfREVWKTsKKwkJbW91bnRfYmxvY2tfcm9vdChzYXZlZF9yb290
X25hbWUsIHJvb3RfbW91bnRmbGFncyk7CisJfSBlbHNlIHsKKwkJY3JlYXRlX2RldigiL2Rldi9y
b290IiwgUk9PVF9ERVYpOworCQltb3VudF9ibG9ja19yb290KCIvZGV2L3Jvb3QiLCByb290X21v
dW50ZmxhZ3MpOworCX0KICNlbmRpZgogfQogCg==
</data>        

          </attachment>
    </bug>

</bugzilla>