Cannot set permissions on second drive properly

I have a system with a second drive which I want to mount at boot.

My current /etc/fstab line for this:

UUID=b60a3f0c-ca47-4295-8605-b22637049b79 /srv ext4 defaults,noatime 0 1

I have set the owner:group of the mount point to the user:group media:media and the desired permissions to drwxrwsr-x. However, after each reboot, they are reset to drwxr-xr-x and I need to set them again with chmod g+sw /srv to have the desired behavior. The owner of the mount point stays as I set it, though, so not everything is reverted.

How can I make the permissions stick as I have set them?

EDIT: I just tried removing the defaults from the fstab line. Doesn’t change behavior.

Not sure if this wiki can be of any use to you ?

The defaults is only needed to have the right number of columns in that line, else the following parts would be interpreted instead.

What you need are the entries for ‘mode=abcd’ and ‘gid=wxyz’. Of course changed to the mode and gid you need.

Are you sure?!

The canonical source for ext4 information on kernel.org doesn’t list mode and gid as module options. AFAIK, they are for tmpfs, FAT and friends.

You are supposed to set owner/permissions for the root directory of the mount, which I did. At least this is what I thought is needed. I wouldn’t know how to debug this.

Sure enough, when I attempt to use mode=2775 in my /etc/fstab, do a sudo systemctl daemon-reload and try to mount, I get

emk2203@M4800:~$ LANG=C sudo mount -a
mount: /srv: fsconfig() failed: ext4: Unknown parameter 'mode'.
       dmesg(1) may have more information after failed mount system call.

So this cannot be the solution.

try adding rw to you options. I thought it was the default but maybe.

It reads and writes just fine, but with the wrong permissions. The owner and root can write without issues. The permissions get reset to the standard 755, where I want to have 2775 to have the same group also write permissions.

In that case, maybe it’s getting mountes with the wrong mask. I’m not sure if that on affects file creation or also mounting. Cheat-sheet.

Yup, that’s the issue. There’s an umask getting applied since the empty mount point has the proper 2775 permissions. The umask reduces it back to default 755.

But where does it come from? I have no idea how to fix this, except for applying sudo chmod g+sw /srv directly after boot.

I do this as a workaround, but I am interested to know why this happens.

Again I’m not completely sure about this, but try adding umask=007 to your mount options. This should allow user and group to read and write but give others no access. That is if it works at all!

mount: /srv: fsconfig() failed: ext4: Unknown parameter 'umask'.
       dmesg(1) may have more information after failed mount system call.

umask is also not part of the allowed mount options.

Hmm, I’m sure I remember umask. Maybe that was ext3 or something. The only other thing I can think of is you are chaning the permissions on the actual directory (not the files inside it) after the file system is mounted?

umask, dmask, fmask are for FAT/ntfs filesystems.

When I have the unmounted /srv directory, its permissions are 2775. After the boot & mount, they return to 755.

I’m afreaid I’m out of ideas, afaik, the permissions should stick.

I knew I remembered them from somewhere!