User Tools

Site Tools


ubuntu:processes:mounting_proc

Ubuntu - Processes - Mounting /proc

Objective

To ensure that procfs is mounted as /proc.


Symptoms

Errors caused by the absence of /proc often mention the inability to open a pathname within /proc, and in some cases suggest that you check whether procfs has been mounted. Here are some examples:

Cannot find /proc/version - is /proc mounted?

WARNING: Could not open /proc/net/vlan/config. Maybe you need to load the 8021q module, or maybe you are not using PROCFS??

Other messages may be less helpful and state only that some higher-level operation has failed. This could be almost anything related to the status or configuration of the running kernel, including in particular:

  • scheduling,
  • memory management,
  • device drivers, and
  • the network stack.

Diagnosis

Checking whether procfs has been mounted can be achieved trivially by listing the content of /proc:

ls /proc

The result should look broadly similar to this:

1     2118   31028  823          fb           loadavg       stat
101   2121   31029  acpi         filesystems  locks         swaps
1250  2125   31049  asound       fs           meminfo       sys
131   2233   4      buddyinfo    ide          misc          sysrq-trigger
132   2244   43     bus          interrupts   modules       sysvipc
133   2265   45     cgroups      iomem        mounts        timer_list
134   2284   46     cmdline      ioports      mtrr          timer_stats
1557  2286   5      cpuinfo      irq          net           tty
1570  2288   564    crypto       kallsyms     pagetypeinfo  uptime
2     2289   579    devices      kcore        partitions    version
2073  2290   581    diskstats    key-users    sched_debug   vmallocinfo
2082  2291   6      dma          kmsg         scsi          vmstat
2091  25840  609    driver       kpagecount   self          zoneinfo
2114  3      742    execdomains  kpageflags   slabinfo

but with details that depend on what processes are running and which kernel modules are loaded.

Alternatively, execute the mount command with no arguments and look for a line similar to:

none on /proc type proc (rw)

Possible causes

/proc is not listed in /etc/fstab

The most likely reason for procfs not being mounted is it not being listed in /etc/fstab. There should be a line of the form:

none /proc proc defaults 0 0

This should allow /proc to be mounted manually using the command:

mount /proc

and cause it to be mounted automatically on reboot.


The process is running inside a chroot

The process of entering a chroot does not cause init or any other boot-time scripts to be run, therefore even if /proc is listed in the copy of /etc/fstab within the chroot it will not be mounted automatically.

The solution is to mount from outside the chroot using the copy of /etc/fstab that governs the system as a whole. Whether you should actually do this depends on what the chroot is for:

  • Mounting /proc within a chroot jail is moderately undesirable because the purpose of a jail is to give the process inside it access to as little as possible. However it ought to be safe in theory: procfs does not allow non-root processes to perform privileged operations, and a root process would be able to mount it without help.
  • For other purposes, such as running a different version of the OS, you probably should mount /proc (and consider other mount points such as /dev).

For a chroot environment located at /opt/chroot an appropriate entry in /etc/fstab would be:

/proc /opt/chroot/proc none rw,bind 0 0

A bind mount has been used in this example.

It is possible to use an ordinary mount, because procfs does not object to being mounted twice, however that is not generally true for other filesystems.

The simplest and safest policy is to use bind mounts for everything.


procfs is missing from the kernel

This is very unlikely. Although procfs might once have been considered optional, this is not true in any meaningful sense for a modern Linux-based operating system.

Note that the procfs module is normally compiled into the kernel statically, so do not expect to find it in /lib/modules.

ubuntu/processes/mounting_proc.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki