4

My understanding is /proc/mounts should list all mount options for a filesystem, including kernel defaults, so I was surprised to see that exec (among others) is not listed here?

For example, my root and home filesystems in fstab:

/dev/mapper/vg0-xen_root / ext4 noatime,errors=remount-ro 0 1 /dev/mapper/vg1-xen_home /home ext4 defaults 0 2 

and how they appear in /proc/mounts:

/dev/mapper/vg0-xen_root / ext4 rw,noatime,errors=remount-ro,user_xattr,barrier=1,data=ordered 0 0 /dev/mapper/vg1-xen_home /home ext4 rw,relatime,user_xattr,barrier=1,data=ordered 0 0 


The filesystem independent defaults documented in man mount:

defaults Use default options: rw, suid, dev, exec, auto, nouser, and async. 


Why are some defaults (e.g. rw) listed but others (e.g. exec) are not? Is there a way to get the complete set of mount options associated with a filesystem?

1
  • man mount has a good list. But induvidual filesystem can define their own flags -> there is a separate list for every filesystem. But there are common flags and they are listed on the mount manpage. Commented Aug 25, 2014 at 12:14

3 Answers 3

4

The reason is probably that exec is the opposite of noexec, and it is noexec that is listed. Thus if noexec is absent, the user knows that exec is in effect. This is similar to dev / nodev. It seems that the exception is rw, which is listed even though it is in the default list.

Note: while the mount(8) man page says that defaults is a fixed list of default options, the fstab Wikipedia page says that "Default settings are defined per file system at the file system level."

1
  • you pretty much nailed it. I went with Gilles answer just because he also included the source that definitively shows this logic. Commented Aug 26, 2014 at 6:03
2

Files in /proc are generated by the kernel, not by the mount utility. The kernel omits options that are in their default kernel setting. The defaults of the mount utility don't always match the kernel defaults. You can check the defaults for your kernel version in the source code, in fs/proc_namespace.c. For example, as of version 3.15, noexec is displayed if applicable; nothing is displayed in the no-noexec (i.e. exec) case.

1
  • ahh that explains it. that source also shows that 'rw' is resolved and printed separately, explaining the difference there as well Commented Aug 26, 2014 at 6:03
2

man mount has a good list. But induvidual filesystem can define their own flags -> there is a separate list for every filesystem. But there are common flags and they are listed on the mount manpage.

exec is a default flag. The list of the defaults mount flags are also in the man mount (AFAIK in the kernel sys_mount() syscall there is no such thing). But if you will disallow it, you need to use noexec.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.