Linux – How to configure fstab so that a partition can be used by different users simultaneously

fstablinux

My intent is to set up a drive that any user can read to, write from, and execute on. Moreover, the users must be able to use the drive at the same time.

I have my fstab entry set up like this:

/dev/sdc1     /media/data2     auto    rw,users,noauto, exec     0    0

The drive is 1TB and formatted as FAT32. Right now, any user can mount the drive. A user that has mounted the drive may read, write, and execute, but if another user logs on and attempts to write or execute using this drive while the first user has mounted it, they are disallowed!

The second user may unmount the drive and then mount and use it as desired, but this would have consequences for the first user.

How do I set it up so that multiple users may use the drive at the same time?

Best Answer

Either you follow the advice in my comment and automount the drive at startup and disallow mounting and unmounting by users by changing users to nouser

The other possibility would be to assign all files on the drive certain gids. (group-ids)

Mount options for fat

(Note: fat is not a separate filesystem, but a common part of the msdos, umsdos and vfat filesystems.)

uid=value and gid=value Set the owner and group of all files. (Default: the uid and gid of the current process.)

umask=value Set the umask (the bitmask of the permissions that are not present). The default is the umask of the current process. The value is given in octal.

dmask=value Set the umask applied to directories only. The default is the umask of the current process. The value is given in octal.

fmask=value Set the umask applied to regular files only. The default is the umask of the current process. The value is given in octal.

source man mount

So as an example, to assign everything on the drive the root uid and gid use something like uid=0,gid=0,umask=000 this should make everything on the drive be owned by root, but still be usable through the open public umask.

If you want more control, you should add the users that are allowed to use the content of the drive to a certain group and look up its id, then you do like above but replace the gid by its value (say 123 here) uid=0,gid=123,umask=007. this should make the files (and directories) owned by user root and the group that belongs to 123, makes it readable, executable and writable to them, but they are locked to the public.

Never the less you should actually read the manpages about mount, groups and umask, because I cannot guarantee for the above to work. But I still hope I could push you into the right direction.