添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • How to determine full mount options for a mounted file system ?
  • If defaults provides an alias for async,auto,dev,exec,nouser,rw,suid , then why these options not reported in /etc/mtab , /proc/mounts or in mount command ?
  • If the filesystem is mounted with one of the option in defaults , do other options are applicable ?
  • For example, /etc/fstab lists tmpfs filesystem as below :
  • tmpfs                   /dev/shm                tmpfs    defaults        0 0  
    
  • However, mount command and /proc/mounts reports only rw from defaults :
  • # mount -v -t tmpfs 
    tmpfs on /dev/shm type tmpfs (rw)
    
    # cat /proc/mounts | grep tmpfs
    tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
    

    For tmpfs, the only filesystem options that are displayed are :

  • size=SIZE (if the size is not default)
  • nr_inodes=INODES (if the number is not the default)
  • mode=MODE (if the mode is not the default)
  • uid=UID (if the uid is not 0/root)
  • gid=GID (if the gid is not 0/root)
  • memory policy (if not default)
  • ro/rw is displayed for all filesystem types.

  • Some mount options are only displayed if they are not the default.
  • The most complete location to view the mount options is in /proc/self/mounts in RHEL 5 and /proc/self/mountinfo in RHEL 6
  • Root Cause

  • For most filesystems, the mount options are only displayed in /proc/mounts if :
  • they are applicable to the particular filesystem type
  • they are not strictly for internal use
  • the mount options are not the default setting
  • the user has the appropriate capabilities to show the options (CAP_SYS_ADMIN) in the current mount namespace
  • Diagnostic Steps

    [1] On a test system, edit fstab to mount tmpfs with rw only and performed a reboot :

    # cat /etc/fstab | grep tmpfs
    tmpfs                   /dev/shm                tmpfs   rw              0 0
    # cd /dev/shm/
    # cat > script.sh
    #!/bin/bash
    echo "Script ran"
    # chmod u+x script.sh 
    # ./script.sh 
    Script ran
    
  • Result : Script ran, though exec not set.
  • [2] Now, edit fstab to mount tmpfs with rw,noexec and performed a reboot :

    # cat /etc/fstab | grep tmpfs
    tmpfs                   /dev/shm                tmpfs   rw,noexec              0 0
    # cd /dev/shm/
    # cat > script.sh
    #!/bin/bash
    echo "Script ran"
    # ls -l
    total 4
    -rw-r--r--. 1 root root 30 Apr  6 00:47 scripts.sh
    # chmod u+x script.sh
    chmod: cannot access `script.sh': No such file or directory
    

    Result : Unable to set execute permission, as noexec is set explicitly.

    For example, mounting a filesystem with rw,exec options, will also mount the filesystem with suid,dev,auto, nouser,async,relatime.

  • But, if any of these option is unset explicitly, it will not be applicable.
  • This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

    Here are the common uses of Markdown.

    Code blocks
    ~~~
    Code surrounded in tildes is easier to read
            
    Links/URLs
    [Red Hat Customer Portal](https://access.redhat.com)
    Learn more Are you sure you want to update a translation? It seems an existing English Translation exists already. We appreciate your interest in having Red Hat content localized to your language. Please note that excessive use of this feature could cause delays in getting specific content you are interested in translated.