Gentoo Archives: gentoo-user

From: Mark Knecht <markknecht@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] To mount or not to Mount proc, that is the question
Date: Fri, 16 Mar 2012 21:51:47
Message-Id: CAK2H+eciLHNgFZEHShTMjikqVDcn_VLf986hYri9SnyWfAZ3hw@mail.gmail.com
In Reply to: Re: [gentoo-user] To mount or not to Mount proc, that is the question by "Canek Peláez Valdés"
1 On Fri, Mar 16, 2012 at 2:40 PM, Canek Peláez Valdés <caneko@×××××.com> wrote:
2 > On Fri, Mar 16, 2012 at 3:18 PM, Mark Knecht <markknecht@×××××.com> wrote:
3 >> On Fri, Mar 16, 2012 at 12:47 PM, Canek Peláez Valdés <caneko@×××××.com> wrote:
4 >>> On Fri, Mar 16, 2012 at 1:40 PM, Mark Knecht <markknecht@×××××.com> wrote:
5 >> <SNIP>
6 >>>> Looking at the Gentoo amd64 install guide here:
7 >>>>
8 >>>> http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=8
9 >>>>
10 >>>> it appears that the recommendation is to mount proc.
11 >>>>
12 >>>> [QUOTE]
13 >>>>
14 >>>> /dev/sda1   /boot        ext2    defaults,noatime     1 2
15 >>>> /dev/sda2   none         swap    sw                   0 0
16 >>>> /dev/sda3   /            ext3    noatime              0 1
17 >>>>
18 >>>> /dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0
19 >>>>
20 >>>> proc        /proc        proc    defaults             0 0
21 >>>> shm         /dev/shm     tmpfs   nodev,nosuid,noexec  0 0
22 >>>>
23 >>>> [QUOTE]
24 >> <SNIP>
25 >>>
26 >>> I haven't put /proc explicitly on my /etc/fstab since a long time ago,
27 >>> and everything seems to be working. However, I use systemd, which
28 >>> always mounts /proc with the default options, and only uses the entry
29 >>> in /etc/fstab (if present) to override the default options. In other
30 >>> words, systemd always mounts /proc, no matter if it's listed in
31 >>> /etc/fstab or not.
32 >>>
33 >>> I don't know what OpenRC does, but it would not surprise me that it's
34 >>> something similar.
35 >>>
36 >>> Regards.
37 >>> --
38 >>> Canek Peláez Valdés
39 >>> Posgrado en Ciencia e Ingeniería de la Computación
40 >>> Universidad Nacional Autónoma de México
41 >>>
42 >>
43 >> Thanks Canek. I appreciate your response.
44 >>
45 >> It seems when rereading the link above the authors do put the work
46 >> 'example' in italics, implying that possibly I should know what I'm
47 >> doing and not depend on the text on that page. I'm fine with the not
48 >> depending part. I'm not so sure about the 'know what I'm doing' part.
49 >> ;-)
50 >>
51 >> I'm going to take a wild guess that it's somehow mounted in an init
52 >> script these days but I have no reason to know that's actually how it
53 >> gets done. I did read the kernel docs and it doesn't seem to be done
54 >> automatically by the kernel AFAICT.
55 >
56 > No, it's the init system; look at /lib/rc/sh/init.sh:66:
57 >
58 > # By default VServer already has /proc mounted, but OpenVZ does not!
59 > # However, some of our users have an old proc image in /proc
60 > # NFC how they managed that, but the end result means we have to test if
61 > # /proc actually works or not. We do this by comparing two reads of
62 > # /proc/self/environ for which we have set the variable VAR to two
63 > # different values. If the comparison comes back equal, we know that
64 > # /proc is not working.
65 > mountproc=true
66 > f=/proc/self/environ
67 > if [ -e $f ]; then
68 >        if [ "$(VAR=a cat $f)" = "$(VAR=b cat $f)" ]; then
69 >                eerror "You have cruft in /proc that should be deleted"
70 >        else
71 >                einfo "/proc is already mounted, skipping"
72 >                mountproc=false
73 >        fi
74 > fi
75 > unset f
76 >
77 > if $mountproc; then
78 >        procfs="proc"
79 >        [ "$RC_UNAME" = "GNU/kFreeBSD" ] && proc="linprocfs"
80 >        ebegin "Mounting /proc"
81 >        if ! fstabinfo --mount /proc; then
82 >                mount -n -t "$procfs" -o noexec,nosuid,nodev proc /proc
83 >        fi
84 >        eend $?
85 > fi
86 >
87 > Mistery solved :D
88 >
89 > Regards.
90 > --
91 > Canek Peláez Valdés
92 > Posgrado en Ciencia e Ingeniería de la Computación
93 > Universidad Nacional Autónoma de México
94 >
95
96 Yep, that's it. Somewhat interestingly it was at line 89 in my file
97 but that may well be differences between OpenRC and systemd, etc.
98 Anyway, the code looks identical and at least on the one machine I've
99 tested it doesn't seem to have hurt anythign to remove it from my
100 fstab file.
101
102 !Thanks!
103
104 Cheers,
105 Mark