3

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?

  • 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. – peterh Aug 25 '14 at 12:14
1

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.

  • ahh that explains it. that source also shows that 'rw' is resolved and printed separately, explaining the difference there as well – Dylan Cali Aug 26 '14 at 6:03
3

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."

  • you pretty much nailed it. I went with Gilles answer just because he also included the source that definitively shows this logic. – Dylan Cali Aug 26 '14 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.