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

Bug 155680

Summary: Make mounting of /proc optional
Product: Gentoo Linux Reporter: Phil <Phil>
Component: [OLD] baselayoutAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED WONTFIX    
Severity: enhancement CC: Phil
Priority: High    
Version: 2006.0   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Phil 2006-11-19 07:44:57 UTC
Hi!
My initramfs mounts /proc itself, and can not unmount it as it is in use (dmcrypt mappings are set up). This leads to a harmless, but ugly situation where /proc is shown mounted twice.
Under normal circumstances it is a good idea to mount /proc, as the mounted fs inside initramfs is not usable after switch_root'ing. I found a quite elegant solution, before running switch_root i do a mount -o move to move the mounted /proc to /newroot/proc. After this /proc is still usable in the new rootfs without needing to mount it. Also there is only one entry in /proc/mounts for it.
I did a little /sbin/rc enhancement to allow skipping its attempt to mount /proc at boot time. Here it is:

--- /sbin/rc.orig 2006-11-19 15:34:39.106207470 +0100
+++ /sbin/rc   2006-11-19 15:51:00.180061574 +0100
@@ -215,16 +215,20 @@
      echo
     fi

-  check_statedir /proc
+  if [[ ${RC_SKIP_PROC} != "yes" ]] ; then
+     check_statedir /proc

-  ebegin "Mounting proc at /proc"
-  if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
-     mntcmd=$(get_mount_fstab /proc)
+     ebegin "Mounting proc at /proc"
+     if [[ ${RC_USE_FSTAB} = "yes" ]] ; then
+        mntcmd=$(get_mount_fstab /proc)
+     else
+        unset mntcmd
+     fi
+     try mount -n ${mntcmd:--t proc proc /proc -o noexec,nosuid,nodev}
+     eend $?
   else
-     unset mntcmd
+     ewarn "Mounting of /proc skipped"
   fi
-  try mount -n ${mntcmd:--t proc proc /proc -o noexec,nosuid,nodev}
-  eend $?

   # Start profiling init now we have /proc
   profiling start
--- /etc/conf.d/rc.orig 2006-11-19 15:19:42.277546150 +0100
+++ /etc/conf.d/rc   2006-11-19 15:48:18.592626598 +0100
@@ -98,6 +98,12 @@

 RC_USE_FSTAB="no"

+# RC_SKIP_PROC allows you to prevent rc from mounting /proc at boot time.
+# This is especially useful if it has already been mounted by an initrd/
+# initramfs or similar.
+
+RC_SKIP_PROC="no"
+
 # RC_USE_CONFIG_PROFILE allows you to have different /etc/conf.d files
 # based on your runlevel - if a conf.d file for your profile does not exist
 # then we try and use the default one.

Maybe you could integrate it, as it is no big deal and saves (at least) me from accidentally overwriting my customized /sbin/rc.

Greetings, Phil
Comment 1 Roy Marples (RETIRED) gentoo-dev 2006-11-20 01:44:59 UTC
baselayout-1.13.0_alpha doesn't mount /proc if it's already mounted, which should provide the functionality you require.

re-open if you disagree.

Thanks for the patch though :)
Comment 2 Phil 2008-07-12 13:17:16 UTC
Hi!

What's the status of the mentioned problem here?

I'm using baselayout-1.12.11.1 and still having the problem of /proc forcibly
being mounted at boot time. Do I have to update to baselayout-2? 

Greetings, Phil
Comment 3 Phil 2008-12-03 16:18:29 UTC
For all who stumble upon this bug report: migrating to baselayout2 and openrc
indeed eliminate this issue, as mounting of /proc is just an init service and
therefore can be disabled.

The migration guide can be found here:
http://www.gentoo.org/doc/en/openrc-migration.xml

BTW: the reason why my Gentoo installations mustn't mount /proc is this:
http://nwl.cc/cgi-bin/git/gitweb.cgi?p=initramfs-init.git;a=summary

Greetings, Phil