How to properly mount a CIFS share on Linux for FileCloud
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 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:
Create a file /root/.smbcredentials with the following content.
username=filecloud password=password
Change the permissions such that only root can read the file.
chmod 700 /root/.smbcredentials
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
Reload systemctl daemon.
systemctl daemon-reload
Test if the line added in the fstab file works.
mount -a
Now the remote share should be mounted at /mnt/storage.