Changing permissions for a mounted drive

I am trying to setup a VM to handle my Nextcloud site. It currently runs on physical hardware.

The issue that I am having is that in order to handle the amount of data I have an external SSD drive for that data. I have tried to have it mounted as a drive on the host or as pass through to the VM. In either case, the drive is being mounted with permissions 777. Nextcloud complains as it wants the data directory with permissions 770. I have tried changing the permissions on the mount point to 770 but after the drive is mounted (either from the host or from the pass through) permissions are again 777.

I have tried using dir_mode and file_mode on the mount but they do not appear to have any effect.

The current entry in my fstab for this device is:
/dev/sdb2 /mnt/extradasd ntfs rw,dir_mode=770,file_mode=770,noatime 0,0

I’m drawing blanks as to what to try next so would appreciate your feedback.

IIUC this is an ntfs drive and as far as I know an ntfs drive will always be mounted 777. The ntfs system has no concept of linux file system permissions. Thus it seems you would need that drive to be formatted as a linux file system to enable linux permissions on it.

1 Like

Hmmm - interesting. So, what about a scenario where I create a virtual disk on the ntfs drive and the virtual disk is formatted say as an ext4. Would I be able to mount that virtual disk then with permissions other than 777?

Have you tried setting the umask in the mount options?

ref: fstab mount options for umask, fmask, dmask for ntfs with noexec - Unix & Linux Stack Exchange

Thanks Grumpey - I’ll give this a more thorough read in the morning - my mind is winding down now for the night and I need to be more clear headed while trying to understand the masking settings.

Thanks for the reference to the umask/dmask/fmask query grumpey. After reading through it and on the ntfs-3g and ntfsmapuser options/commands I think I have resolved the issue. For the moment, I have added the “permissions” option on the mount command. That has allowed me to change the permission on the directory in question as well as the owner of the directory. Will continue to do some more testing but things are looking good for now.

For references purposes - the mount command now in the fstab file for this drive is:
/dev/sdb2 /mnt/extradasd ntfs-3g rw,permissions,noatime 0,0

2 Likes

Wow, I just know that we can do that with ntfs-3g driver.

Btw with kernel 5.15, without ntfs-3g driver I can use something like:

UUID=<UUID-number>          /mnt/data       ntfs3 	defaults 0 0

to be able to change the permission.

Source doc

1 Like