Cannot set "users" option with mount

Latest response

Hi,
when executing mount -o users /dev/sdx /mnt and then checking applied mount options with the mount command alone (w/o any other arguments) it only implies few other options like noexec, nosuid, and nodev aside from the implicit ones rw,relatime,data=ordered but no trace of the users option itself. The absense of the option is also confirmed when I try to umount the fs with a regular user, "umount: /mnt: umount failed: Operation not permitted" appears and the fs is still mounted. Where's the problem? Thank you.

RHEL 7.2 x64 in VirtualBox

Responses

if you want to mount or umount by any users I think options has to be defined in the /etc/fstab file. try to define entries in the /etc/fstab file with users options. e.g in /etc/fstab file /dev/mapper/vg_test /soft ext4 users 1 2

I've added: /dev/sdb1 /mnt ext4 users 0 0 to fstab and now I'm confused. Even though I'm able to umount it with a regular user now, the option users is still absent in the list of applied options in the mount output, why is that? And moreover, what is the point of the -o parameter in the mount command if the options can't be applied this way but only via fstab instead?

David, as per the man page of mount when either "user" or "users" parameter has been passed with mount command then it would be list "noexe,nosuid,nodev" when checked with /proc/mounts output.

       user   Allow  an  ordinary  user  to mount the filesystem.  The name of the mounting user is written to mtab so
              that he can unmount the filesystem again.  This option implies the options  noexec,  nosuid,  and  nodev
              (unless overridden by subsequent options, as in the option line user,exec,dev,suid).

       nouser Forbid an ordinary (i.e., non-root) user to mount the filesystem.  This is the default.

       users  Allow  every  user to mount and unmount the filesystem.  This option implies the options noexec, nosuid,
              and nodev (unless overridden by subsequent options, as in the option line users,exec,dev,suid).

That means when mounted with users parameter you would get to see "noexec,nosuid,nodev" not "users"; check by in /proc/mounts file. If you don't specify "users" parameter while mounting then these option would not get apply.

Yes, adding it to fstab would make the mounting and unmounting task easy. Also, the /etc/mtab gets updated on each of these transactions.

Sadashiva: Yes, I've read the man page and as I said in my 1st post the trio of options noexec,nosuid,nodev does indeed apply. But what I expected was that the users option itself would be shown too so the final array would be something like rw,nosuid,nodev,noexec,users,relatime,data=ordered but I guess this was my wrong understanding of how it works. Anyway my 2nd question still stands - what is the purpose of the -o parameter in the mount command if it doesn't work correctly and only specifying the users option via fstab makes the filesystem being unmountable by regular users?

based on the man pages

<br /> The non-superuser mounts.
              Normally, only the superuser can mount filesystems.  However, when fstab contains the user option on a line, anybody can mount  the  corresponding
              system.

              Thus, given a line

                     /dev/cdrom  /cd  iso9660  ro,user,noauto,unhide

              any user can mount the iso9660 filesystem found on his CDROM using the command

                     mount /dev/cdrom

              or

                     mount /cd

              For  more  details,  see fstab(5).  Only the user that mounted a filesystem can unmount it again.  If any user should be able to unmount, then use
              users instead of user in the fstab line.  The owner option is similar to the user option, with the restriction that the user must be the owner  of
              the special file. This may be useful e.g. for /dev/fd if a login script makes the console user owner of this device.  The group option is similar,
              with the restriction that the user must be member of the group of the special file.

Reena: I'm sorry but I can't seem to find how it answers my question. We already know that the users option allows to unmount the given filesystem by regular users but even though I specify it with the -o parameter in the mount command, it doesn't make it unmountable by regular users. Only via fstab it works. Or is there something else I'm missing here?

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.