Mount a CIFS Share on Ubuntu for FileCloud

You might need to mount a CIFS network share on Linux, so that FileCloud can use storage located on network devices for both local storage as well as external shares.

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

Assumptions

Parameter

Value

Remote CIFS share path

//192.168.1.120/storage

Local mount path

/mnt/storage

CIFS user

username

CIFS password

password

Apache User UID

33
Note: Verify the correct UID on your server.

Apache User GID

33
Note: Verify the correct GID on your server.

Pre-requisites

Ensure that the mount.cifs command is installed on your system.

Required Packages

Ubuntu: cifs-utils

Installing cifs-utils on Ubuntu
PowerShell
user@host:~$ sudo apt-get update
user@host:~$ sudo apt-get install cifs-utils

Mounting

Use the following command to mount the CIFS share

Command Line
PowerShell
user@host:~$ mount -t cifs -o username=username,password=password,uid=33,gid=33,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
user@host:~$ mount -t cifs -o credentials=/root/.the-creds-file,uid=33,gid=33,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 //192.168.1.120/storage /mnt/storage

Auto Mounting

To perform auto mounting of windows share, you need to create a password file and use that in /etc/fstab. Follow the steps here:

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

    Command Line

    PowerShell
    username=winuser
    password=winpass
    
    

    Here winuser and winpass are the username and password for the remote CIFS share.

  2. Change the permissions such that only root can read the file.

    Command Line

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

    Command Line

    PowerShell
    //192.168.1.120/storage /mnt/storage        cifs    credentials=/root/.smbcredentials,uid=33,gid=33,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
    
  4. Test if the line added in the fstab file works.

    Command Line

    PowerShell
    # sudo mount -a
    

    If you receive a host not found error while mounting, add vers=3.0 to the mount options after dir_mode=0777 as shown below:

    //192.168.1.120/storage /mnt/storage cifs credentials=/root/.smbcredentials,uid=33,gid=33,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,vers=3.0 0 0
    

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