Centos – How to set permissions for a CIFS mount with autofs

autofscentoschmodcifsmount

I've set up a CIFS mount on my CentOS 6.4 server with autofs :

File /etc/auto.mnt :

Photos -fstype=cifs,perm,rw,uid=505,forceuid,gid=505,forcegid,file_mode=0770,dir_mode=0770,credentials=/root/credentials.txt ://adsrv01/Photos

What a ls command shows :

[root@websrv01 mnt]# ls -l
total 4
drwxr-xr-x 1 root root 4096 Apr 26 12:01 Photos

What I expect from the ls command :

[root@websrv01 mnt]# ls -l
total 4
drwxrwx--- 1 photos photos 4096 Apr 26 12:01 Photos

Do you see anything wrong ? How can I set owner and chmod right ?

Edit : I forgot to say that chown and chmod commands are denied for root user on the /mnt/Photos directory. I can't get it right, and I also tried using fstab.

This is what happens with fstab :

mkdir /mnt/Photos
chmod 770 /mnt/Photos
chown photos:photos /mnt/Photos
mount /mnt/Photos

The permissions are automatically changed and set to 755 when the directory is mounted. I can't set the mode back to 770 : permission denied.

Best Answer

I found the answer : you have to use the option nounix together with file_mode and dir_mode

Here is my fstab :

//adsrv01/Photos      /mnt/Photos           cifs    credentials=/root/credentials.txt,file_mode=0770,dir_mode=0770,nounix,uid=505,gid=505 0 0