How can I check if /proc/ is mounted?

  • Using /etc/mtab is discouraged as it might be inconsistent.

  • Using /proc/mounts is also not an option as might not exist if /proc/ is not mounted (although checking for its existence may be a way to do this check.

What is the best way to do this check?

4 Answers 4


You can run the mount without any arguments to get a list of current mounts. The /etc/mtab file should have similar data, but like you said it is possible for this to be inconsistent with what is actually mounted in the event that the /etc file system is messed up, not writable, or another program has messed with it. You can get specific information about the proc mounts by asking mount to list all mounts of type proc like this:

mount -l -t proc

Edit: It looks like you can use stat to compare the device of the /proc folder to the device of / to tell at least if SOMETHING is mounted there other than the root file system:

[[ $(stat -c %d%D /proc) != $(stat -c %d%D /) ]] && echo "Something is mounted at /proc"
  • This is indeed one way to do it. The risk here is the running the mount command might get stuck on various problematic mounts like NFS/CIFS shares which are disconnected.
    – freddie
    Commented Jul 6, 2011 at 11:48
  • 1
    @freddie: Does it actually get stuck if you ask it to list mounts of type proc like I showed? I don't have a case I can test right now, but if it's decently implemented I don't see why it would hang on scanning the status of nfs mounts if asked to list only proc mounts. Note that I did NOT recommend running mount | grep proc for just that reason.
    – Caleb
    Commented Jul 6, 2011 at 11:51
  • I will need to test it, but I agree, if it's implemented properly, mount -l should not get stuck and in that case this is a good solution. Although, mount -l returns return code 0 if it finds a mount point (or more) or if it doesn't find it. So the check is further complicated by using mount -l -t proc |wc -l and checking how many filesystems are returned :(
    – freddie
    Commented Jul 6, 2011 at 11:56
  • @freddie: see my edit for another solution. Also you could use a string test on the mount without running wc: [[ -n $(mount -l -t proc) ]]
    – Caleb
    Commented Jul 6, 2011 at 12:06

Test for the existence of /proc/mounts. Running mount is no good because if /proc isn't mounted, it will return potentially obsolete data from /etc.

In theory there might be something else at /proc. But this is extremely unlikely in practice: if /proc/mounts exists and /proc isn't the proc filesystem, you can't trust anything about your environment anyway. If you're really worried, you can check that the filesystem type is proc: df -PT /proc | awk 'NR==2 && $2=="proc" {print 1}' (requires the Linux utilities df, there's no corresponding option in Busybox). Conversely, in theory, there could be a proc filesystem mounted in a different place; there's no easy way to find this with shell commands (df reads /proc/mounts to enumerate filesystems). In practice, just check for /proc/mounts.


If you want a (more or less) guarantee that the filesystem on /proc is in fact proc instead of some other filesystem or a directory structure made to look like it, you can call statfs() and check the type, 0x9fa0 is the value for proc.


There is tool called mountpoint avaiable on many linux installations. The exitcode is 0 if the first argument is a mountpoint.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .