Linux – Permissions on files created by Linux in NTFS

linuxntfspermissions

I'm trying to mount NTFS filesystem in Linux with the following settings:

  1. In Linux all files and directories in NTFS should be owned by root
    and have a group win. Permissions should be set to 775.
  2. All files and directories created by Linux in NTFS filesystem should
    have in Windows the same ownership and permissions as a directory
    containing newly created file or directory.

To this end, I've added the following record to fstab:

/dev/sda7 /mnt/win/users_data ntfs-3g noauto,inherit,usermapping=/etc/ntfs-3g.usermapping,uid=0,gid=1002,umask=0002 0 0

Here is a content of the /etc/ntfs-3g.usermapping file:

:win:S-1-5-21-3452292639-2475245894-2622236828-1002
:win:S-1-5-21-3452292639-2475245894-2622236828-1003
:win:S-1-5-21-3452292639-2475245894-2622236828-1005
:win:S-1-5-21-3452292639-2475245894-2622236828-1004
:win:S-1-5-21-3452292639-2475245894-2622236828-1009
...

When the filesystem is mounted, the following message appears in console:

$ sudo mount /mnt/win/users_data
There were no valid user or no valid group

Files and directories in mounted filesystem have the right ownership and permissions in Linux (root:win 775). But in Windows all users is permitted to do all operations over files created by Linux in the filesystem.

What am I doing wrong? And how to mount NTFS filesystem in the way described above?

Best Answer

From the mount.ntfs-3g man page:

When a user mapping file (usermapping=file-name) is defined, the options uid=, gid=, umask=, fmask=, dmask= and silent are ignored.

  1. In Linux all files and directories in NTFS should be owned by root and have a group win. Permissions should be set to 775.

You don't need a usermapping for this. Your UID, GID and umask settings are correct, just ditch the usermapping=

Point 2. is achieved by using inherit which you already have.