How to properly mount a CIFS share on Linux for FileCloud

You might need to mount a CIFS network share on Linux so that FileCloud can use storage from devices over the network for both local storage and external shares.

Use these instructions to mount a CIFS share in a way that prevents FileCloud from encountering any permission issues. 

Assumptions

ParameterValue
Remote CIFS share path//192.168.1.120/filecloud
Local mount path/mnt/storage
CIFS userusername
CIFS passwordpassword
Apache user uid

48. Note: check your server for the right uid

Apache user gid

48. Note: check your server for the right gid

Prerequisites

Ensure the command mount.cifs is present in your distro. Here is the list of packages that provide this utility in different distros.

Required Packages

RHEL: cifs-utils

yum update -y
yum install cifs-utils

Mounting

Use the following command to mount the CIFS share:

mount -t cifs -
o username=username,password=password,uid=48,gid=48,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 //192.168.1.120/storage /mnt/storage

or if you have credential files at /root/.this-creds-file:

mount -t cifs -o credentials=/root/.the-creds-file,uid=48,gid=48,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 //192.168.1.120/storage


Auto Mounting

To perform auto mounting of a Windows share, create a password file, and use it in /etc/fstab. Follow the steps here:

  1. Create a file /root/.smbcredentials with the following content.

    username=filecloud
    password=password 
  2. Change the permissions such that only root can read the file.

    chmod 700 /root/.smbcredentials
    
  3. Now add the following line in /etc/fstab file.

    //192.168.1.120/storage /mnt/storage        cifs    credentials=/root/.smbcredentials,uid=48,gid=48,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0 
  4. Reload systemctl daemon.

    systemctl daemon-reload
  5. Test if the line added in the fstab file works.

    mount -a
    

    Now the remote share should be mounted at /mnt/storage.