Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 38360

Summary: /etc/init.d/checkroot mounts root 2 times
Product: Gentoo Hosted Projects Reporter: Donald R. Gray Jr <donald.r.gray>
Component: genkernelAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED FIXED    
Severity: normal CC: agriffis, alpeterson, andre.hinrichs, drobbins, flash3001, floeff, genkernel, GertThiel, gstag, hodak, iggy, jgonzalez.openinput, julie-gentoo, livewire, mariusmuja, matteo-ml, mccartyp, ml, morodoch, releng, stefano, tamer, vericgar
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Kernel config
Correct patch for checkroot
Correct patch for checkroot (try #2)

Description Donald R. Gray Jr 2004-01-15 17:26:01 UTC
Im not sure if this is intentional or not but with the new version of genkernel my / volume is mounted twice.

# mount
/dev/hda8 on / type reiserfs (rw,noatime,notail)
/dev/hda8 on / type reiserfs (rw,noatime)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev type devfs (rw)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/bus/usb type usbfs (rw)


Reproducible: Always
Steps to Reproduce:
1.compiled kernel with genkernel all --menuconfig --clean --mrproper --bootsplash
2.
3.

Actual Results:  
compiled kernel and initrd, no error messages on bootup on in genkernel.log


Relevant files can be accessed at http://www.dslextreme.com/users/rockhound/genbug/
Comment 1 Joseph 2004-01-17 14:39:46 UTC
I have this same issue; here is my grub conf...

title Gentoo
kernel (hd0,5)/boot/vmlinuz root=/dev/ram0 init=/linuxrc real_root=/dev/hda7 devfs=mount acpi=ht resume=/dev/hda8 splash=silent vga=788
initrd (hd0,5)/boot/initrd
Comment 2 Joseph 2004-01-17 14:41:48 UTC
Same here; this is my grub.conf:

title Gentoo
kernel (hd0,5)/boot/vmlinuz root=/dev/ram0 init=/linuxrc real_root=/dev/hda7 devfs=mount acpi=ht resume=/dev/hda8 splash=silent vga=788
initrd (hd0,5)/boot/initrd
Comment 3 Jeff Quasarano 2004-01-17 15:04:36 UTC
Same thing occurs with a normal lilo.conf install as well, using:

root=/dev/ram0
append "real_root=/dev/hdX#.... "

By 'normal', I mean it is otherwise consistent with the current install document.

Comment 4 Brad House 2004-01-18 08:23:47 UTC
yes, I have no idea why.  I actually think it's a 
baselayout issue in the rc-scripts.
It does not appear to affect anything though :/

Comment 5 Nathaniel McCallum 2004-01-25 11:53:48 UTC
It does affect something.  On shutdown, it tries to umount / 2x, resulting in an error and interrupting the shutdown proceedure (prompting for a root password or Ctrl-D). See http://bugs.gentoo.org/show_bug.cgi?id=33271.
Comment 6 Brad House 2004-01-28 18:58:08 UTC
I'm 99.9% positivie that only occurs if you have Automount devfs at boot turned
on, as I am able to reproduce it with that on, but not with it off.

-Brad
Comment 7 vtkstef 2004-01-31 22:49:35 UTC
I too see the double root mount with the mount command but only  mounted once in proc mounts. What I see though is that the '/' mount point is mounted without 
using the options specified in /etc/fstab 

my root fstab entry looks like this:

/dev/sda2 / xfs noatime,logbufs=8,logbsize=32k 0 1

while my mount command reports:

/dev/sda2 on / type xfs (rw,noatime,logbufs=8,logbsize=32k)
/dev/sda2 on / type xfs (rw,noatime)

and /proc/mounts contains:

rootfs / rootfs rw 0 0
/dev/root /tmp/.initrd ext2 rw 0 0
/dev/sda2 / xfs rw,noatime 0 0


Comment 8 hodak 2004-02-20 01:08:17 UTC
Created attachment 25969 [details]
Kernel config

I also have this double mount problem, even with latest stable genkernel. It is
not due to automounting of devfs, it is disabled in my kernel configuration. I
am attaching my kernel configuration file.
Here is what my mount shows:

/dev/hda3 on / type reiserfs (rw,noatime)
/dev/hda3 on / type reiserfs (rw,noatime)
none on /proc type proc (rw)
none on /dev type devfs (rw)
none on /dev/shm type tmpfs (rw)
none on /proc/bus/usb type usbfs (rw)

It does not seem to cause problem at runtime, but at shotdown, it does not
power down or reboot automatically, teh shutdown procedure just stops and it
asks for root password (for maintenance or something) or pressing CTRL-D. It is
quite annoying.
Comment 9 Julie Brandon 2004-02-22 07:53:20 UTC
Just to add to this, I'm seeing the same root mounted twice problem (once without the right options, once with), with genkernel's default 2.4 kernel config, and latest stable versions of everything


from grub.conf:
root   (hd0,3)
kernel (hd0,1)/kernel-2.4.22-gentoo-r7 root=/dev/ram0 real_root=/dev/hda4 init=/linuxrc vga=0x317 acpi=off
initrd (hd0,1)/initrd-2.4.22-gentoo-r7


from fstab:
/dev/hda4               /               ext3            defaults                0 0


from /proc/mounts:
rootfs / rootfs rw 0 0
/dev/root /tmp/.initrd ext2 rw 0 0
none /tmp/.initrd/dev devfs rw 0 0


from df:
/dev/hda4             11139884   5204728   5369268  50% /
/dev/hda4             11139884   5204728   5369268  50% /

[Though I've got a probably caused-by-me issue to look at here as well.... root is supposed to be an ext3 partition and its being mounted ext2 during boot :( ]
Comment 10 Joe Saland 2004-02-25 14:57:50 UTC
I had the same problem with my ext3 mounting as ext2,  turns out compiling ext3 into the kernel (not as a module) fixed that problem.  Though I still have the issue with the double mounted root.  Also not sure if this second piece is related, though this all seems to be related to bugs in the startup scripts generated by genkernel, it seems that the /tmp/.initrd mount never unmounts during boot, because the kernel is using it for access to the console device.


electro root # lsof | grep initrd
keventd       2   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
keventd       2   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
keventd       2   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
ksoftirqd     3   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
ksoftirqd     3   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
ksoftirqd     3   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kswapd        4   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kswapd        4   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kswapd        4   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
bdflush       5   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
bdflush       5   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
bdflush       5   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kupdated      6   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kupdated      6   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kupdated      6   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald  7186   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald  7186   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald  7186   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 17634   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 17634   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 17634   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 19277   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 19277   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 19277   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 22702   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 22702   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 22702   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 23496   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 23496   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 23496   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 24026   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 24026   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
kjournald 24026   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
khubd     31926   root    0u   CHR        5,1                  56 /tmp/.initrd/dev/console
khubd     31926   root    1u   CHR        5,1                  56 /tmp/.initrd/dev/console
khubd     31926   root    2u   CHR        5,1                  56 /tmp/.initrd/dev/console
Comment 11 Brad House 2004-02-25 15:23:50 UTC
actually as of _beta12, it should properly umount the initrd,
we're redirecting console earlier on, which fixed that problem.
We just released _rc2 today, which seems to have fixed everything
except the double mount.  The thing is it's not really double mounted
if you look in /proc/mounts, /etc/mtab just thinks it is, so I need
to debug that.
Comment 12 Paul 2004-02-26 02:13:42 UTC
I've just built the new genkernel, and I still have this problem. Genkernel reports this version:

# genkernel  
GenKernel 3.0.1_rc2 [options] command
[snip]

A df shows:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md2               1951744   1352328    599416  70% /
/dev/md2               1951744   1352328    599416  70% /

plus the OK other file systems, but /proc/mounts shows:

rootfs / rootfs rw 0 0
/dev/root /tmp/.initrd ext2 rw 0 0
/dev/md2 / reiserfs rw,noatime 0 0

plus other file systems

I've built the kernel with automount of /dev off, as per the genkernel readme.
Comment 13 Brad House 2004-02-26 19:45:51 UTC
please stop adding reports to this entry unless you have a fix

I will close it when it's fixed ....
we are aware of the double-mount entry in /etc/mtab (which 
is what shows when you run 'mount' without parameters).

We do not yet have a solution.

Thank you 
Comment 14 Tim Yamin (RETIRED) gentoo-dev 2004-02-27 11:06:37 UTC
*** Bug 42903 has been marked as a duplicate of this bug. ***
Comment 15 hodak 2004-02-29 02:15:00 UTC
Brad,
What about the shutdown problem (with unmount) (see comments 5 & 8)? Is this addressed in this bug report or should I file it as another bug? I am asking because you never commented directly on the shutdown issue.
Comment 16 Florian Effenberger 2004-02-29 02:51:53 UTC
At least on my system, the shutdown problem has disappeared with a recent Portage snapshot.
Comment 17 hodak 2004-02-29 02:59:38 UTC
being fully up-to-date, I can still see the shutdown problem, it gives error message saying something about remounting (?) and asks for password or CTRL-D. If I do not do anything, it shutdown the system within few seconds as asked (meaning that it does not just wait for input forever). 
Comment 18 Florian Effenberger 2004-02-29 03:09:58 UTC
Hm... mysterious. I don't have this anymore, but I don't know when and how it disappeared.
Comment 19 Brad House 2004-02-29 20:51:25 UTC
I thought I addressed it.
Basically, it ONLY occurs if you have automount at boot turned on
for devfs.  That MUST be turned off.
That is the only cause I have ever seen for that issue.  
Comment 20 Florian Effenberger 2004-02-29 21:47:25 UTC
Where do you turn automount on and off? In /etc/fstab?
I ask because I have followed the install doc all the time, so I have nothing changed, but it disappeared at once.
Comment 21 MKI 2004-02-29 23:52:48 UTC
The issue at hand is that /etc/init.d/checkroot forces a mount of /
after creation of /etc/mtab via a 'mount -f /' which seems unnecessary
because prior to that there's a mount of / via the remount option.

I commented out the 'mount -f /' at line 105, and this fixed the
double mount issue.  If the mount -f / is really required, then it
might be beneficial to add the -o remount option to that as well!
Comment 22 Aaron Peterson 2004-03-01 01:45:24 UTC
>I thought I addressed it.
>Basically, it ONLY occurs if you have automount at boot turned on
>for devfs.  That MUST be turned off.
>That is the only cause I have ever seen for that issue. 

So you can fix it!
I'm hoping to create a framework for checking for sane kernel configs, but in the mean time a quick awk through the .config file is all that is needed.

search for start of file CONFIG_STARTDEVFS or whatever it is
(start of file is a carrot? ^??)
and replace all ocurences with #CONFIG_STARTDEVFS



part of what the framework is supposed to do, is deal with the upcomming genkernel interactive mode (either in a fork or mainline depending on if my patches get accepted or even discussed)  and deal with what options are currently being made, if it's a noinitrd/busybox or whatever occurance, (I hate my spell checker), what's needed will be different (I presume)
Comment 23 hodak 2004-03-01 02:56:17 UTC
As for as the shutdown issue, I do not have automonting of devfs enabled, I have rebuilt my kernel just to make sure, but I still get error message at shutdown (Unmounting fails and I get "Remounting remaining filesystems readonly" message).
At that point mount says that root partition is mounted (twice) and it also sees /proc and /dev as mounted.

I have tried MKI's solution, it seems to work (root partition is finally mounted just once), but strangely it does not solve the shutdown issue for me. 

I have also used tried different kernel which compiled some time ago manually (no initrd) and had no problem at shutdown, so it looks like it is a genkernel problem. 
Comment 24 MKI 2004-03-03 11:16:47 UTC
Brad,

This problem may after all be really related to busybox's ash not
correctly closing the open filedescriptors for /dev/console upon
the exec with fd redirection?  Almost as though the filedescriptors
did not have FD_CLOEXEC set.  We tested a barebones linuxrc which
simply mounted the filesystem, pivot_root'd and then called chroot
with redirection for dev/console and even _that_ failed to allow
unmounting of the initrd image because all kernel threads were at
that point using the dev/console off of the initrd image instead of
the filesystem.  (busybox-1.00-pre7)
Comment 25 Tim Yamin (RETIRED) gentoo-dev 2004-03-04 09:27:31 UTC
[[ Reassigning ]]
Comment 26 Brad House 2004-03-07 08:02:13 UTC
MKI thanks for tracking  down the double-mount issue, it should definatly
have  -o remount in there, as /etc/fstab may have different options for
mounting, than when the initrd mounts the root.
As far as not closing down filedescriptors at exec, that's odd, as I do not
believe I'm seeing that here, though I am on AMD64 ...
I'll see if I can get azarah to commit the baselayout fix for the double-mount
issue.

Thanks for your help!
-Brad 
Comment 27 Tim Yamin (RETIRED) gentoo-dev 2004-03-14 06:18:01 UTC
*** Bug 43457 has been marked as a duplicate of this bug. ***
Comment 28 MKI 2004-03-18 02:50:03 UTC
Brad,

I just installed another system (portage sync'd earlier today during install)
and got bit by the initrd not unmounting issue.  After some googling and
mucking with the initrd image, I found out that the issue was really the
2.4.22 kernel (gentoo-sources branch).  The bug is that the kernel never
follows init's fd set (/dev/tty, /dev/console) as it should.

The default ebuild gentoo-sources-2.4.22-r7.ebuild really needs to be
patched to include the fix for the fd problem, so as to save all the other
poor souls the hassle of figuring this out.  I've included the patch below
(the double mount of / still remains however in baselayout):

--->8---cut-here---8<---
--- kernel/fork.c.old   2004-03-17 20:17:54.000000000 -0700
+++ kernel/fork.c       2004-03-17 19:17:42.000000000 -0700
@@ -572,7 +572,7 @@

        /* This can race but the race causes us to copy when we don't
           need to and drop the copy */
-       if(atomic_read(&files->count) == 1)
+       if(atomic_read(&files->count) == 1 || (current->pid == 1))
        {
                atomic_inc(&files->count);
                return 0;

--->8---cut-here---8<--- 

And here's the fix for baselayout's /etc/init.d/checkroot:

--- init.d/checkroot.old        2004-03-17 20:22:28.000000000 -0700
+++ init.d/checkroot    2004-03-17 20:39:04.000000000 -0700
@@ -80,9 +80,9 @@

                > /etc/mtab
                # Add the entry for / to mtab
-               mount -f /
+               mount -f -o remount /
                # Make sure we do not have these in there
-               egrep -v '^(rootfs|/dev/root)' /proc/mounts >> /etc/mtab
+               awk '{ if ($2 != "/" && $3 != "rootfs") print $0; }' /proc/mounts >> /etc/mtab
                # Now make sure /etc/mtab have additional info (gid, etc) in there
                for x in $(awk '{ print $2 }' /proc/mounts | uniq)
                do

--->8---cut-here---8<---

-mohan
Comment 29 Seemant Kulleen (RETIRED) gentoo-dev 2004-03-18 03:03:47 UTC
kernel issue, not base-system's removing from cc
Comment 30 Joshua Megerman 2004-03-19 11:21:24 UTC
I applied the patch to checkroot and it does resolve the problem of having root mounted twice.  However, /tmp/.initrd is still mounted because /tmp/.initrd/dev/console is still being held open by kernel processes 2-6,8 (ksoftirqd, events, kblockd, pdflush(x2) and aio) and /tmp/.initrd/dev could not be umounted.  Still, it's better than before (no error on reboot, laptop mode now works, etc.), and if I really don't like it I can go without the initrd and boot without it successfully...  Still, it would be nice to have a resolution for this one.  I'm using genkernel-3.0.1, built on 20040304 from a portage snapshot from either that day or the previous one.
Comment 31 Tim Yamin (RETIRED) gentoo-dev 2004-03-21 07:45:30 UTC
Reassigning this back to the Base System team since this is an issue with baselayout. The patch for /etc/init.d/checkroot [ ignore the kernel patch ] is in comment #28.

MKI: You might want to send that kernel patch upstream, since it is a problem in the vanilla sources. See http://bugme.osdl.org. The issue is solved in genkernel-3.0.2_rc1 without the need of a patch.
Comment 32 Tim Yamin (RETIRED) gentoo-dev 2004-03-21 07:47:21 UTC
*** Bug 44601 has been marked as a duplicate of this bug. ***
Comment 33 Paul Taylor 2004-03-31 05:54:43 UTC
Tim, are you sure that the issue has been resolved in genkernel-3.0.2_rc1?
I'm using genkernel-3.0.2 (final) with the gentoo-dev-sources kernel, and
the problem still exists (with none of the patches mentioned here):

# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hde6              8007288   2623396   5383892  33% /
/dev/hde6              8007288   2623396   5383892  33% /
/dev/hde2                77772      7232     66524  10% /boot
/dev/hde7              4069096   1304304   2554744  34% /usr/portage
none                    258072         0    258072   0% /dev/shm
Comment 34 Matteo Settenvini 2004-03-31 07:19:44 UTC
Yeah, you still need the patch for fork.c at the beginning of comment #28. Please try, for me it worked.
Comment 35 Tim Yamin (RETIRED) gentoo-dev 2004-03-31 07:24:17 UTC
The problem for the /tmp/.initrd issue has been fixed in genkernel 3.0.2_rc1; that was a genkernel issue. But; I don't maintain basesystem which contains the double root [/] bug; so this is still an open non-genkernel issue.
Comment 36 Benjamin Judas (RETIRED) gentoo-dev 2004-04-06 02:59:27 UTC
agriffis, this is one of the bugs you need to keep track of for 2004.1. I personally experienced this when building test-iso's for 2004.1. The 2.4.24-xfs-r3 just works fine, while 2.6.3-gentoo-dev-r3 prints that nasty "press ctrl+d..."-Message on shutdown.
Comment 37 Aron Griffis (RETIRED) gentoo-dev 2004-04-07 12:41:33 UTC
Created attachment 28842 [details, diff]
Correct patch for checkroot

I think this is the correct patch for checkroot.

If you add -o remount then you've missed the point.  The problem is that we
only want one listing in /etc/mtab for the root filesystem.  The listing that
we want is the one that is generated from mount -f /.  So first we clear the
mtab.  Then we add the correct listing with mount -f / (if you use -o remount
then it won't add the line at all).  Finally we add in other filesystems from
/proc/mounts, excluding any root listings.  The old code for that was buggy; I
think the new code will work correctly.
Comment 38 Aron Griffis (RETIRED) gentoo-dev 2004-04-08 09:57:13 UTC
Created attachment 28902 [details, diff]
Correct patch for checkroot (try #2)

Small but important change... beejay is already testing this update
Comment 39 Benjamin Judas (RETIRED) gentoo-dev 2004-04-08 12:17:37 UTC
Fixed on a Gentoo-2004.1 Beta-LiveCD (internal testing) / is mounted only once now.
Comment 40 Aron Griffis (RETIRED) gentoo-dev 2004-04-08 15:22:25 UTC
Fixed in baselayout-1.8.8
Comment 41 Thomas Smith 2004-04-23 17:23:35 UTC
I've read through this log and have been experiencing similar symptoms. At shutdown, I get

"Remounting remaining filesystems read-only...

Give root password for maintenance..."

My system is up to date (just synced it and emerged the "world").

What I found to cause my problem is /initrd . It appears that the initrd is being remounted to /initrd during boot as /dev/rood.old . This filesystem can't be unmount as it has many files that are in use. When "Remounting remaining..." at shutdown tries to remount /dev/root.old it fails.

To resolve this, I booted off of CD and deleted the directory (I originally created it to resolve a boot error regarding "/initrd not found").

With /initrd in place, /etc/mtab shows this:

/dev/md/0 / ext3 rw,noatime 0 0
/dev/root.old /initrd ext2 rw 0 0
proc /initrd/proc proc rw 0 0
none /proc proc rw 0 0
none /dev devfs rw 0 0
/dev/vg/usr /usr reiserfs rw,noatime 0 0
/dev/vg/home /home reiserfs rw,noatime 0 0
/dev/vg/opt /opt reiserfs rw,noatime 0 0
/dev/vg/var /var reiserfs rw,noatime 0 0
/dev/vg/tmp /tmp reiserfs rw,noatime 0 0
none /dev/shm tmpfs rw 0 0
none /proc/bus/usb usbfs rw 0 0

Notice lines 2 and 3 of /etc/mtab--/dev/root.old and proc are being mounted into /initrd.

I still have this problem after "emerge sync" and "emerge -u world"--was this an issue address with the fixes mentioned in this bug?
Comment 42 Aron Griffis (RETIRED) gentoo-dev 2004-04-23 17:46:29 UTC
Thomas, I think the problem you're seeing is different from what we resolved in this bug.  Please put it in a new bug and we'll chase it there.  Thanks!