How to properly mount a CIFS share on RHEL for FileCloud

You may need to mount a CIFS network share on Linux so that FileCloud can use storage located on network devices 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

Parameter

Value

Remote CIFS share path

//192.168.1.120/filecloud

Local mount path

/mnt/storage

CIFS user

username

CIFS password

password

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 that the mount.cifs command is installed.

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 to the /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 whether the line added in the fstab file works.

    mount -a
    

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