I mounted a Windows share on CentOS 7, but I have read only access to it. I need write access.
Commands used to mount the share…
sudo mkdir /media/shared
sudo chmod 777 /media/shared
sudo vim /etc/fstab
//192.168.16.25/shared /media/shared cifs
username=XXXX,password=XXXX,uid=1000,gid=1000 0 0
It mounts fine, but the owner is now "admin" and it's read only…
$ ls -lrt
total 8
drwxr-xr-x 2 admin admin 4096 Aug 7 18:11 shared
And I can't change it
$ sudo chown -R root shared
chown: changing ownership of ‘shared/System Volume Information’:
Permission denied
sudo chown: changing ownership of ‘shared’: Permission denied
$ sudo chmod 777 shared
chmod: changing permissions of ‘shared’: Permission denied
What am I missing? And on the Windows Server, the drive is shared with "Everyone" with full access.
Fixed! Here is the solution to what I changed the config to in fstab…
//192.168.16.25/shared /mnt/shared cifs username=XXXX,password=XXXX,uid=0,gid=0,file_mode=0777,dir_mode=0777 0 0
Best Answer
Please read up on file ownership and permissions in the mount.cifs manual, which is part of the cifs-utils RPM package:
Basically you are using the mount options
uid=1000,gid=1000
to force a specific owner of the mounted share, which is what makes yourchown
command fail.If you want to change the owner, simply mount the share with the correct owner in the
uid=?,gid=?
mount options in/etc/fstab
instead of usingchown
and usefile_mode=?
anddir_mode=?
instead ofchmod
.