"dmask" and "fmask" mount options
I tried this command to mount manually :
sudo mount -t vfat /dev/sdb1 /media/external -o uid=1000,gid=1000,utf8,dmask=027,fmask=137
I am not getting what dmask
and fmask
do here. I know they are used to set up permissions, but when I check permissions of files and folders inside the mounted directory, they are not the same as I set using fmask
and dmask
.
So, what are they actually doing?
fmask
and dmask
are mount
options for the FAT filesystem, based on fstab
.
They are used to define permissions (umask
sets them to both files and directories, while fmask
only applies to files and dmask
to directories).
The masks are NOT the permissions of the file, they are used to get the permissions you want. In addition, masks can't add any permissions, they only limit what permissions a file or a directory can have.
The umask
is the default for files and folders, if you want to customize files and folders’s permissions you should use fmask
and dmask
same use as the umask
.
The mask permissions are not like the octal permission codes passed to the chmod
command, however this table is really helpful understanding how the masks permissions work :
0 1 2 3 4 5 6 7
r + + + + - - - -
w + + - - + + - -
x + - + - + - + -
It works as the normal octal permissions but subtracted from 7, and use the absolute value. for instance if you want to set the permissions to 0777
you will need to set it 0000
in the umask
(e.g. umask=0000
), if you want to set it to 0755
you will set it to 0022
:
- The first character represents that its an octal permissions
- The second is for the owner
- The third is the group
- The fourth is for other, i.e any other user
(Source)
man mount
gives this :
umask=value
Set the umask (the bitmask of the permissions that are not
present). The default is the umask of the current process. The
value is given in octal.
dmask=value
Set the umask applied to directories only. The default is the
umask of the current process. The value is given in octal.
fmask=value
Set the umask applied to regular files only. The default is the
umask of the current process. The value is given in octal.
You'll also find examples and technical explaination from Drenriza on Ubuntuforums and of course Wikipedia helps a lot, as usual.