Directory changes permission when mounted

mountpermissionssamba

I want to mount a samba sghare to a directory in my home dir. I have created it but mount the share as root. Upon mount, the owner of my dir changes to root and my user doesn't have permission tow rite files on the share… How do I modify my mount line to be able to mount with write permissions? It currently looks like this: sudo mount -t cifs //IP/share/ /mount/point/ -o rw,username=user,password=pass,domain=domain

Best Answer

Use the uid and gid mount options:

uid=arg

sets the uid that will own all files or directories on the mounted filesystem when the server does not provide ownership information. It may be specified as either a username or a numeric uid. When not specified, the default is uid 0. The mount.cifs helper must be at version 1.10 or higher to support specifying the uid in non-numeric form. See the section on FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS below for more information.

forceuid

instructs the client to ignore any uid provided by the server for files and directories and to always assign the owner to be the value of the uid= option. See the section on FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS below for more information.

gid=arg

sets the gid that will own all files or directories on the mounted filesystem when the server does not provide ownership information. It may be specified as either a groupname or a numeric gid. When not specified, the default is gid 0. The mount.cifs helper must be at version 1.10 or higher to support specifying the gid in non-numeric form. See the section on FILE AND DIRECTORY OWNERSHIP AND PERMISSIONS below for more information.

Related Question