2

I have a server running a samba instance which I access with cifs. When the system boots the folder is mounted but with wrong uid and gid. When I umuont and mount again manually, uid and gid are set correct (according to my credentials file).

Here's the relevant fstab:

//arkansas-1/data/ /home/me/dataArk cifs defaults,users,credentials=/home/me/.cred

Thanks for suggestions!

BandGap
  • 123
  • 1
  • 3

1 Answers1

4

The UID and GID used for the mounted fs is different from the credentials used to connect to the cifs fileserver. So, I can connect to the fileserver as bob, but mount the filesystem as larry. So, you should use the uid and gid mount options in addition to the credentials option.

from http://webscript.princeton.edu/~pug/faqwiki/index.php?title=Using_SAMBA/CIFS_to_access_Windows_Shares

for example, if your NetID is "zorro999" and your password is "zorrospassword", and you use /etc/cifspw for the credentials filename, and your local user on your home computer is called "bigzorro", your fstab should have the following line

//files.princeton.edu/zorro999 /mnt/h-drive cifs uid=bigzorro,credentials=/etc/cifspw,domain=Princeton 0 0 

of, if you want to mount it with SAMBA, it should look like

//files.princeton.edu/zorro999 /mnt/h-drive smbfs uid=bigzorro,credentials=/etc/cifspw,workgroup=Princeton 0 0 

and in /etc/cifspw should be

username=zorro999
password=zorrospassword

[edit]

Jeff Putney
  • 211
  • 1
  • 2
  • Ok thanks for your suggestions but I'm still confused about the fact that a simple "umount; mount dataArk" stanza mounts the folder with the correct permissions. Does that mean that in the boot process my UID and GID are not avaiable when fstab is executed? – BandGap Aug 14 '12 at 08:28
  • I actually tested your suggestions and it worked so far that I can edit files. Unfortunately I cannot execute them. The worst thing though is that when I manually umount and mount again, the uid is set to root. I also added a gid=me to fstab with the effect that gid is also set to root when I ummount/mount... I don't understand why that is happening. – BandGap Aug 14 '12 at 09:18
  • That is absolutely correct, the 'users' option will cause mount to use the uid of the user running the command. At boot time, that is root. As for making files executable, you need to tell mount what permissions to use. The relevant option for cifs is 'file_mode'. So, adding something like 'file_mode=0754' to the options list would make all files read/write/execute for the uid in the mount command, read/execute for the gid, and read-only for all others. – Jeff Putney Aug 14 '12 at 12:32