9

I have a NTFS partition on my PC. It shares data between Linux and a Windows dual boot system.

My /etc/fstab line for that is:

#Mount Dati at boot=
UUID=01CD9E64E80BD460 /mnt/Dati ntfs nls=iso8859-1,umask=0022,uid=1000,gid=1000,dmask=027,fmask=137 0 0

There is something wrong, because I can not make any files executable. What should I change?

In addition, can someone help me understand umask, dmask, and fmask or post a link to some guide?

Summarizing: What permission should I give to a NTFS partition that is shared between Linux and Windows, and shared on samba network?

MadMike
  • 4,244
  • 8
  • 28
  • 50
f.lambe
  • 111
  • Are you trying to prevent files on that filesystem from being executed or you want to be able to execute them?
    The permissions you should give do not depend on which OS is going to use the FS but on what you want to do with the files in it.
    – Didi Kohen Nov 28 '12 at 14:27
  • i want to be able to execute them. i'm not well explained, my mistake. – f.lambe Nov 29 '12 at 13:08
  • On the Windows system? If so you don't need the execute bit, Windows ignores it. – Didi Kohen Nov 29 '12 at 14:18
  • misunderstanding.. I'm not able to execute files from Linux system. I've written about win, beacause the partition where there are these files is NTFS – f.lambe Nov 29 '12 at 17:55

1 Answers1

23

I know this question was asked a while ago, but I will try to answer it anyway for future users:

About mask in file system:

The use of masks in linux filesystem is to control - read, write, and execute permission among different users/groups for specific files and folders. I emphasize the word 'control' because masks are not same as giving permission. Just the opposite; they are to control or limit permission. So, if you want to set 777 for a file as permission, then you have to use 000 as mask for that file. For permission 655, mask will be 122 (i.e: for permission xyz mask will be (777-xyz)).

What is umask,dmask, and fmask?

  • umask = user mask (folder and directory!)
  • dmask = directory only mask
  • fmask = file only mask

How To Set Executable Permission for NTFS Partition files?

Run this command to get UUID (Universally Unique IDentifier) for every NTFS drive:
$ sudo blkid

You will get output like this:

/dev/sda6: LABEL="Software" UUID="FEDC5DB5DC5D6943" TYPE="ntfs" 
/dev/sda7: LABEL="Works" UUID="585AD06A35149024" TYPE="ntfs" 

Now edit the fstab file:

$ sudo vim /etc/fstab

In the fstab file add/edit every drive specifying line with the following options (remember to use other option carefully, as adding any other option may cause problem):

defaults,auto,umask=002 

So after edit/adding nfts drives your portion of fstab file will look something like this:

#<file system>           <mount point>   <type>  <options>                  <dump>  <pass>
UUID=FEDC5DB5DC5D6943   /media/software   ntfs    defaults,auto,umask=002      0      0
UUID=585AD06A35149024   /media/works      ntfs    defaults,auto,umask=002      0      0

Above umask will set permission equal 775, i.e read-write-execute for admin user (that is you) and admin user group and read-write permission for other users. For samba share you might need to use gid=YourGroupID,uid=YourUserID in the option set. You can find YourGroupID and YourUserID values using the following command:

$ id YourUserName

Now Unmount your drives if already mounted:

$ sudo umount -a

Then mount by this command:

$ sudo mount -a

After mount you can use the drives in whatever way you want.

AtariBaby
  • 321
sowrov
  • 333
  • What if I already have options dmask and fmask? Can I remove them? They have four digits e.g. 0177 -- what could that mean? – Sanjay Manohar Jan 03 '15 at 23:03
  • I'm using ubuntu 18.04. I tried what you mentioned above. But no luck. I can't write file from the terminal without sudo. And the file permission remains the same even if use sudo. ex: sudo chmod 400 my-file-name.txt and ls -la my-file-name.txt's permission still remains the same. No change – ssi-anik Dec 28 '20 at 15:51