how do I mount a CIFS share so I can fully control the mounted volume on the client

46,918

If you add the share to fstab you should be ok, but remember you need to have a network connection before you actually mount the drive. There "network" option is for that.

Now as to making it look "exactly" like a native partition, you can't. There are certain things that are not supported over a network drive. There are even more things that "may" be support, but depends on the hosts configuration.

You can get pretty close though.

Never mount things as root (across the network)

Change your configuration so that

mount -t cifs -o username=someuser,password=somepass //192.168.0.110/backup /var/backup

Then in /etc/fstab add

//192.168.0.110/backup /var/backup cifs username=someuser,password=somepass,network,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 

The dir_mode and file_mode force the local files to work like they have those permissions. You can also set other masking options and user options to allow others to access the folders. Keep in mind this removes a layer of security. If your trying to run backups you might want to try backups over SSH or NFS if possible. (NFS is like CIFS but much nicer for Linux to Linux shares, and SSH is supported by almost every backup tool out there).

Share:
46,918
user50536
Author by

user50536

Updated on September 18, 2022

Comments

  • user50536
    user50536 almost 2 years

    It's a simple question: but I am in much pain over this situation, so here is the question:

    How can I "mount" a share so that a) the share is run on boot b) that I can control things like chown/chmod from the client.

    # mount -t cifs -o username=root,password=******** //192.168.0.110/backup/ /var/backup/
    # chown -R wwwroot:www /var/backup/
    

    this second line will fail as a million "Permission Denied", is there anyway I can place the system settings such that a) this self same command in /etc/fstab/ auto-mounts and b) set things up so I can manage the share as if it were to behave exactly like a local volume

  • SarahG
    SarahG over 10 years
    Also keep in mind that cifs is supposed to be for user mounts not entire systems. It basically assumes you will be mounting 1 user on this side to 1 user on that side.
  • user50536
    user50536 over 10 years
    thanks for your help, in the end I added it as nfs :-) still u answered correctly
  • Kalle Richter
    Kalle Richter almost 8 years
    Are file_mode=0777,dir_mode=0777,noperm expected to be listed in the output of mount?
  • can-ned_food
    can-ned_food almost 7 years
    @KarlRichter I probably didn't catch your question properly, but those are all options available with the mount.cifs tool.