0

I have a local SSD disk, which is mounted via /etc/fstab on my Ubuntu machine:

/dev/sdb2 /media/Store ntfs-3g rw,nosuid,nodev,default_permissions,umask=0002,uid=deniss,gid=deniss 0 0

I can read and write anything on that drive. Now I have installed nginx and php-fpm, and added www-data to my group and www-data in my group so i can edit files from both groups:

$ groups deniss
deniss : deniss adm cdrom sudo dip www-data plugdev lpadmin lxd sambashare

$ groups www-data
www-data : www-data deniss

nginx user (www-data) can read and write all files on mounted share, the problem starts when it tries to chmod files on a drive:

$ sudo -u www-data chmod 644 test.txt
chmod: changing permissions of '/media/Store/file.txt': Operation not permitted

Not that I need www-data to chmod files, but there are local websites running on the drive, and chmod sometimes is integrated into libraries and frameworks and I cannot disable them.

2
  • This is not NFS: a NFS would be a filesystem shared over the network from another computer. This is NTFS: the preferred filesystem of Windows operating systems. Furthermore, the ntfs-3g driver is based on FUSE, meaning that the filesystem driver is running as an user-space process, which causes some overhead, so the performance of the disk is not going to be as good as it could be with a Linux-native filesystem type.
    – telcoM
    May 21, 2021 at 12:21
  • Correct, as i use that disk in dual boot with Windows 10 May 22, 2021 at 16:19

2 Answers 2

4

NTFS is not a unix filesystem and is not capable of using unix ownership, groups, or permissions.

When an NTFS filesystem is mounted on linux, ONE user and ONE group are used to simulate ownership of ALL files and directories, and ONE set of permissions is also used for all files/dirs on the NTFS mount.

This is what the default_permissions,umask=0002,uid=deniss,gid=deniss part of your /etc/fstab entry is setting up.

4
  • BTW, have you considered having the www-data files locally on the nginix server and using samba to provide access to other computers & users on the network? That would avoid a lot of problems & headaches.
    – cas
    May 21, 2021 at 12:44
  • I actually don’t care how it’s mounted, as long as Windows has access to it, I can mount it in Ubuntu and both me and www-data can read/write to it. So you say i should try to mount it as Samba share? Isnt Samba for network drives? May 22, 2021 at 16:21
  • no, samba is useless for sharing a drive between dual-boot OSes. I was suggesting having the nginx server on a dedicated machine on your network (maybe a cheap raspberry pi or an old desktop or laptop PC), and providing RW access to other machines on your network via samba.
    – cas
    May 23, 2021 at 1:15
  • Hey, that's a great idea! I will think about it. Besides, it solves some other inconveniences i have. May 28, 2021 at 11:02
1

The ntfs-3g driver can actually provide the functional equivalents of unix-style ownerships, groups and basic permissions. It does not do it by default, because the driver does not know how the Linux user and group IDs should be represented as Windows Security IDs (SIDs for short).

But if you create a mapping file that identifies a corresponding Windows SID for each relevant Linux UID and GID, and place it (in your case) at /media/Store/.NTFS-3G/UserMapping, then commands like chmod and chown will work mostly as expected (except setuid/setgid/sticky bits for files) as long as only users and groups for which a SID mapping exists are referenced.

See the USER MAPPING paragraph in man ntfs-3g for details. The ntfsusermap command can help you in creating such a mapping file by identifying files with a particular Windows user or group SID and asking you what the corresponding Linux user or group should be, and repeating the process until all the existing SIDs in the filesystem are mapped or you want to stop creating more mappings.

From https://jp-andre.pagesperso-orange.fr/ntfsusermap.html you'll find examples on using ntfsusermap, and also a Windows version of the ntfsusermap tool, in case it's more convenient for you to create the mapping file while running Windows (so you can have Windows look up the human-readable names associated with each SID that needs to be mapped).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .