CentOS 7.x mount samba share

From Notes_Wiki

Home > CentOS > CentOS 7.x > File sharing > Samba > CentOS 7.x mount samba share

To mount samba (CIFS or Windows file sharing) file share in Linux use

  1. yum -y install cifs-utils samba-client
  2. Create desired mountpoint such as:
    mkdir /mnt/fileserver
  3. List mountpoints using:
    smbclient -L <IP> -U username
    and enter password for listing mount points
  4. To access files without mouting use:
    smbclient //<ip>/share -U username
    and enter password to get smb client based file access.
  5. Mounting using command similar to:
    mount -t cifs --verbose '//<IP>/<share-name>' /mnt/fileserver -o 'username=administrator,password=secret'
  6. In case of older Windows Server 2003 above command fails with output:
    mount.cifs kernel mount options: ip=<ip>,unc=\\<server>\<share-name>,user=administrator,pass=********
    mount error(95): Operation not supported
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
    with /var/log/messages having suggestion:
    Apr 8 22:05:04 localhost kernel: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
    Apr 8 22:05:04 localhost kernel: CIFS VFS: Dialect not supported by server. Consider specifying vers=1.0 or vers=2.0 on mount for accessing older servers
    Apr 8 22:05:04 localhost kernel: CIFS VFS: cifs_mount failed w/return code = -95
  7. After this mounting worked using:
    mount -t cifs --verbose '//<IP>/<share-name>' /mnt/fileserver -o 'username=administrator,password=secret,vers=1.0'


Refer:


Adding samba mount to /etc/fstab

We can add Samba mount to /etc/fstab via:

//<server>/<share> <local-mount-point> cifs username=administrator,password=<redacted>,file_mode=0777,dir_mode=0777,noauto 0 0

Here:

file_mode=0777 and dir_mode=0777
are used to allow the files to be edited by everyone.
noauto
Ensures that this is not automatically mounted on boot


Home > CentOS > CentOS 7.x > File sharing > Samba > CentOS 7.x mount samba share